Skip to content

Commit 76e63ed

Browse files
Merge pull request #816 from microsoft/psl-add-coverage-pr-comment
feat: Add pytest coverage comment to PRs
2 parents fd99dcb + a8a8125 commit 76e63ed

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
@@ -28,6 +28,7 @@ on:
2828
permissions:
2929
contents: read
3030
actions: read
31+
pull-requests: write
3132

3233
concurrency:
3334
group: test-${{ github.ref }}
@@ -69,7 +70,19 @@ jobs:
6970
- name: Run Backend Tests with Coverage
7071
if: env.skip_backend_tests == 'false'
7172
run: |
72-
pytest --cov=. --cov-report=term-missing --cov-report=xml ./src/tests
73+
pytest --cov=. --cov-report=term-missing --cov-report=xml --junitxml=pytest.xml ./src/tests
74+
75+
- name: Pytest Coverage Comment
76+
if: |
77+
always() &&
78+
github.event_name == 'pull_request' &&
79+
github.event.pull_request.head.repo.fork == false &&
80+
env.skip_backend_tests == 'false'
81+
uses: MishaKav/pytest-coverage-comment@26f986d2599c288bb62f623d29c2da98609e9cd4 # v1.6.0
82+
with:
83+
pytest-xml-coverage-path: coverage.xml
84+
junitxml-path: pytest.xml
85+
report-only-changed-files: true
7386

7487
- name: Skip Backend Tests
7588
if: env.skip_backend_tests == 'true'

0 commit comments

Comments
 (0)