Skip to content

Enable coverage monitoring for non-test Python modules#304

Merged
knoepfel merged 6 commits intomainfrom
copilot/check-coverage-monitoring
Feb 10, 2026
Merged

Enable coverage monitoring for non-test Python modules#304
knoepfel merged 6 commits intomainfrom
copilot/check-coverage-monitoring

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 10, 2026

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 like phlexpy.py, adder.py, reducer.py, etc.

Changes

  • Add py-pytest-cov to CI container: Updated ci/spack.yaml to include pytest-cov dependency
  • Configure coverage scope: Created test/python/.coveragerc to measure non-test Python modules while excluding test files:
    [run]
    source = .
    omit = test_*.py, **/test_*.py
    
    [report]
    omit = test_*.py, **/test_*.py
  • Wire up configuration: Updated CMake files to pass --cov-config=.coveragerc to pytest
  • Ignore coverage artifacts: Added .coverage and .pytest_cache to .gitignore

Deployment Note

CI container rebuild required for py-pytest-cov to take effect. Once deployed, coverage workflow will automatically generate and upload Python coverage reports to Codecov.

Original prompt

Please examine recent coverage/codecov workflow logs, and the CMake code in the repository to ascertain whether the test coverage of non-test Python code (such as plugins/python/src/__init__.py) is being monitored as intended, and investigate/resolve if not.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits February 10, 2026 14:33
- 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>
Copilot AI changed the title [WIP] Examine test coverage for non-test Python code Enable coverage monitoring for non-test Python modules Feb 10, 2026
Copilot AI requested a review from greenc-FNAL February 10, 2026 14:37
@greenc-FNAL greenc-FNAL marked this pull request as ready for review February 10, 2026 14:39
Copilot AI review requested due to automatic review settings February 10, 2026 14:39
@greenc-FNAL
Copy link
Copy Markdown
Contributor

@phlexbot format

@greenc-FNAL
Copy link
Copy Markdown
Contributor

@phlexbot python-fix

@github-actions
Copy link
Copy Markdown
Contributor

No automatic markdownlint fixes were necessary.

@github-actions
Copy link
Copy Markdown
Contributor

No automatic cmake-format fixes were necessary.

@github-actions
Copy link
Copy Markdown
Contributor

No automatic clang-format fixes were necessary.

@github-actions
Copy link
Copy Markdown
Contributor

No automatic jsonnetfmt fixes were necessary.

@github-actions
Copy link
Copy Markdown
Contributor

Automatic ruff fixes pushed (commit 3ca22bb).
⚠️ Note: Some issues may require manual review and fixing.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-cov to the CI Spack environment so Python coverage isn’t skipped.
  • Introduce test/python/.coveragerc and pass it to pytest via --cov-config to 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.

@greenc-FNAL
Copy link
Copy Markdown
Contributor

Review the full CodeQL report for details.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 10, 2026

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              
Flag Coverage Δ
unittests 74.60% <ø> (+0.32%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 022f754...dd8915b. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@greenc-FNAL greenc-FNAL requested a review from knoepfel February 10, 2026 15:21
@knoepfel knoepfel merged commit 338b735 into main Feb 10, 2026
48 of 49 checks passed
greenc-FNAL added a commit that referenced this pull request Feb 10, 2026
* 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>
@knoepfel knoepfel deleted the copilot/check-coverage-monitoring branch February 10, 2026 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants