From 7c864e4fb338218ed7b9e2ede43ebb7aa9712170 Mon Sep 17 00:00:00 2001 From: Rafi Date: Thu, 16 Apr 2026 18:41:29 +0530 Subject: [PATCH] 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> --- .github/workflows/test.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f9699f197..a45f09f72 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,6 +31,7 @@ on: permissions: contents: read actions: read + pull-requests: write jobs: # frontend_tests: @@ -106,7 +107,19 @@ jobs: - name: Run Backend Tests with Coverage if: env.skip_backend_tests == 'false' run: | - pytest --cov=. --cov-report=term-missing --cov-report=xml ./src/tests/api + pytest --cov=. --cov-report=term-missing --cov-report=xml --junitxml=pytest.xml ./src/tests/api + + - name: Pytest Coverage Comment + if: | + always() && + github.event_name == 'pull_request' && + github.event.pull_request.head.repo.fork == false && + env.skip_backend_tests == 'false' + uses: MishaKav/pytest-coverage-comment@26f986d2599c288bb62f623d29c2da98609e9cd4 # v1.6.0 + with: + pytest-xml-coverage-path: coverage.xml + junitxml-path: pytest.xml + report-only-changed-files: true - name: Skip Backend Tests if: env.skip_backend_tests == 'true'