Enable coverage monitoring for non-test Python modules#304
Conversation
- Add .coveragerc to configure pytest-cov to measure non-test Python modules - Add py-pytest-cov to CI spack.yaml for coverage reports - Update CMake files to use .coveragerc configuration - Ensure non-test Python code (phlexpy.py, etc.) is monitored Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
- Remove .coverage file from repository - Add .coverage and .pytest_cache to .gitignore Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
|
@phlexbot format |
|
@phlexbot python-fix |
|
No automatic markdownlint fixes were necessary. |
|
No automatic cmake-format fixes were necessary. |
|
No automatic clang-format fixes were necessary. |
|
No automatic jsonnetfmt fixes were necessary. |
|
Automatic ruff fixes pushed (commit 3ca22bb). |
There was a problem hiding this comment.
Pull request overview
Enables Python coverage collection for non-test modules in test/python by ensuring pytest-cov is available in CI and by standardizing coverage configuration via a checked-in .coveragerc.
Changes:
- Add
py-pytest-covto the CI Spack environment so Python coverage isn’t skipped. - Introduce
test/python/.coveragercand pass it to pytest via--cov-configto exclude test files from reports. - Ignore common Python coverage artifacts in
test/python/.gitignore.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
ci/spack.yaml |
Adds py-pytest-cov to ensure coverage dependencies exist in the CI container. |
test/python/.coveragerc |
Defines coverage scope/omit rules to focus reporting on non-test modules. |
test/python/CMakeLists.txt |
Wires --cov-config into the CTest/pytest invocation for Python tests. |
Modules/private/CreateCoverageTargets.cmake |
Wires --cov-config into the coverage-python custom target. |
test/python/.gitignore |
Ignores .coverage and .pytest_cache artifacts produced by local test runs. |
|
Review the full CodeQL report for details. |
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (74.60%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage. @@ Coverage Diff @@
## main #304 +/- ##
==========================================
+ Coverage 74.28% 74.60% +0.32%
==========================================
Files 124 124
Lines 2955 2961 +6
Branches 513 516 +3
==========================================
+ Hits 2195 2209 +14
+ Misses 540 532 -8
Partials 220 220
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
* Add .coveragerc and py-pytest-cov to enable Python coverage monitoring * Update CMake files to use .coveragerc configuration * Test and validate Python coverage configuration * Update .gitignore to exclude Python coverage artifacts * Apply ruff fixes * Fix line-too-long complaint from `ruff` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Chris Green <greenc@fnal.gov>
Python coverage reports were skipped in CI due to missing
pytest-cov, and when run locally, only measured test files rather than non-test modules likephlexpy.py,adder.py,reducer.py, etc.Changes
py-pytest-covto CI container: Updatedci/spack.yamlto include pytest-cov dependencytest/python/.coveragercto measure non-test Python modules while excluding test files:--cov-config=.coveragercto pytest.coverageand.pytest_cacheto.gitignoreDeployment Note
CI container rebuild required for
py-pytest-covto take effect. Once deployed, coverage workflow will automatically generate and upload Python coverage reports to Codecov.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.