Skip to content

ci(test): enforce coverage-based test selection on PRs#1468

Open
sbryngelson wants to merge 2 commits into
MFlowCode:masterfrom
sbryngelson:enforce-test-selection
Open

ci(test): enforce coverage-based test selection on PRs#1468
sbryngelson wants to merge 2 commits into
MFlowCode:masterfrom
sbryngelson:enforce-test-selection

Conversation

@sbryngelson
Copy link
Copy Markdown
Member

What

Flips the coverage-based test selection from shadow to enforced on PR runs:

  • test.yml github (GNU/intel) Test step → --only-changes --select-enforce
  • common/test.sh self-hosted Phoenix/Frontier → --only-changes --select-enforce

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 anything risky: unavailable file lists (rung 1), macro/codegen/build inputs (rung 2), hand-written .f90 (rung 3), and — critically — a changed .fpp that 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)

  • Pre-merge full check: the NVHPC jobs still run --test-all on 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.
  • Master backstop: pushes to master run the full suite (SELECT empty), never cancelled per the concurrency config.
  • Selection is visible in each PR's test log (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.

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.
@sbryngelson
Copy link
Copy Markdown
Member Author

Added a second commit simplifying the flags: --select-enforce now implies selection, so it no longer needs to be paired with --only-changes (which was redundant — --select-enforce did nothing on its own).

  • --select-enforce (alone) → select and prune
  • --only-changes (alone) → shadow (print selection, run full suite)

CI enforce paths now pass just --select-enforce --changed-files …. Verified locally: --select-enforce alone prunes (81/578 for a bubbles change, no shadow message); --only-changes alone still shows the shadow message. 273 unit tests pass.

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

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-enforce as 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-enforce on 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-branch help text still says it’s only used for --only-changes, but the selection path now also runs when --select-enforce is 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."),
    ],

Comment on lines 272 to 274
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
Comment on lines 65 to 68
select_opts=""
if [ "${GITHUB_EVENT_NAME:-}" = "pull_request" ]; then
select_opts="--only-changes"
select_opts="--select-enforce"
fi
@codecov
Copy link
Copy Markdown

codecov Bot commented May 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.31%. Comparing base (574e53d) to head (3eaba1c).
⚠️ Report is 9 commits behind head on master.

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.
📢 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.

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