ci(test): enforce coverage-based test selection on PRs#1468
ci(test): enforce coverage-based test selection on PRs#1468sbryngelson wants to merge 2 commits into
Conversation
Flip the shadow --only-changes selection to --select-enforce on PR runs for the github (GNU/intel) jobs and the self-hosted Phoenix/Frontier jobs. PRs now run only the tests whose recorded coverage overlaps the changed files; the conservative ladder in coverage.py falls back to run-all for non-.fpp changes and .fpp files no test covers. Backstops retained: the NVHPC jobs still run --test-all on every PR (pre-merge full check), and pushes to master run the full suite (SELECT empty).
…y-changes) --select-enforce previously did nothing without --only-changes, so the enforce config had to pass both. Gate the selection block on either flag: --select-enforce alone now selects AND prunes; --only-changes alone stays shadow (print selection, run full suite). CI enforce paths simplify to just --select-enforce --changed-files.
|
Added a second commit simplifying the flags:
CI enforce paths now pass just |
There was a problem hiding this comment.
Pull request overview
This PR switches coverage-based test selection on PR runs from “shadow” (log-only) to “enforced” (actually skipping unselected tests), while keeping conservative fallbacks (run-all) when selection would be unsafe.
Changes:
- Treat
--select-enforceas sufficient to trigger coverage selection (no need to also pass--only-changes). - Update CLI help text around coverage-selection flags.
- Update GitHub-hosted and self-hosted CI runners to pass
--select-enforceon PRs.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
toolchain/mfc/test/test.py |
Runs coverage selection when either --only-changes (shadow) or --select-enforce (enforced) is set. |
toolchain/mfc/cli/commands.py |
Updates CLI help strings describing shadow vs enforced selection behavior. |
.github/workflows/test.yml |
Enforces selection on PRs by passing --select-enforce (and still runs full suite on master pushes). |
.github/workflows/common/test.sh |
Enforces selection on self-hosted PR runs via --select-enforce. |
Comments suppressed due to low confidence (1)
toolchain/mfc/cli/commands.py:486
- The
changes-branchhelp text still says it’s only used for--only-changes, but the selection path now also runs when--select-enforceis set (even without--only-changes). Update the help to reflect both flags so users understand it applies to enforced selection too.
Argument(name="changed-files", dest="changed_files", type=str, default=None, help="Changed-file list (newline-, space-, or comma-separated; from CI paths-filter). Overrides git detection."),
Argument(name="changes-branch", dest="changes_branch", type=str, default="master", help="Branch to diff against for --only-changes."),
],
| SELECT=() | ||
| [ "${{ github.event_name }}" = "pull_request" ] && SELECT=(--only-changes --changed-files "$CHANGED_FILES") | ||
| [ "${{ github.event_name }}" = "pull_request" ] && SELECT=(--select-enforce --changed-files "$CHANGED_FILES") | ||
| /bin/bash mfc.sh test -v --max-attempts 3 -j $(nproc) "${SELECT[@]}" $TEST_ALL $TEST_PCT $PRECISION |
| select_opts="" | ||
| if [ "${GITHUB_EVENT_NAME:-}" = "pull_request" ]; then | ||
| select_opts="--only-changes" | ||
| select_opts="--select-enforce" | ||
| fi |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1468 +/- ##
=======================================
Coverage 61.31% 61.31%
=======================================
Files 72 72
Lines 19771 19771
Branches 2852 2852
=======================================
Hits 12123 12123
Misses 5699 5699
Partials 1949 1949 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
What
Flips the coverage-based test selection from shadow to enforced on PR runs:
test.ymlgithub (GNU/intel) Test step →--only-changes --select-enforcecommon/test.shself-hosted Phoenix/Frontier →--only-changes --select-enforcePRs now run only the tests whose recorded coverage overlaps the changed files. The conservative ladder in
coverage.pyfalls back to run-all for anything risky: unavailable file lists (rung 1), macro/codegen/build inputs (rung 2), hand-written.f90(rung 3), and — critically — a changed.fppthat no test covers (rung 4). The only "run nothing" path is docs/irrelevant-only changes (rung 7).Safety / backstops (why this is safe to enforce)
--test-allon every PR, so the full suite runs on at least one config before merge — a selector under-inclusion is caught pre-merge, not just post-merge.SELECTempty), never cancelled per the concurrency config.Coverage selection: ran N/M …), so pruning can be eyeballed.Note
This PR itself touches
test.yml/test.sh(non-.fpp) → rung 2 → it runs the full suite, so pruning isn't demonstrated here. A follow-up Fortran-only PR will show the enforced prune. Pruning the NVHPC jobs too (for more savings) is a later step once this proves out.