ci: add coverage measurement and gate to backend-test - #149
Conversation
Adds pytest-cov to backend/requirements.txt and runs the suite with --cov=. --cov-report=xml --cov-report=term-missing, uploading the coverage.xml as a build artifact. Sets --cov-fail-under=60 as a floor (measured baseline is ~66%), catching future regressions in untested modules while leaving headroom. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wp66uSq9saSpRq9Bbmjxj4
| - uses: actions/upload-artifact@v4 | ||
| if: always() | ||
| with: | ||
| name: backend-coverage | ||
| path: backend/coverage.xml |
There was a problem hiding this comment.
Artifact name not unique across concurrent runs
name: backend-coverage is a fixed string. If two PRs or branches trigger backend-test simultaneously (e.g. a push to main and an open PR), both jobs will try to upload an artifact with the same name into the same Actions scope. actions/upload-artifact@v4 will reject the second upload with a conflict error. Consider parameterising with the run id, e.g. name: backend-coverage-${{ github.run_id }}.
- Scope coverage to production code: add backend/.coveragerc omitting tests/ so test modules (always ~100% covered) no longer inflate the total. Adjust the gate 60 -> 50 to match real production coverage (51.27% measured; with tests included it was 65.81%). - Dismissed the artifact-name finding: Actions artifacts are scoped per workflow run, and this job uploads backend-coverage once per run, so concurrent runs cannot conflict. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wp66uSq9saSpRq9Bbmjxj4
Greptile review findings addressed (commit cd58511)Fixed — coverage source includes test files (ci.yml:48): Valid. Measured it: with Dismissed — artifact name not unique across concurrent runs (ci.yml:53): False positive. GitHub Actions artifacts are scoped per workflow run; the Verification (local, Python 3.12, fresh venv from backend/requirements.txt):
|
|
Merged into integration branch |
Summary
backend-testhad no coverage visibility at all —pytest tests/ -v --tb=shortran with no--cov, andpytest-covwasn't even a dependency.Changes
backend/requirements.txt: addpytest-cov>=6.0.0..github/workflows/ci.yml(backend-test): runpytest tests/ -v --tb=short --cov=. --cov-report=xml --cov-report=term-missing --cov-fail-under=60, then uploadbackend/coverage.xmlviaactions/upload-artifact@v4(if: always()so failed runs still publish the report).Test plan
Existing
requirements.txt): 296 passed, 8 skipped, unchanged from currentmain.New
pytest tests/ -v --tb=short --cov=. --cov-report=xml --cov-report=term-missing --cov-fail-under=60→ passes withRequired test coverage of 60% reached. Total coverage: 65.81%.Closes #116
🤖 Generated with Claude Code
Greptile Summary
This PR adds pytest-cov coverage measurement and a fail-under gate to the
backend-testCI job, with test files excluded from the metric via a new.coveragercso the floor reflects untested production code only..github/workflows/ci.yml: Expands thepytestinvocation with--cov=., XML + terminal reports, and a--cov-fail-under=50gate; uploadsbackend/coverage.xmlas an artifact on every run (including failures) viaactions/upload-artifact@v4.backend/.coveragerc: New config that omitstests/*, keeping the coverage percentage focused on application code (~51% baseline vs ~66% when tests were included).backend/requirements.txt: Addspytest-cov>=6.0.0as a test dependency.Confidence Score: 5/5
This is a safe, additive CI change with no modifications to application logic.
The change only adds coverage instrumentation to the test job. The .coveragerc omit pattern is appropriate for the flat tests/ structure, the artifact upload path is correct relative to the workspace root, and the 50% floor gives a few points of headroom above the measured ~51% production-only baseline so the gate won't flake on minor drift.
No files require special attention.
Important Files Changed
Reviews (2): Last reviewed commit: "fix(review): address Greptile findings o..." | Re-trigger Greptile