Skip to content

Commit 8c766a5

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 pull-requests: write permission - 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 201acae commit 8c766a5

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

.github/workflows/test.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ on:
3636
permissions:
3737
contents: read
3838
actions: read
39+
pull-requests: write
3940
jobs:
4041
backend_tests:
4142
runs-on: ubuntu-latest
@@ -72,7 +73,19 @@ jobs:
7273
if: env.skip_backend_tests == 'false'
7374
run: |
7475
cd src/ContentProcessor
75-
python -m pytest -vv --cov=. --cov-report=xml --cov-report=term-missing --cov-fail-under=80
76+
python -m pytest -vv --cov=. --cov-report=xml --cov-report=term-missing --cov-fail-under=80 --junitxml=pytest.xml
77+
78+
- name: Pytest Coverage Comment
79+
if: |
80+
always() &&
81+
github.event_name == 'pull_request' &&
82+
github.event.pull_request.head.repo.fork == false &&
83+
env.skip_backend_tests == 'false'
84+
uses: MishaKav/pytest-coverage-comment@26f986d2599c288bb62f623d29c2da98609e9cd4 # v1.6.0
85+
with:
86+
pytest-xml-coverage-path: src/ContentProcessor/coverage.xml
87+
junitxml-path: src/ContentProcessor/pytest.xml
88+
report-only-changed-files: true
7689

7790
- name: Skip Backend Tests
7891
if: env.skip_backend_tests == 'true'

0 commit comments

Comments
 (0)