Skip to content

Add gcov-based test pruning with file-level coverage cache#1316

Merged
sbryngelson merged 10 commits intoMFlowCode:masterfrom
sbryngelson:gcov-test-pruning-v3-rebase
Mar 17, 2026
Merged

Add gcov-based test pruning with file-level coverage cache#1316
sbryngelson merged 10 commits intoMFlowCode:masterfrom
sbryngelson:gcov-test-pruning-v3-rebase

Conversation

@sbryngelson
Copy link
Copy Markdown
Member

@sbryngelson sbryngelson commented Mar 15, 2026

Summary

  • File-level gcov coverage cache maps test UUIDs to exercised .fpp source files (gzip JSON, committed to repo)
  • --only-changes flag prunes tests by intersecting PR-changed files against coverage cache
  • --build-coverage-cache flag + 3-phase parallel cache builder (prepare, run, gcov collect)
  • New rebuild-cache CI job runs on Phoenix via SLURM when cases.py or Fortran dependency graph changes
  • Dep-change detection greps PR/push diffs for added use/include statements
  • Conservative fallbacks: missing cache runs all, missing sim coverage includes test, ALWAYS_RUN_ALL files trigger full suite
  • 54 unit tests cover core coverage logic

Replaces #1284.

Test plan

  • CI lint checks pass
  • rebuild-cache job triggers (dep_changed detection)
  • Test jobs download cache artifact and prune tests via --only-changes

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 15, 2026

Outdated review (resolved)This review was on an earlier revision. All findings have been addressed.

@sbryngelson sbryngelson force-pushed the gcov-test-pruning-v3-rebase branch 9 times, most recently from c4efbc6 to 68b035b Compare March 16, 2026 00:03
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 16, 2026

Outdated review (resolved)This review was on an earlier revision. All findings have been addressed.

@sbryngelson sbryngelson marked this pull request as ready for review March 17, 2026 00:56
Copilot AI review requested due to automatic review settings March 17, 2026 00:56
@github-actions

This comment was marked as resolved.

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

Introduces file-level gcov coverage–based test pruning to speed up PR CI runs by running only tests whose covered .fpp files overlap with the PR’s changed files, with CI support to rebuild and distribute the coverage cache when needed.

Changes:

  • Adds a coverage cache builder and a --only-changes pruning path to the mfc.sh test command.
  • Extends CI to (optionally) rebuild/upload the coverage cache and to run PR tests with --only-changes.
  • Updates build/test infrastructure to improve gcov fidelity (Fypp line markers, gcov-friendly flags) and adds offline unit tests for the coverage logic.

Reviewed changes

Copilot reviewed 12 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
toolchain/mfc/test/coverage.py Implements coverage cache build + changed-file-based pruning logic.
toolchain/mfc/test/test.py Wires --only-changes and --build-coverage-cache into test execution and filtering.
toolchain/mfc/cli/commands.py Adds CLI flags: --build-coverage-cache, --only-changes, --changes-branch.
toolchain/mfc/test/test_coverage_unit.py Adds offline unit tests for the coverage module.
toolchain/mfc/test/test_coverage_cache.json.gz Adds the committed coverage cache artifact.
toolchain/mfc/test/case.py Refactors post_process-related parameter mods for reuse by coverage builder.
toolchain/mfc/test/cases.py Skips 1D_qbmm example due to a gfortran 12 overflow issue.
CMakeLists.txt Adjusts gcov builds (Fypp line markers; disables LTO for gcov; uses -O1 in Release for accuracy/portability).
.github/workflows/test.yml Adds cache rebuild job + artifact download; runs PR tests with --only-changes.
.github/workflows/common/test.sh Enables pruning only on PR events in SLURM-based CI runs.
.github/workflows/common/rebuild-cache.sh Adds SLURM script to rebuild the gcov cache.
.github/scripts/submit-slurm-job.sh Exports GITHUB_EVENT_NAME into SLURM job environment.
.github/file-filter.yml Adds cases_py filter and includes common workflow paths.
.gitignore Ignores legacy raw (non-gz) coverage cache file.
Comments suppressed due to low confidence (1)

toolchain/mfc/test/test.py:90

  • __filter operates on the objects returned by list_cases() (TestCaseBuilder instances), and later test() converts them via .to_case(). The current return type hint uses List[TestCase], which is misleading and makes type-checking harder; consider changing the annotations to List[TestCaseBuilder] (and importing that type) for both inputs and returned lists.
def __filter(cases_) -> typing.Tuple[typing.List[TestCase], typing.List[TestCase]]:
    cases = cases_[:]
    selected_cases = []
    skipped_cases = []

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 17, 2026

Outdated review (resolved)This review was on an earlier revision. All findings have been addressed.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 45.01%. Comparing base (38a7b4b) to head (f5d7344).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1316      +/-   ##
==========================================
- Coverage   45.12%   45.01%   -0.11%     
==========================================
  Files          70       70              
  Lines       20554    20562       +8     
  Branches     1962     1962              
==========================================
- Hits         9274     9255      -19     
- Misses      10152    10179      +27     
  Partials     1128     1128              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@sbryngelson sbryngelson force-pushed the gcov-test-pruning-v3-rebase branch from c6cf6c6 to f5d7344 Compare March 17, 2026 17:51
@sbryngelson sbryngelson merged commit 808a668 into MFlowCode:master Mar 17, 2026
48 of 52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants