Skip to content

Commit 81e723f

Browse files
committed
feat(test): accept space/comma/newline separated --changed-files (CI paths-filter)
1 parent 9de8e5e commit 81e723f

4 files changed

Lines changed: 19 additions & 3 deletions

File tree

.github/workflows/test.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ jobs:
5353
runs-on: 'ubuntu-latest'
5454
outputs:
5555
checkall: ${{ steps.changes.outputs.checkall }}
56+
changed_files: ${{ steps.changes.outputs.checkall_files }}
5657
steps:
5758
- name: Clone
5859
uses: actions/checkout@v4
@@ -62,6 +63,7 @@ jobs:
6263
id: changes
6364
with:
6465
filters: ".github/file-filter.yml"
66+
list-files: shell
6567

6668
github:
6769
name: ${{ matrix.nvhpc && format('NVHPC {0} ({1})', matrix.nvhpc, matrix.target) || format('Github ({0}, {1}, {2}, {3})', matrix.os, matrix.mpi, matrix.debug, matrix.intel && 'intel' || 'GNU') }}
@@ -262,11 +264,17 @@ jobs:
262264
- name: Test
263265
if: '!matrix.nvhpc'
264266
run: |
265-
/bin/bash mfc.sh test -v --max-attempts 3 -j $(nproc) $TEST_ALL $TEST_PCT $PRECISION
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.
270+
SELECT=""
271+
[ "${{ github.event_name }}" = "pull_request" ] && SELECT="--only-changes"
272+
/bin/bash mfc.sh test -v --max-attempts 3 -j $(nproc) $SELECT --changed-files "$CHANGED_FILES" $TEST_ALL $TEST_PCT $PRECISION
266273
env:
267274
TEST_ALL: ${{ matrix.mpi == 'mpi' && '--test-all' || '' }}
268275
TEST_PCT: ${{ matrix.debug == 'reldebug' && '-% 20' || '' }}
269276
PRECISION: ${{ matrix.precision != '' && format('--{0}', matrix.precision) || '' }}
277+
CHANGED_FILES: ${{ needs.file-changes.outputs.changed_files }}
270278

271279
# ── NVHPC build + test (via docker exec into long-lived container) ──
272280
- name: Build (NVHPC)

tests/coverage_map.json.gz

14.1 KB
Binary file not shown.

toolchain/mfc/test/coverage.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,12 @@ def _merge_base(cwd, branch):
133133
def get_changed_files(root_dir, compare_branch="master", explicit: Optional[str] = None):
134134
"""Set of changed repo-relative paths, or None if undeterminable (-> run all).
135135
136-
`explicit` is a newline-separated list from CI (paths-filter); preferred when given.
136+
`explicit` is a changed-file list from CI (paths-filter); preferred when given. It may
137+
be separated by newlines, spaces, or commas (paths-filter's shell output is space-sep).
137138
Otherwise use git merge-base, self-healing a shallow clone with a deepen+retry.
138139
"""
139140
if explicit is not None:
140-
return {f for f in explicit.splitlines() if f.strip()}
141+
return {f for f in explicit.replace(",", " ").split() if f.strip()}
141142
try:
142143
base = _merge_base(root_dir, compare_branch)
143144
if base is None:

toolchain/mfc/test/test_coverage_unit.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,10 @@ def test_rung5_empty_coverage_is_included():
254254
run, skip, _ = select_tests(cases, cov_map, {"src/simulation/m_rhs.fpp"})
255255
run_keys = {c.coverage_key() for c in run}
256256
assert "hasempty" in run_keys and skip == []
257+
258+
259+
def test_changed_files_explicit_space_and_comma_separated():
260+
from mfc.test.coverage import get_changed_files
261+
262+
assert get_changed_files("/r", "master", explicit="src/a.fpp src/b.fpp") == {"src/a.fpp", "src/b.fpp"}
263+
assert get_changed_files("/r", "master", explicit="src/a.fpp,src/b.fpp") == {"src/a.fpp", "src/b.fpp"}

0 commit comments

Comments
 (0)