test: add pytest-cov coverage reporting to CI (#55)#239
Conversation
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.
| - name: Install pytest-cov | ||
| run: pip install pytest-cov |
| 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: 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 |
| - name: Coverage summary comment (PR only) | ||
| if: github.event_name == 'pull_request' | ||
| uses: py-cov-action/python-coverage-comment-action@v3 |
| 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 |
| name: coverage-report | ||
| path: | | ||
| coverage.xml | ||
| htmlcov/ |
8a69c01 to
2749f4f
Compare
|
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! |
|
Hi @param20h, thank you for merging this PR! I noticed it has the 'gssoc:approved' label but is missing a difficulty level label (like 'level:beginner' or 'level:intermediate'). Could you please add the appropriate difficulty label so the points are correctly parsed by the GSSoC leaderboard? Thanks! |
📋 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