Skip to content

Commit 36d60fe

Browse files
Merge branch 'master' into local-aware-ibm
2 parents 0c56440 + 40dde5e commit 36d60fe

7 files changed

Lines changed: 41 additions & 12 deletions

File tree

.github/scripts/check_coverage_map_health.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,23 @@
1313
entries, meta = load_map(COVERAGE_MAP_PATH)
1414
if entries is None:
1515
sys.exit("Coverage map missing or corrupt.")
16-
current_keys = {b.to_case().coverage_key() for b in list_cases()}
16+
# Compute each current test's coverage key. Loading a case executes its case
17+
# file; some (e.g. chemistry examples) import optional deps like cantera that are
18+
# not installed in this lightweight job. Skip any case that fails to load instead
19+
# of crashing — map_health measures the fraction of *loadable* current tests that
20+
# are mapped, so a smaller current_keys cannot produce a false "stale" result.
21+
current_keys = set()
22+
unloadable = []
23+
for b in list_cases():
24+
try:
25+
current_keys.add(b.to_case().coverage_key())
26+
except Exception as exc: # noqa: BLE001 — a case file that won't import must not crash the health check
27+
last_line = (str(exc).strip().splitlines() or ["(no message)"])[-1][:140]
28+
unloadable.append((getattr(b, "trace", repr(b)), last_line))
29+
if unloadable:
30+
print(f"Note: {len(unloadable)} case(s) could not be loaded in this lightweight job (excluded from the check):")
31+
for trace, err in unloadable[:15]:
32+
print(f" - {trace}: {err}")
1733
ok, msg = map_health(
1834
meta=meta,
1935
current_keys=current_keys,

.github/workflows/common/test.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ if [ -n "${job_shard:-}" ]; then
5757
shard_opts="--shard $job_shard"
5858
fi
5959

60-
# Coverage-based test selection in SHADOW mode on PRs: prints what it WOULD select but the
61-
# full suite still runs (no --select-enforce). Changed files come from git detection
62-
# (self-healing deepen) since the SLURM job doesn't receive the paths-filter list.
60+
# Coverage-based test selection ENFORCED on PRs: runs only tests whose recorded coverage
61+
# overlaps the PR's changed files (conservative ladder; non-.fpp and uncovered-.fpp changes
62+
# fall back to run-all). Pushes to master run the full suite as a backstop. Changed files
63+
# come from git detection (self-healing deepen) since the SLURM job doesn't receive the
64+
# paths-filter list.
6365
select_opts=""
6466
if [ "${GITHUB_EVENT_NAME:-}" = "pull_request" ]; then
65-
select_opts="--only-changes"
67+
select_opts="--select-enforce"
6668
fi
6769

6870
./mfc.sh test -v --max-attempts 3 --no-build $select_opts -a -j $n_test_threads $rdma_opts $device_opts $build_opts $shard_opts -- -c $job_cluster

.github/workflows/test.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,13 @@ jobs:
264264
- name: Test
265265
if: '!matrix.nvhpc'
266266
run: |
267-
# Coverage-based test selection in SHADOW mode on PRs: the selector
268-
# prints what it WOULD run, but the full suite still runs (no
269-
# --select-enforce). Enforcement is a separate, later change.
267+
# Coverage-based test selection ENFORCED on PRs: runs only the tests whose
268+
# recorded coverage overlaps the PR's changed files (conservative ladder in
269+
# coverage.py — non-.fpp changes and .fpp files no test covers fall back to
270+
# run-all). Pushes to master run the full suite (SELECT empty) as a backstop,
271+
# and the NVHPC jobs below still run --test-all as a pre-merge full check.
270272
SELECT=()
271-
[ "${{ github.event_name }}" = "pull_request" ] && SELECT=(--only-changes --changed-files "$CHANGED_FILES")
273+
[ "${{ github.event_name }}" = "pull_request" ] && SELECT=(--select-enforce --changed-files "$CHANGED_FILES")
272274
/bin/bash mfc.sh test -v --max-attempts 3 -j $(nproc) "${SELECT[@]}" $TEST_ALL $TEST_PCT $PRECISION
273275
env:
274276
TEST_ALL: ${{ matrix.mpi == 'mpi' && '--test-all' || '' }}

tests/coverage_map.json.gz

31 Bytes
Binary file not shown.

toolchain/mfc/case_validator.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,15 @@ def check_chemistry(self):
13281328
# Fetch global chemistry and diffusion flags
13291329
chemistry = self.get("chemistry", "F") == "T"
13301330
diffusion = self.get("chem_params%diffusion", "F") == "T"
1331+
num_fluids = self.get("num_fluids")
1332+
1333+
# Chemistry assumes a single reacting gas phase: the temperature/pressure
1334+
# inversion recovers T from the total internal energy via Cantera's ideal-gas
1335+
# EOS (ignoring pi_inf), and the cons->prim conversion collapses all partial
1336+
# densities onto the species-summed total density. Both are only correct for
1337+
# num_fluids = 1; with a second (e.g. stiffened-gas) fluid the state is
1338+
# inconsistent and the simulation NaNs. See MFlowCode/MFC#1470.
1339+
self.prohibit(chemistry and num_fluids is not None and num_fluids != 1, "chemistry is only supported for single-component flows (num_fluids = 1)")
13311340

13321341
# Define what constitutes a wall (-15 for slip, -16 for no-slip)
13331342
wall_bcs = [-15, -16]

toolchain/mfc/cli/commands.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,14 +472,14 @@
472472
dest="only_changes",
473473
action=ArgAction.STORE_TRUE,
474474
default=False,
475-
help="Select only tests whose covered files overlap changed files (shadow mode unless --select-enforce).",
475+
help="Shadow mode: compute and print the coverage-based test selection but still run the full suite. Use --select-enforce to actually prune.",
476476
),
477477
Argument(
478478
name="select-enforce",
479479
dest="select_enforce",
480480
action=ArgAction.STORE_TRUE,
481481
default=False,
482-
help="With --only-changes, actually skip unselected tests (otherwise shadow: print selection, run all).",
482+
help="Run only the coverage-selected tests (implies selection; skips unselected tests). Without it, --only-changes is shadow-only.",
483483
),
484484
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."),
485485
Argument(name="changes-branch", dest="changes_branch", type=str, default="master", help="Branch to diff against for --only-changes."),

toolchain/mfc/test/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def is_uuid(term):
178178
if not cases:
179179
raise MFCException(f"--shard {ARG('shard')} matched zero test cases. Total cases before sharding may be less than shard count.")
180180

181-
if ARG("only_changes"):
181+
if ARG("only_changes") or ARG("select_enforce"):
182182
import datetime
183183

184184
from .. import common

0 commit comments

Comments
 (0)