Skip to content

Commit

Permalink
Check ruby test coverage before merging PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
unoduetre committed Jun 25, 2024
1 parent bd31bca commit fd8da51
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions .github/workflows/minitest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions .github/workflows/pact-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Empty file.
19 changes: 19 additions & 0 deletions .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Check test coverage

on:
workflow_call:

jobs:
check_ruby_test_coverage:
name: Check Ruby 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
7 changes: 7 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit fd8da51

Please sign in to comment.