Skip to content

Commit 086f686

Browse files
Add pytest coverage comment to PRs
Add MishaKav/pytest-coverage-comment action to post code coverage summary as a PR comment. Changes include: - Add permissions block with pull-requests: write - Add --junitxml=pytest.xml flag for test summary - Add coverage comment step with per-file breakdown Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c39397b commit 086f686

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

.github/workflows/test.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ on:
2020
- demo
2121
- hotfix
2222

23+
permissions:
24+
contents: read
25+
actions: read
26+
pull-requests: write
27+
2328
jobs:
2429
test:
2530
runs-on: ubuntu-latest
@@ -51,8 +56,20 @@ jobs:
5156
- name: Run tests with coverage
5257
if: env.skip_tests == 'false'
5358
run: |
54-
pytest --cov=. --cov-report=term-missing --cov-report=xml --ignore=tests/e2e-test/tests
59+
pytest --cov=. --cov-report=term-missing --cov-report=xml --junitxml=pytest.xml --ignore=tests/e2e-test/tests
5560
61+
- name: Pytest Coverage Comment
62+
if: |
63+
always() &&
64+
github.event_name == 'pull_request' &&
65+
github.event.pull_request.head.repo.fork == false &&
66+
env.skip_tests == 'false'
67+
uses: MishaKav/pytest-coverage-comment@26f986d2599c288bb62f623d29c2da98609e9cd4 # v1.6.0
68+
with:
69+
pytest-xml-coverage-path: coverage.xml
70+
junitxml-path: pytest.xml
71+
report-only-changed-files: true
72+
5673
- name: Skip coverage report if no tests
5774
if: env.skip_tests == 'true'
5875
run: |

0 commit comments

Comments
 (0)