|
| 1 | +# Additional copyright: Joachim Jablon, kieferro (MIT license) |
1 | 2 | name: tox pytests |
2 | 3 |
|
3 | 4 | on: |
@@ -27,15 +28,64 @@ jobs: |
27 | 28 | - name: Install dependencies |
28 | 29 | run: | |
29 | 30 | python -m pip install --upgrade pip |
30 | | - python -m pip install tox tox-gh-actions coverage coveralls |
| 31 | + python -m pip install tox tox-gh-actions coverage |
31 | 32 | - name: Test with tox |
32 | 33 | run: tox |
| 34 | + env: |
| 35 | + COVERAGE_FILE: ".coverage.${{ matrix.python-version }}" |
| 36 | + # The file name prefix must be ".coverage." for "coverage combine" |
| 37 | + # enabled by "MERGE_COVERAGE_FILES: true" to work. A "subprocess" |
| 38 | + # error with the message "No data to combine" will be triggered if |
| 39 | + # this prefix is not used. |
33 | 40 |
|
34 | 41 | - name: Check test coverage |
35 | | - run: coverage report -m --fail-under=${{ matrix.vcs == 'bzr' && 84 || 85 }} |
36 | | - |
37 | | - - name: Report to coveralls |
38 | | - run: coveralls |
| 42 | + run: coverage report -m --fail-under=85 |
39 | 43 | env: |
40 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
41 | | - COVERALLS_SERVICE_NAME: github |
| 44 | + COVERAGE_FILE: ".coverage.${{ matrix.python-version }}" |
| 45 | + |
| 46 | + - name: Store coverage file |
| 47 | + uses: actions/upload-artifact@v4 |
| 48 | + with: |
| 49 | + name: coverage-${{ matrix.python-version }} |
| 50 | + path: .coverage.${{ matrix.python-version }} |
| 51 | + # By default hidden files/folders (i.e. starting with .) are ignored. |
| 52 | + # You may prefer (for security reasons) not setting this and instead |
| 53 | + # set COVERAGE_FILE above to not start with a `.`, but you cannot |
| 54 | + # use "MERGE_COVERAGE_FILES: true" later on and need to manually |
| 55 | + # combine the coverage file using "pipx run coverage combine" |
| 56 | + include-hidden-files: true |
| 57 | + |
| 58 | + coverage: |
| 59 | + name: Coverage |
| 60 | + runs-on: ubuntu-latest |
| 61 | + needs: pytest |
| 62 | + permissions: |
| 63 | + pull-requests: write |
| 64 | + contents: write |
| 65 | + steps: |
| 66 | + - uses: actions/checkout@v4 |
| 67 | + with: |
| 68 | + # This is optional since by default it's to true. The git |
| 69 | + # operations in python-coverage-comment-action utilize the token |
| 70 | + # stored by actions/checkout. |
| 71 | + persist-credentials: true |
| 72 | + |
| 73 | + - uses: actions/download-artifact@v4 |
| 74 | + id: download |
| 75 | + with: |
| 76 | + pattern: coverage-* |
| 77 | + merge-multiple: true |
| 78 | + |
| 79 | + - name: Coverage comment |
| 80 | + id: coverage_comment |
| 81 | + uses: py-cov-action/python-coverage-comment-action@v3 |
| 82 | + with: |
| 83 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 84 | + MERGE_COVERAGE_FILES: true |
| 85 | + |
| 86 | + - name: Store Pull Request comment to be posted |
| 87 | + uses: actions/upload-artifact@v4 |
| 88 | + if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' |
| 89 | + with: |
| 90 | + name: python-coverage-comment-action |
| 91 | + path: python-coverage-comment-action.txt |
0 commit comments