Skip to content

Commit 783f93d

Browse files
feat: Add pytest coverage comment to PRs (dev-v4)
- Add permissions block for pull-requests: write - Add --junitxml=pytest.xml for test summary reporting - Add MishaKav/pytest-coverage-comment step (pinned by SHA) - Remove demo-v4 from target branches Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0d2132a commit 783f93d

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

.github/workflows/test.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches:
66
- main
7-
- demo-v4
87
- dev-v4
98
paths:
109
- 'src/backend/**/*.py'
@@ -23,7 +22,6 @@ on:
2322
- synchronize
2423
branches:
2524
- main
26-
- demo-v4
2725
- dev-v4
2826
paths:
2927
- 'src/backend/**/*.py'
@@ -35,6 +33,11 @@ on:
3533
- 'src/**/pyproject.toml'
3634
- '.github/workflows/test.yml'
3735

36+
permissions:
37+
contents: read
38+
actions: read
39+
pull-requests: write
40+
3841
jobs:
3942
test:
4043
runs-on: ubuntu-latest
@@ -71,9 +74,9 @@ jobs:
7174
run: |
7275
# Run test_app.py first (isolation required)
7376
python -m pytest src/tests/backend/test_app.py --cov=src/backend --cov-config=.coveragerc -q
74-
77+
7578
# Run remaining backend tests with coverage append
76-
python -m pytest src/tests/backend --cov=src/backend --cov-append --cov-report=term --cov-report=xml --cov-config=.coveragerc --ignore=src/tests/backend/test_app.py
79+
python -m pytest src/tests/backend --cov=src/backend --cov-append --cov-report=term --cov-report=xml --junitxml=pytest.xml --cov-config=.coveragerc --ignore=src/tests/backend/test_app.py
7780
7881
- name: Check coverage threshold
7982
if: env.skip_tests == 'false'
@@ -91,7 +94,19 @@ jobs:
9194
exit 1
9295
fi
9396
97+
- name: Pytest Coverage Comment
98+
if: |
99+
always() &&
100+
github.event_name == 'pull_request' &&
101+
github.event.pull_request.head.repo.fork == false &&
102+
env.skip_tests == 'false'
103+
uses: MishaKav/pytest-coverage-comment@26f986d2599c288bb62f623d29c2da98609e9cd4 # v1.6.0
104+
with:
105+
pytest-xml-coverage-path: coverage.xml
106+
junitxml-path: pytest.xml
107+
report-only-changed-files: true
108+
94109
- name: Skip coverage report if no tests
95110
if: env.skip_tests == 'true'
96111
run: |
97-
echo "Skipping coverage report because no tests were found."
112+
echo "Skipping coverage report because no tests were found."

0 commit comments

Comments
 (0)