diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 645a8160..98978970 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,12 +43,13 @@ jobs: test: permissions: - issues: write + # Gives the action the necessary permissions for publishing new + # comments in pull requests. pull-requests: write - statuses: write - checks: write + # Gives the action the necessary permissions for pushing data to the + # python-coverage-comment-action branch, and for editing existing + # comments (to avoid publishing multiple comments in the same PR) contents: write - actions: read runs-on: ubuntu-latest strategy: matrix: @@ -78,9 +79,17 @@ jobs: coverage xml if: success() || failure() - - name: Publish coverage report - if: ${{ github.event_name == 'pull_request' }} - uses: orgoro/coverage@v3 + - name: Coverage comment + id: coverage_comment + uses: py-cov-action/python-coverage-comment-action@v3 with: - coverageFile: coverage.xml - token: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ github.token }} + + - name: Store Pull Request comment to be posted + uses: actions/upload-artifact@v3 + if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' + with: + # If you use a different name, update COMMENT_ARTIFACT_NAME accordingly + name: python-coverage-comment-action + # If you use a different name, update COMMENT_FILENAME accordingly + path: python-coverage-comment-action.txt