|
| 1 | +name: Test Coverage |
| 2 | + |
| 3 | +env: |
| 4 | + K_SOUP_COV_MIN_BRANCH: 2 |
| 5 | + K_SOUP_COV_MIN_LINE: 46 |
| 6 | + K_SOUP_COV_MIN_HARD: true |
| 7 | + K_SOUP_COV_DO: true |
| 8 | + K_SOUP_COV_COMMAND_NAME: "RSpec 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 | + coverage: |
| 33 | + name: Code Coverage on ${{ matrix.ruby }}@current |
| 34 | + if: "!contains(github.event.commits[0].message, '[ci skip]') && !contains(github.event.commits[0].message, '[skip ci]')" |
| 35 | + runs-on: ubuntu-latest |
| 36 | + continue-on-error: ${{ matrix.experimental || endsWith(matrix.ruby, 'head') }} |
| 37 | + env: # $BUNDLE_GEMFILE must be set at job level, so it is set for all steps |
| 38 | + BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}.gemfile |
| 39 | + strategy: |
| 40 | + fail-fast: false |
| 41 | + matrix: |
| 42 | + include: |
| 43 | + # Coverage |
| 44 | + - ruby: "ruby" |
| 45 | + appraisal: "coverage" |
| 46 | + exec_cmd: "rake test" |
| 47 | + gemfile: "Appraisal.root" |
| 48 | + rubygems: latest |
| 49 | + bundler: latest |
| 50 | + |
| 51 | + steps: |
| 52 | + - uses: amancevice/setup-code-climate@v2 |
| 53 | + name: CodeClimate Install |
| 54 | + if: ${{ github.event_name != 'pull_request' }} |
| 55 | + with: |
| 56 | + cc_test_reporter_id: ${{ secrets.CC_TEST_REPORTER_ID }} |
| 57 | + |
| 58 | + - name: Checkout |
| 59 | + uses: actions/checkout@v4 |
| 60 | + |
| 61 | + - name: Setup Ruby & RubyGems |
| 62 | + uses: ruby/setup-ruby@v1 |
| 63 | + with: |
| 64 | + ruby-version: "${{ matrix.ruby }}" |
| 65 | + rubygems: "${{ matrix.rubygems }}" |
| 66 | + bundler: "${{ matrix.bundler }}" |
| 67 | + bundler-cache: false |
| 68 | + |
| 69 | + - name: CodeClimate Pre-build Notification |
| 70 | + run: cc-test-reporter before-build |
| 71 | + if: ${{ github.event_name != 'pull_request' }} |
| 72 | + continue-on-error: ${{ matrix.experimental != 'false' }} |
| 73 | + |
| 74 | + # Raw `bundle` will use the BUNDLE_GEMFILE set to matrix.gemfile (i.e. Appraisal.root) |
| 75 | + # We need to do this first to get appraisal installed. |
| 76 | + # NOTE: This does not use the main Gemfile at all. |
| 77 | + - name: Install Root Appraisal |
| 78 | + run: bundle |
| 79 | + - name: Appraisal for ${{ matrix.appraisal }} |
| 80 | + run: bundle exec appraisal ${{ matrix.appraisal }} bundle |
| 81 | + - name: Tests for ${{ matrix.ruby }}@current via ${{ matrix.exec_cmd }} |
| 82 | + run: bundle exec appraisal ${{ matrix.appraisal }} bundle exec ${{ matrix.exec_cmd }} |
| 83 | + |
| 84 | + - name: CodeClimate Post-build Notification |
| 85 | + run: cc-test-reporter after-build |
| 86 | + if: ${{ github.event_name != 'pull_request' }} |
| 87 | + continue-on-error: ${{ matrix.experimental != 'false' }} |
| 88 | + |
| 89 | + - name: Code Coverage Summary Report |
| 90 | + |
| 91 | + if: ${{ github.event_name == 'pull_request' }} |
| 92 | + with: |
| 93 | + filename: ./coverage/coverage.xml |
| 94 | + badge: true |
| 95 | + fail_below_min: true |
| 96 | + format: markdown |
| 97 | + hide_branch_rate: false |
| 98 | + hide_complexity: true |
| 99 | + indicators: true |
| 100 | + output: both |
| 101 | + thresholds: '69 80' |
| 102 | + continue-on-error: ${{ matrix.experimental != 'false' }} |
| 103 | + |
| 104 | + - name: Add Coverage PR Comment |
| 105 | + uses: marocchino/sticky-pull-request-comment@v2 |
| 106 | + if: ${{ github.event_name == 'pull_request' }} |
| 107 | + with: |
| 108 | + recreate: true |
| 109 | + path: code-coverage-results.md |
| 110 | + continue-on-error: ${{ matrix.experimental != 'false' }} |
| 111 | + |
| 112 | + - name: Coveralls |
| 113 | + uses: coverallsapp/github-action@master |
| 114 | + with: |
| 115 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 116 | + continue-on-error: ${{ matrix.experimental != 'false' }} |
| 117 | + |
| 118 | + - name: Upload results to Codecov |
| 119 | + uses: codecov/codecov-action@v5 |
| 120 | + with: |
| 121 | + token: ${{ secrets.CODECOV_TOKEN }} |
0 commit comments