|
| 1 | +name: Ruby - Coverage |
| 2 | + |
| 3 | +env: |
| 4 | + K_SOUP_COV_MIN_BRANCH: 71 |
| 5 | + K_SOUP_COV_MIN_LINE: 89 |
| 6 | + K_SOUP_COV_MIN_HARD: true |
| 7 | + K_SOUP_COV_DO: true |
| 8 | + K_SOUP_COV_COMMAND_NAME: "MiniTest Coverage" |
| 9 | + |
| 10 | +on: |
| 11 | + push: |
| 12 | + branches: |
| 13 | + - 'main' |
| 14 | + tags: |
| 15 | + - '!*' # Do not execute on tags |
| 16 | + pull_request: |
| 17 | + branches: |
| 18 | + - '*' |
| 19 | + # Allow manually triggering the workflow. |
| 20 | + workflow_dispatch: |
| 21 | + |
| 22 | +permissions: |
| 23 | + contents: read |
| 24 | + |
| 25 | +# Cancels all previous workflow runs for the same branch that have not yet completed. |
| 26 | +concurrency: |
| 27 | + # The concurrency group contains the workflow name and the branch name. |
| 28 | + group: "${{ github.workflow }}-${{ github.ref }}" |
| 29 | + cancel-in-progress: true |
| 30 | + |
| 31 | +jobs: |
| 32 | + test: |
| 33 | + name: Specs with Coverage - Ruby ${{ matrix.ruby }} ${{ matrix.name_extra || '' }} |
| 34 | + if: "!contains(github.event.commits[0].message, '[ci skip]') && !contains(github.event.commits[0].message, '[skip ci]')" |
| 35 | + env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps |
| 36 | + BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile |
| 37 | + runs-on: ubuntu-latest |
| 38 | + strategy: |
| 39 | + matrix: |
| 40 | + rubygems: |
| 41 | + - latest |
| 42 | + bundler: |
| 43 | + - latest |
| 44 | + gemfile: |
| 45 | + - coverage |
| 46 | + ruby: |
| 47 | + - '3.1' |
| 48 | + |
| 49 | + steps: |
| 50 | + - name: Checkout |
| 51 | + uses: actions/checkout@v4 |
| 52 | + |
| 53 | + - name: Setup Ruby & RubyGems |
| 54 | + uses: ruby/setup-ruby@v1 |
| 55 | + with: |
| 56 | + ruby-version: "${{ matrix.ruby }}" |
| 57 | + rubygems: "${{ matrix.rubygems }}" |
| 58 | + bundler: "${{ matrix.bundler }}" |
| 59 | + bundler-cache: true # runs 'bundle install' and caches installed gems automatically |
| 60 | + |
| 61 | + - name: Run tests |
| 62 | + run: bundle exec rake test |
| 63 | + |
| 64 | + - name: Code Coverage Summary Report |
| 65 | + |
| 66 | + if: ${{ github.event_name == 'pull_request' }} |
| 67 | + with: |
| 68 | + filename: ./coverage/coverage.xml |
| 69 | + badge: true |
| 70 | + fail_below_min: true |
| 71 | + format: markdown |
| 72 | + hide_branch_rate: false |
| 73 | + hide_complexity: true |
| 74 | + indicators: true |
| 75 | + output: both |
| 76 | + thresholds: '93 82' |
| 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' }} |
0 commit comments