Skip to content

Commit d5ad80d

Browse files
Merge pull request #877 from microsoft/psl-add-coverage-pr-comment
feat: Add pytest coverage comment to PRs
2 parents fcc0e72 + 7c864e4 commit d5ad80d

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
@@ -31,6 +31,7 @@ on:
3131
permissions:
3232
contents: read
3333
actions: read
34+
pull-requests: write
3435

3536
jobs:
3637
# frontend_tests:
@@ -106,7 +107,19 @@ jobs:
106107
- name: Run Backend Tests with Coverage
107108
if: env.skip_backend_tests == 'false'
108109
run: |
109-
pytest --cov=. --cov-report=term-missing --cov-report=xml ./src/tests/api
110+
pytest --cov=. --cov-report=term-missing --cov-report=xml --junitxml=pytest.xml ./src/tests/api
111+
112+
- name: Pytest Coverage Comment
113+
if: |
114+
always() &&
115+
github.event_name == 'pull_request' &&
116+
github.event.pull_request.head.repo.fork == false &&
117+
env.skip_backend_tests == 'false'
118+
uses: MishaKav/pytest-coverage-comment@26f986d2599c288bb62f623d29c2da98609e9cd4 # v1.6.0
119+
with:
120+
pytest-xml-coverage-path: coverage.xml
121+
junitxml-path: pytest.xml
122+
report-only-changed-files: true
110123

111124
- name: Skip Backend Tests
112125
if: env.skip_backend_tests == 'true'

0 commit comments

Comments
 (0)