Skip to content

Commit

Permalink
Add code coverage to ci (catima#507)
Browse files Browse the repository at this point in the history
* Add code coverage to ci

* Fix ci configuration for coverage

* Fix ci configuration for coverage again

* Use forked action for minimum coverage check

* Test failure

* Test failure with fixed ci config file

* Rollback to working test suit

* Test with a variable for minimum_coverage

* Change the minimum coverage value

* Test failure

* Rollback to working test suit
  • Loading branch information
lucaguindani authored Feb 27, 2023
1 parent 6155cd8 commit 3752f27
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
33 changes: 30 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: ci
on: [push, pull_request]
jobs:
build:
test:
name: RUBY${{ matrix.ruby-versions }}
runs-on: ubuntu-20.04
strategy:
Expand Down Expand Up @@ -75,12 +75,39 @@ jobs:

- name: Test app
id: app-test
run: NO_COVERAGE=1 rails test
run: rails test

- name: Upload coverage artifact
id: upload-coverage-artifact
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: /home/runner/work/catima/catima/coverage

coverage:
name: Coverage
runs-on: ubuntu-latest
needs: test
if: success()
continue-on-error: false

steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: coverage-report
path: coverage

- name: Check minimum coverage
uses: unil-lettres/simplecov-check@main
with:
minimum_coverage: ${{ vars.MINIMUM_COVERAGE || 45 }}
coverage_path: coverage/.last_run.json

notification:
name: Notify
runs-on: ubuntu-latest
needs: build
needs: [test, coverage]
if: always()
continue-on-error: true

Expand Down
4 changes: 4 additions & 0 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
require "simplecov"
SimpleCov.start("rails") do
add_filter("/bin/")
add_filter("/test/")
add_filter("/rspec/")
add_filter("/app/controllers/api/")
add_filter("/lib/locales/")
add_filter("/lib/tasks/assets.rake")
add_filter("/lib/tasks/auto_annotate_models.rake")
add_filter("/lib/tasks/coverage.rake")
Expand Down

0 comments on commit 3752f27

Please sign in to comment.