|
| 1 | +name: Code Coverage |
| 2 | + |
| 3 | +env: |
| 4 | + K_SOUP_COV_MIN_BRANCH: 85 |
| 5 | + K_SOUP_COV_MIN_LINE: 87 |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - 'main' |
| 11 | + tags: |
| 12 | + - '!*' # Do not execute on tags |
| 13 | + pull_request: |
| 14 | + branches: |
| 15 | + - '*' |
| 16 | + # Allow manually triggering the workflow. |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +# Cancels all previous workflow runs for the same branch that have not yet completed. |
| 20 | +concurrency: |
| 21 | + # The concurrency group contains the workflow name and the branch name. |
| 22 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 23 | + cancel-in-progress: true |
| 24 | + |
| 25 | +jobs: |
| 26 | + test: |
| 27 | + name: Specs with Coverage - Ruby ${{ matrix.ruby }} |
| 28 | + if: "!contains(github.event.commits[0].message, '[ci skip]') && !contains(github.event.commits[0].message, '[skip ci]')" |
| 29 | + env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps |
| 30 | + BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile |
| 31 | + CI_CODECOV: true |
| 32 | + COVER_ALL: true |
| 33 | + strategy: |
| 34 | + fail-fast: false |
| 35 | + matrix: |
| 36 | + experimental: [false] |
| 37 | + rubygems: |
| 38 | + - latest |
| 39 | + bundler: |
| 40 | + - latest |
| 41 | + gemfile: |
| 42 | + - coverage |
| 43 | + ruby: |
| 44 | + - "3.2" |
| 45 | + |
| 46 | + runs-on: ubuntu-latest |
| 47 | + steps: |
| 48 | + - name: Checkout |
| 49 | + uses: actions/checkout@v3 |
| 50 | + |
| 51 | + - name: Setup Ruby & Bundle |
| 52 | + uses: ruby/setup-ruby@v1 |
| 53 | + with: |
| 54 | + ruby-version: ${{ matrix.ruby }} |
| 55 | + rubygems: ${{ matrix.rubygems }} |
| 56 | + bundler: ${{ matrix.bundler }} |
| 57 | + bundler-cache: true |
| 58 | + |
| 59 | + - name: Run RSpec tests |
| 60 | + run: | |
| 61 | + bundle exec rspec |
| 62 | +
|
| 63 | + - name: Code Coverage Summary Report |
| 64 | + uses: irongut/CodeCoverageSummary@v1.3.0 |
| 65 | + if: ${{ github.event_name == 'pull_request' }} |
| 66 | + with: |
| 67 | + filename: ./coverage/coverage.xml |
| 68 | + badge: true |
| 69 | + fail_below_min: true |
| 70 | + format: markdown |
| 71 | + hide_branch_rate: false |
| 72 | + hide_complexity: true |
| 73 | + indicators: true |
| 74 | + output: both |
| 75 | + # https://github.com/irongut/CodeCoverageSummary#thresholds |
| 76 | + thresholds: "75 85" |
| 77 | + continue-on-error: ${{ matrix.experimental != 'false' }} |
| 78 | + |
| 79 | + - name: Add Coverage PR Comment |
| 80 | + uses: marocchino/sticky-pull-request-comment@v2 |
| 81 | + if: ${{ github.event_name == 'pull_request' }} |
| 82 | + with: |
| 83 | + recreate: true |
| 84 | + path: code-coverage-results.md |
| 85 | + continue-on-error: ${{ matrix.experimental != 'false' }} |
| 86 | + |
| 87 | + - name: Coveralls |
| 88 | + uses: coverallsapp/github-action@master |
| 89 | + with: |
| 90 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 91 | + continue-on-error: ${{ matrix.experimental != 'false' }} |
0 commit comments