Add Python test coverage#250
Conversation
greenc-FNAL
commented
Jan 13, 2026
- maintenance: Align coverage.sh with CI workflow
- Add Python test execution and coverage monitoring
- Improve Python coverage target with proper environment variables
- Update documentation for Python coverage support
- Address code review feedback
- Improve Python executable detection in coverage.sh
- Standardize Python package discovery across project
|
@phlexbot format |
|
Automatic cmake-format fixes pushed (commit 99a85da). |
|
No automatic clang-format fixes were necessary. |
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (75.63%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage. @@ Coverage Diff @@
## main #250 +/- ##
==========================================
+ Coverage 75.43% 75.63% +0.20%
==========================================
Files 124 124
Lines 2902 2902
Branches 507 507
==========================================
+ Hits 2189 2195 +6
+ Misses 492 486 -6
Partials 221 221
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:
|
There was a problem hiding this comment.
Pull request overview
This pull request adds Python test coverage monitoring to the Phlex project, integrating pytest-cov for Python code coverage alongside existing C++ coverage infrastructure. The changes standardize Python package discovery across the project, switching from Python3 to Python for CMake find_package calls, and update the default coverage preset from GCC to Clang to better align with the CI workflow.
Changes:
- Added Python coverage support via pytest-cov with automatic report generation in XML and HTML formats
- Standardized Python package discovery using
find_package(Python 3.12)across CMakeLists.txt and CreateCoverageTargets.cmake - Changed default coverage preset from
coverage-gcctocoverage-clangto mirror CI workflow - Added new
pythoncommand to coverage.sh for standalone Python coverage generation - Integrated Python coverage into GitHub Actions CI workflow with non-fatal reporting
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/python/CMakeLists.txt | Added pytest-cov module check and conditional PYTEST_COMMAND configuration with coverage flags when ENABLE_COVERAGE is ON |
| scripts/coverage.sh | Added generate_python_coverage function, changed default preset to coverage-clang, updated usage documentation, improved preset handling and command-line parsing |
| scripts/README.md | Documented new python command, updated command descriptions to indicate C++ and Python coverage support, added Python coverage requirements section |
| Modules/private/CreateCoverageTargets.cmake | Standardized to find_package(Python 3.12), updated all Python_EXECUTABLE references, added coverage-python target, updated coverage-clean to remove Python artifacts |
| .github/workflows/coverage.yaml | Added Python coverage report generation step with graceful handling when pytest-cov unavailable, integrated Python coverage artifacts into upload process |
We use the module, so check for the module—availability of the command is irrelevant. Per Framework-R-D#250 (comment) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Refactors the `coverage.sh` script to align its behavior, particularly for the Clang toolchain, with the CI coverage workflow. Key changes: - Sets the `LLVM_PROFILE_FILE` environment variable during the test phase for Clang to ensure correct collection of raw profile data, mirroring the CI setup. - Changes the default preset from `coverage-gcc` to `coverage-clang` to match the CI standard. - Adds HTML report generation for the Clang toolchain, bringing it to feature parity with the GCC preset within the script. - Simplifies the logic for the Clang path by removing irrelevant and incorrect GCC-specific staleness checks. - Improves the argument parsing to be more robust and reliable. Refactors the coverage.sh script to align its behavior with the CI workflow. - Implements support for uploading LLVM/Clang coverage reports to Codecov. - Improves the help text to clarify the differences between the GCC and Clang workflows. - Adds validation for the --preset flag. - Changes the exit code to 1 when no commands are provided. - Improves comments and file URL generation.
- Add pytest-cov integration to test/python/CMakeLists.txt - Update CreateCoverageTargets.cmake to add coverage-python target - Add python command to coverage.sh script - Update .github/workflows/coverage.yaml to collect Python coverage - Include Python coverage files in artifact bundles and Codecov uploads Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
- Add PHLEX_INSTALL environment variable to coverage-python target - Update documentation in CreateCoverageTargets.cmake header - Ensure Python coverage target has necessary environment setup Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
- Add python command to coverage.sh commands table - Document Python coverage requirements (pytest, pytest-cov) - Add example for Python-only coverage generation - Update command descriptions to note C++ and Python support Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
- Remove unused HAS_PYTEST variable from test/python/CMakeLists.txt - Remove unused PYTEST_EXECUTABLE find_program call - Use Python3_EXECUTABLE -m pytest consistently throughout Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
- Add fallback detection for both python3 and python commands - Use detected Python command for pytest-cov check - Make script more robust across different Python installations Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
- Change from find_package(Python3) to find_package(Python 3.12) - Replace all Python3_FOUND and Python3_EXECUTABLE references with Python_* - Ensure consistent Python interpreter detection across all CMake files - Aligns CreateCoverageTargets.cmake with test/python/CMakeLists.txt Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
We use the module, so check for the module—availability of the command is irrelevant. Per Framework-R-D#250 (comment) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
9d68111 to
ca41803
Compare
|
@phlexbot format |
|
Automatic cmake-format fixes pushed (commit 333ba47). |
|
No automatic clang-format fixes were necessary. |
We use the module, so check for the module—availability of the command is irrelevant. Per #250 (comment) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>