diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08a813b098..51ab6b245e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,3 +61,7 @@ jobs: uses: ./.github/workflows/pact-verify.yml with: ref: ${{ github.ref }} + + test-coverage: + name: Check test coverage + uses: ./.github/workflows/test-coverage.yml diff --git a/.github/workflows/minitest.yml b/.github/workflows/minitest.yml index 10e4788fca..fc877d9f66 100644 --- a/.github/workflows/minitest.yml +++ b/.github/workflows/minitest.yml @@ -47,3 +47,10 @@ jobs: RAILS_ENV: test GOVUK_CONTENT_SCHEMAS_PATH: vendor/publishing-api/content_schemas run: bundle exec rake test + + - name: Store test coverage percentage + uses: actions/upload-artifact@v4 + with: + name: minitest-test-coverage + path: coverage/percentage.txt + retention-days: 1 diff --git a/.github/workflows/pact-verify.yml b/.github/workflows/pact-verify.yml index cc36d0c5a6..f941855c82 100644 --- a/.github/workflows/pact-verify.yml +++ b/.github/workflows/pact-verify.yml @@ -64,3 +64,10 @@ jobs: - if: inputs.pact_artifact != '' run: bundle exec rake pact:verify:at[tmp/pacts/${{ inputs.pact_artifact_file_to_verify }}] + + - name: Store test coverage percentage + uses: actions/upload-artifact@v4 + with: + name: pact-test-coverage + path: coverage/percentage.txt + retention-days: 1 diff --git a/.github/workflows/store-test-coverage-percentage.yml b/.github/workflows/store-test-coverage-percentage.yml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.github/workflows/test-coverage.yml b/.github/workflows/test-coverage.yml new file mode 100644 index 0000000000..7e34578817 --- /dev/null +++ b/.github/workflows/test-coverage.yml @@ -0,0 +1,19 @@ +name: Check test coverage + +on: + workflow_call: + +jobs: + name: Check test coverage + runs-on: ubuntu-latest + steps: + - name: Retrieve minitest test coverage + uses: actions/download-artifact@v4 + with: + name: minitest-test-overage + - name: Retrieve pact test coverage + with: + name: minitest-test-overage + - name: Check Ruby test coverage + run: ls -R + diff --git a/test/test_helper.rb b/test/test_helper.rb index fb0ff388a2..9582f1f2f8 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,4 +1,11 @@ require "simplecov" +SimpleCov.at_exit do + SimpleCov.result.format! + File.write( + Rails.root.join("coverage/percentage.txt"), + SimpleCov.result.coverage_statistics[:line].percent.to_s, + ) +end SimpleCov.start "rails" require "i18n/coverage"