☂️ parse and publish coverage xml to a PR, enforce coverage rate on new & modified files
Create a new workflow .yml file in the .github/workflows/ directory.
You can create a coverage report using python:
- pytest
$ pytest --cov-report xml:path/to/coverage.xml - coverage
$ coverage xml path/to/coverage.xml
name: 'coverage'
on:
pull_request:
branches:
- master
- main
permissions:
contents: read
pull-requests: write
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- name: Get Cover
uses: orgoro/coverage@v3.2
with:
coverageFile: path/to/coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}The action needs pull-requests: write to post (and update) the coverage comment, and contents: read to fetch the diff between base and head. If your workflow restricts the default token (e.g. via a repo-wide permissions: read-all), set them explicitly as shown above.

