diff --git a/.github/workflows/minitest.yml b/.github/workflows/minitest.yml index ba1f1624a8b5..b4c5488c6722 100644 --- a/.github/workflows/minitest.yml +++ b/.github/workflows/minitest.yml @@ -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 @@ -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 diff --git a/bin/minitest-ci b/bin/minitest-ci new file mode 100644 index 000000000000..afb657fa9bf4 --- /dev/null +++ b/bin/minitest-ci @@ -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(" ")}" diff --git a/test/unit/inflections_test.rb b/test/unit/inflections_test.rb index d2e715d4dc3c..1a40883646e5 100644 --- a/test/unit/inflections_test.rb +++ b/test/unit/inflections_test.rb @@ -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