|
14 | 14 | # see https://docs.github.com/en/actions/how-tos/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token |
15 | 15 | permissions: {} |
16 | 16 |
|
| 17 | +concurrency: |
| 18 | + group: '${{ github.workflow }}-${{ github.ref }}' |
| 19 | + cancel-in-progress: true |
| 20 | + |
| 21 | +env: |
| 22 | + COVERAGE_DIR: coverage |
| 23 | + TESTS_COVERAGE_ARTIFACT: coverage |
| 24 | + |
17 | 25 | jobs: |
18 | 26 | test: |
19 | 27 | name: Ruby ${{ matrix.ruby }} |
|
39 | 47 | bundler-cache: true |
40 | 48 | - name: Run the default task |
41 | 49 | run: bundle exec rake |
| 50 | + - name: Artifact coverage |
| 51 | + if: ${{ ! cancelled() }} |
| 52 | + # see https://github.com/actions/upload-artifact |
| 53 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 54 | + with: |
| 55 | + name: '${{ env.TESTS_COVERAGE_ARTIFACT }}_ruby${{ matrix.ruby }}' |
| 56 | + path: ${{ env.COVERAGE_DIR }} |
| 57 | + if-no-files-found: error |
| 58 | + retention-days: 7 |
| 59 | + report-coverage: |
| 60 | + name: Publish test coverage |
| 61 | + needs: [ "test" ] |
| 62 | + runs-on: ubuntu-latest |
| 63 | + timeout-minutes: 5 |
| 64 | + steps: |
| 65 | + - name: fetch test artifacts |
| 66 | + # see https://github.com/actions/download-artifact |
| 67 | + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 68 | + with: |
| 69 | + pattern: '${{ env.TESTS_COVERAGE_ARTIFACT }}_*' |
| 70 | + merge-multiple: false |
| 71 | + - name: Run codacy-coverage-reporter |
| 72 | + env: |
| 73 | + CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} |
| 74 | + ## see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-secrets |
| 75 | + if: ${{ env.CODACY_PROJECT_TOKEN != '' }} |
| 76 | + # see https://github.com/codacy/codacy-coverage-reporter-action |
| 77 | + uses: codacy/codacy-coverage-reporter-action@89d6c85cfafaec52c72b6c5e8b2878d33104c699 # v1 |
| 78 | + with: |
| 79 | + project-token: ${{ env.CODACY_PROJECT_TOKEN }} |
| 80 | + coverage-reports: '${{ env.TESTS_COVERAGE_ARTIFACT }}_*/coverage.xml' |
0 commit comments