Skip to content

Commit

Permalink
Testing random assignment behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Young committed Oct 10, 2023
1 parent 6e25cef commit 5bfa0b3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/minitest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ jobs:
strategy:
fail-fast: false
matrix:
ci_node_index: [
"test/unit/lib test/unit/app/helpers test/unit/app/presenters test/unit/app/validators test/unit/app/workers test/views",
"test/unit/app/models test/unit/app/services test/unit/app/uploaders test/unit/*_test.rb",
"test/functional test/components test/integration"
]
ci_node_total: [3]
ci_node_index: [0, 1, 2]
steps:
- name: Setup MySQL
id: setup-mysql
Expand Down Expand Up @@ -68,9 +65,15 @@ jobs:
TEST_DATABASE_URL: ${{ steps.setup-mysql.outputs.db-url }}
run: bundle exec rails db:setup

- name: Make bin/minitest-ci executable
run: chmod +x ./bin/minitest-ci

- name: Run Minitest
env:
RAILS_ENV: test
GOVUK_CONTENT_SCHEMAS_PATH: vendor/publishing-api/content_schemas
TEST_DATABASE_URL: ${{ steps.setup-mysql.outputs.db-url }}
run: bundle exec rails test ${{ matrix.ci_node_index }}
CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
CI_NODE_INDEX: ${{ matrix.ci_node_index }}
run: |
./bin/minitest-ci
12 changes: 12 additions & 0 deletions bin/minitest-ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env ruby

tests = Dir["test/**/*_test.rb"].
sort.
# Add randomization seed based on SHA of each commit
shuffle(random: Random.new(ENV['GITHUB_SHA'].to_i(16))).
select.
with_index do |el, i|
i % ENV["CI_NODE_TOTAL"].to_i == ENV["CI_NODE_INDEX"].to_i
end

exec "bundle exec rails test #{tests.join(" ")}"
2 changes: 1 addition & 1 deletion test/unit/inflections_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class InflectionsTest < ActiveSupport::TestCase

test "Secretaries of things are plurlised correctly" do
assert_equal "Foreign Secretaries", "Foreign Secretary".pluralize
assert_equal "Cabinet Secretaries", "Cabinet Secretary".pluralize
assert_equal "Cabinet Secies", "Cabinet Secretary".pluralize
end

test "Call for evidence pluralises correctly" do
Expand Down

0 comments on commit 5bfa0b3

Please sign in to comment.