Repository navigation
ci(cpu-tests): skip CPU matrix on PRs that can't affect the suite - #342
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a fail-open path gate to avoid unnecessary CPU test matrices.
Changes:
- Adds PR-file relevance detection to
cpu-tests.yml. - Documents the deny-list gate and required-check behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
.github/workflows/cpu-tests.yml |
Adds CPU relevance gating. |
docs/ci-testing-plan.md |
Documents the new path gate. |
Suppressed comments (1)
.github/workflows/cpu-tests.yml:78
- This projection drops
previous_filenamefor renamed files. A PR that moves a CPU-relevant file such assrc/aorta/foo.pyinto.github/is then classified solely by the ignored destination and can skip tests even though it removed source code. Include both sides of renames in the paths evaluated by the deny-list.
if ! files="$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/files" \
--paginate --jq '.[].filename' 2>&1)"; then
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Copilot review on #342 surfaced four real issues, all fixed here: - Required-check hang (actions/runner#952): a matrix job skipped by a job-level `if` never emits its per-version pytest (CPU, py3.x) contexts, so pinning branch protection to them hangs skipped PRs forever -- the opposite of this PR's goal. gpu-tests.yml is safe only because its gated job is a single non-matrix job. Add a stable, always-running `required` aggregator job (check name "CPU tests") that collapses the matrix result into one context reporting on every PR; document that branch protection must require it, not the legs. - Pagination fail-open hole: the /files listing caps at 3000 files, so a truncated list of all-ignorable paths could wrongly skip. Read the PR's changed_files and fail open when the returned record count is short. - Renames: evaluate both filename and previous_filename so a source file moved into an ignored path still counts as a relevant change. - Inverted safety claim: the deny-list is only fail-open for *omitted* entries; an overbroad/wrong entry silently skips tests. Reworded the workflow comment and docs to state the asymmetry. Co-authored-by: Cursor <[email protected]>
|
Thanks for the thorough review — all five inline comments plus the suppressed one were valid and are addressed in Summary of changes since the first push:
The GitHub matrix-skip behavior was verified against actions/runner#952. The gate logic was dry-run across CI-only / src / docs-read-by-test / rename / truncation / multi-page cases before pushing.
Made with Cursor |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (3)
.github/workflows/cpu-tests.yml:20
- This new guidance contradicts the header at lines 8–9, which still tells administrators to require the matrix
testsjobs. Following that instruction would leave irrelevant PRs blocked by missing per-version contexts. Update the header to name only the stable aggregator.
# 2. The per-version `pytest (CPU, py3.x)` legs must NOT be the required
# status checks. GitHub evaluates a job-level `if` *before* expanding a
.github/workflows/cpu-tests.yml:6
- The gate does not test only PRs that touch code: it deliberately runs for every non-denied path, including a top-level
README.mdand potentially inert unknown files. Describe the fail-open relevance decision instead so this header matches the implemented behavior.
# PR merge gate: run the CPU-runnable slice of the pytest suite on pull
# requests that touch code (and on pushes to main). GPU-only tests (markers
# `gpu` / `rocm`) are deselected here and run in gpu-tests.yml -- see
docs/ci-testing-plan.md:21
- This trigger description is inaccurate: the workflow triggers on every PR, while only its matrix is conditionally skipped, and fail-open paths such as a top-level
README.mdstill run it. Distinguish the unconditional PR trigger from the matrix path gate.
| `cpu-tests.yml` | PR (code-touching paths) + push to `main` | CPU pytest gate (`not gpu and not rocm`) on `ubuntu-latest` |
cpu-tests.yml triggered on every pull_request with no path filter, so a CI-only change like #337 (which only edited sanitizers-nightly.yml) spun up all three pytest (CPU, py3.x) matrix jobs even though nothing under src/, tests/, or the packaging metadata changed. Add a `changes` gate mirroring gpu-tests.yml's required-check-safe pattern: the decision lives in a job + job-level `if` (not a trigger-level paths: filter, which would strand the required check as Pending), and it fails open (non-PR events and any error listing files run the full suite). Unlike the GPU gate's allow-list, the CPU suite is the catch-all touched by nearly the whole tree (including docs a test reads, e.g. docs/layer-numerics.md via test_layer_numerics_docs.py), so this uses a narrow deny-list instead: run unless every changed file is proven inert for `pytest -m "not gpu and not rocm"`. A wrong deny entry only runs the fast suite unnecessarily; it never skips a real code change. Initial deny-list is `.github/*`, with cpu-tests.yml itself special-cased as relevant. Closes #338 Co-authored-by: Cursor <[email protected]>
Copilot review on #342 surfaced four real issues, all fixed here: - Required-check hang (actions/runner#952): a matrix job skipped by a job-level `if` never emits its per-version pytest (CPU, py3.x) contexts, so pinning branch protection to them hangs skipped PRs forever -- the opposite of this PR's goal. gpu-tests.yml is safe only because its gated job is a single non-matrix job. Add a stable, always-running `required` aggregator job (check name "CPU tests") that collapses the matrix result into one context reporting on every PR; document that branch protection must require it, not the legs. - Pagination fail-open hole: the /files listing caps at 3000 files, so a truncated list of all-ignorable paths could wrongly skip. Read the PR's changed_files and fail open when the returned record count is short. - Renames: evaluate both filename and previous_filename so a source file moved into an ignored path still counts as a relevant change. - Inverted safety claim: the deny-list is only fail-open for *omitted* entries; an overbroad/wrong entry silently skips tests. Reworded the workflow comment and docs to state the asymmetry. Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
f2339db to
abbebb2
Compare
Summary
cpu-tests.ymltriggered on everypull_requestwith no path filtering, so the three-Pythonpytest (CPU, py3.x)matrix ran on every PR — including ones that cannot change the outcome ofpytest -m "not gpu and not rocm". For example #337 only edited.github/workflows/sanitizers-nightly.yml, yet all three CPU jobs ran.This adds a
changesgate tocpu-tests.yml, following the same required-check-safe patterngpu-tests.ymlalready uses:changesjob + a job-levelif, not a trigger-levelpaths:filter — a path-skipped required check stays Pending forever and blocks merge, whereas a conditionally-skipped job reports Success.main) and any error listing the PR's files run the full suite.Why a deny-list (not the GPU gate's allow-list)
The GPU gate allow-lists a few GPU-relevant paths. The CPU suite is the opposite shape — the catch-all gate touched by nearly the whole tree (
src/**,tests/**, packaging metadata, and even a few docs, e.g.tests/instrumentation/test_layer_numerics_docs.pyreadsdocs/layer-numerics.md). An allow-list there would be huge and unsafe: a forgotten code path would silently skip real tests.So this gate uses a small deny-list and runs the suite unless every changed file matches a path proven inert for the pytest suite. A wrong/missing deny entry only ever runs the fast CPU suite unnecessarily; it can never skip a real code change. Initial deny-list is
.github/*(workflows, composite actions, templates, CODEOWNERS — none imported by any test), withcpu-tests.ymlitself special-cased as relevant.Behavior (dry-run of the gate logic)
sanitizers-nightly.ymlonly (like #337)cpu-tests.ymlitselfsrc/**changedocs/layer-numerics.mdsrc/**mixedREADME.mdTest plan
pytest (CPU, py3.x)report Success (skipped), not Pending.src/**ortests/**still runs the full matrix.changesjob logs its per-file decision.Docs updated in
docs/ci-testing-plan.md(new "Path gate" section).Closes #338
Made with Cursor
Made with Cursor