Skip to content

ci(cpu-tests): skip CPU matrix on PRs that can't affect the suite - #342

Merged
amd-vivekag merged 3 commits into
mainfrom
ci/cpu-tests-path-gate
Aug 7, 2026
Merged

amd-vivekag merged 3 commits into
mainfrom
ci/cpu-tests-path-gate

Conversation

@amd-vivekag

Copy link
Copy Markdown
Collaborator

Summary

cpu-tests.yml triggered on every pull_request with no path filtering, so the three-Python pytest (CPU, py3.x) matrix ran on every PR — including ones that cannot change the outcome of pytest -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 changes gate to cpu-tests.yml, following the same required-check-safe pattern gpu-tests.yml already uses:

  • The relevance decision lives in a changes job + a job-level if, not a trigger-level paths: filter — a path-skipped required check stays Pending forever and blocks merge, whereas a conditionally-skipped job reports Success.
  • Fails open: non-PR events (push to 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.py reads docs/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), with cpu-tests.yml itself special-cased as relevant.

Behavior (dry-run of the gate logic)

Changed files Result
sanitizers-nightly.yml only (like #337) skip
composite action only skip
cpu-tests.yml itself run
any src/** change run
docs/layer-numerics.md run (a test reads it)
CI file + src/** mixed run
top-level README.md run (fail-open)

Test plan

  • Open/observe a CI-only PR and confirm pytest (CPU, py3.x) report Success (skipped), not Pending.
  • Confirm a PR touching src/** or tests/** still runs the full matrix.
  • Confirm the changes job 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

Copilot AI balanced review requested due to automatic review settings August 7, 2026 09:26
@amd-vivekag amd-vivekag self-assigned this Aug 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_filename for renamed files. A PR that moves a CPU-relevant file such as src/aorta/foo.py into .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.

Comment thread .github/workflows/cpu-tests.yml Resolved
Comment thread .github/workflows/cpu-tests.yml Resolved
Comment thread .github/workflows/cpu-tests.yml Resolved
Comment thread docs/ci-testing-plan.md Resolved
Comment thread docs/ci-testing-plan.md Resolved
amd-vivekag added a commit that referenced this pull request Aug 7, 2026
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]>
Copilot AI review requested due to automatic review settings August 7, 2026 10:07
@amd-vivekag

Copy link
Copy Markdown
Collaborator Author

Thanks for the thorough review — all five inline comments plus the suppressed one were valid and are addressed in 5dfe4ca / f2339db (replies on each thread).

Summary of changes since the first push:

  1. Required-check hang (the big one, Skipping a matrix job hangs the Pull Request when inner-matrix jobs are required status checks actions/runner#952). A matrix job skipped by a job-level if never emits its pytest (CPU, py3.x) contexts, so requiring those legs would hang skipped PRs forever — the opposite of this PR's intent. Added a stable, non-matrix CPU tests aggregator (if: always(), needs: [changes, tests]) that reports on every PR and passes when the matrix ran green or was legitimately skipped. Docs now say to require that aggregator, not the legs.
  2. Fail-open pagination guard. The /files listing caps at 3000; the gate now compares the returned record count against the PR's changed_files and fails open on any shortfall.
  3. Renames (suppressed comment). The gate now evaluates both filename and previous_filename, so a source file moved into an ignored path still counts as a relevant (source-removing) change. Verified with a simulation: src/aorta/foo.py → .github/moved.py correctly runs the suite.
  4. Inverted safety claim. Reworded the workflow comment and docs to state the asymmetry: an omitted deny entry only costs an extra fast run, but an overbroad/wrong entry silently skips real tests — so entries must be proven inert.

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.

Action for a repo admin: branch protection on main should require the CPU tests check and drop any requirement on pytest (CPU, py3.10/3.11/3.12).

Made with Cursor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 tests jobs. 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.md and 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.md still 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` |

amd-vivekag and others added 3 commits August 7, 2026 17:37
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]>
Copilot AI review requested due to automatic review settings August 7, 2026 12:07
@amd-vivekag
amd-vivekag force-pushed the ci/cpu-tests-path-gate branch from f2339db to abbebb2 Compare August 7, 2026 12:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@amd-vivekag
amd-vivekag merged commit 0f2cb23 into main Aug 7, 2026
10 checks passed
@amd-vivekag
amd-vivekag deleted the ci/cpu-tests-path-gate branch August 7, 2026 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CPU test gate runs on CI-only PRs that can't affect the suite

2 participants