Based on this stackoverflow question, this is a GitHub Action for annotating the commits based on your Pytest coverage report.
- Generates
pytest
report leveragingcoverage
library (present insrc/entrypoint.sh
file). More specifically, these set of commands are run :This generates achanged_files=$(git diff --name-only --diff-filter=AM "$PR_BASE_SHA" "$PR_HEAD_SHA" | grep '\.py$' | tr '\n' ' ') python -m coverage run -m pytest $changed_files python -m coverage json
coverage.json
report file. This respects the.coveragerc
file present in the root of the repository. - Next, a Python script (
src/main.py
) parses the file and generateswarning
annotations using the GitHub Check runs API. We only generate50
annotations in a single run since that's the limit specified by the API specifications.