test: add pytest-cov coverage reporting to CI (#55)#239
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds Python test coverage reporting to the backend CI workflow, including artifact upload and PR comment integration.
Changes:
- Installs
pytest-covand runs pytest with coverage thresholds (fail under 60%). - Uploads coverage XML and HTML reports as workflow artifacts.
- Posts a coverage summary comment on pull requests via
py-cov-action/python-coverage-comment-action@v3.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+58
to
+59
| - name: Install pytest-cov | ||
| run: pip install pytest-cov |
Comment on lines
+70
to
+75
| pytest backend/tests -v \ | ||
| --cov=backend/app \ | ||
| --cov-report=term-missing \ | ||
| --cov-report=xml:coverage.xml \ | ||
| --cov-report=html:htmlcov \ | ||
| --cov-fail-under=60 |
Comment on lines
+87
to
+94
| - name: Coverage summary comment (PR only) | ||
| if: github.event_name == 'pull_request' | ||
| uses: py-cov-action/python-coverage-comment-action@v3 | ||
| with: | ||
| GITHUB_TOKEN: ${{ github.token }} | ||
| MINIMUM_GREEN: 60 | ||
| MINIMUM_ORANGE: 40 | ||
| continue-on-error: true |
Comment on lines
+87
to
+89
| - name: Coverage summary comment (PR only) | ||
| if: github.event_name == 'pull_request' | ||
| uses: py-cov-action/python-coverage-comment-action@v3 |
Comment on lines
+69
to
+79
| run: | | ||
| pytest backend/tests -v \ | ||
| --cov=backend/app \ | ||
| --cov-report=term-missing \ | ||
| --cov-report=xml:coverage.xml \ | ||
| --cov-report=html:htmlcov \ | ||
| --cov-fail-under=60 | ||
|
|
||
| - name: Upload coverage XML report | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 |
Comment on lines
+81
to
+84
| name: coverage-report | ||
| path: | | ||
| coverage.xml | ||
| htmlcov/ |
8a69c01 to
2749f4f
Compare
Contributor
Author
|
Hi @param20h, I've rebased this PR on the latest dev branch, and adjusted the test coverage threshold to 40% to align with the current repository baseline (~42.25%). All checks are now fully passing. Could you please review and merge? Thanks! |
param20h
approved these changes
Jun 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📋 PR Checklist
🔗 Related Issue
Closes #55
📝 What does this PR do?
Configures pytest-cov in the CI pipeline and adds a coverage reporting step to
.github/workflows/ci.yml.Adjusts the coverage failure threshold parameter
--cov-fail-underto 40 to match the repository's current coverage baseline (42.25%), preventing build failures while ensuring future changes don't decrease coverage significantly.🗂️ Type of Change
🧪 How was this tested?
uvicorn app.main:app --reload)📸 Screenshots (if UI change)
The initial PR setup tried to enforce 60% backend test coverage, which was failing the build because the repo's baseline is ~42.25%. We updated the failure threshold to 40% to align with the current project codebase.
✅ Self-Review Checklist
dev, notmainmainbranch or any HuggingFace deployment config