Skip to content

Commit 681bf33

Browse files
committed
ci: run each heavy suite for the changes its PR run executes
ATOM Test decided relevance by a deny-list: every path not listed ran the GPU suite, so a PR changing only a CPU unit test (#3879) ran 15 GPU jobs. The plugin and ATOMesh suites had the opposite gap: their include lists missed files their PR runs execute (the gate's own action and scripts, shared download / preflight scripts, setup.py and pyproject.toml for the ATOM they install, and for ATOMesh the shared actions, atom_test.sh and the golden outputs), so a change to those ran none of them. A change is relevant to a suite when it can alter what the suite's PR run executes: its code, how ATOM is installed, its workflow file, and the local actions, scripts, data files and Dockerfiles its PR-run steps use, followed through the scripts, actions and Dockerfiles they run. Every PR run installs the whole atom package; ATOM Test's code is all of it but the plugins and ATOMesh, while the plugin and ATOMesh suites keep their own code (atom/plugin/**, atom/mesh/**) and leave the rest of atom to ATOM Test and the runs on main, as before. ATOM Test now lists exactly that set (CI_GATE_PATHS_INCLUDE); tests, docs, tools, the Dockerfile of the published image it pulls and main-only steps no longer start it. The other three suites gain what they missed. ci_gate/suites.py mirrors the four lists. tests/ci_gate_relevance.py derives each PR run's files from the workflow: a step's run and with, local actions, and what the scripts, actions and Dockerfiles they run name outside comments; a file read as data counts, what it names does not. tests/test_ci_gate_suites.py fails when a suite's include list misses any of it or its own code, and pins the boundary that ATOM's core runs ATOM Test only.
1 parent dc4c3a4 commit 681bf33

9 files changed

Lines changed: 366 additions & 44 deletions

File tree

‎.github/scripts/ci_gate/README.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@ Defined once and used everywhere:
4646
decides.
4747
- **Changed paths** (`ChangedPaths`) are every path the PR adds, removes or
4848
renames from / to. When the file list is cut short, nothing is ruled out.
49+
- **A suite is relevant to a change** when the change can alter what the
50+
suite's PR run executes: its code, how ATOM is installed (the packaging
51+
files), its workflow file, and the local actions, scripts, data files and
52+
Dockerfiles its PR-run steps use, followed through the scripts, actions and
53+
Dockerfiles they run. The suite lists these as include globs;
54+
`tests/test_ci_gate_suites.py` derives them (`tests/ci_gate_relevance.py`)
55+
and fails when one is missing. A file the run does not execute (CPU unit
56+
tests, docs, the Dockerfile of an image it pulls, steps that run only on
57+
`main`, what a data file or a comment names) is not relevant. Every PR run
58+
installs the whole `atom` package, but only ATOM Test's code is all of it
59+
(the packages `pyproject.toml` declares, less the plugins and ATOMesh); the
60+
plugin and ATOMesh suites' code is `atom/plugin/**` and `atom/mesh/**`, and
61+
the rest of `atom` is left to ATOM Test and the runs on `main`.
4962
- **PR references** (`refs.py`): `#N`, `owner/repo#N`, and the PR's URL; names
5063
compare case-insensitively. **Dependencies** (`deps.py`) are the references
5164
to this repository right after `depends on`, `stacked on` or `blocked by`

‎.github/scripts/ci_gate/suites.py‎

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,24 @@ def _suite(
6161
)
6262

6363

64+
# Every suite's PR run installs ATOM from the PR and runs the old gate.
65+
_PACKAGING = ("setup.py", "pyproject.toml", "MANIFEST.in")
66+
_GATE = (
67+
".github/actions/evaluate-test-gate/**",
68+
".github/scripts/check_heavy_ci_gate.sh",
69+
".github/scripts/check_signal.sh",
70+
)
6471
_PLUGIN_INCLUDE = (
65-
"atom/plugin/**",
66-
".github/scripts/plugin_ci/**",
67-
"docker/atom_release.dockerfile",
72+
_PACKAGING
73+
+ _GATE
74+
+ (
75+
"atom/plugin/**",
76+
".github/scripts/plugin_ci/**",
77+
".github/scripts/download_aiter_wheel.sh",
78+
".github/scripts/download_model_with_lock.sh",
79+
".github/scripts/gpu_preflight_check.sh",
80+
"docker/atom_release.dockerfile",
81+
)
6882
)
6983

7084
SUITES: tuple[Suite, ...] = (
@@ -74,27 +88,23 @@ def _suite(
7488
"ATOM Test",
7589
"ATOM Test",
7690
("ci:full", "ci:atom"),
77-
ignore=(
78-
"**/*.md",
79-
"docs/**",
80-
".claude/**",
81-
"atomrl/**",
82-
".github/workflows/atomrl-*.yaml",
83-
"atom/plugin/**",
84-
"atom/mesh/**",
85-
".github/benchmark/models_atomesh.yaml",
86-
".github/scripts/atomesh/**",
87-
".github/workflows/atomesh-*.yaml",
88-
".github/workflows/atom-review-bot*.yml",
89-
".github/scripts/atomesh_*.sh",
90-
".github/dashboard/atomesh_*.html",
91-
".github/workflows/atom-vllm-*.yaml",
92-
".github/workflows/atom-sglang-*.yaml",
93-
".github/benchmark/oot_models_accuracy.json",
94-
".github/benchmark/sglang_models_accuracy.json",
95-
"LICENSE",
96-
".gitignore",
91+
include=_PACKAGING
92+
+ _GATE
93+
+ (
94+
"atom/**",
95+
".github/workflows/atom-test.yaml",
96+
".github/workflows/golden_outputs/**",
97+
".github/actions/docker-auth/**",
98+
".github/actions/setup-gpu-container/**",
99+
".github/benchmark/models_accuracy.json",
100+
".github/scripts/atom_test.sh",
101+
".github/scripts/collect_gpu_info.sh",
102+
".github/scripts/download_aiter_wheel.sh",
103+
".github/scripts/download_model_with_lock.sh",
104+
".github/scripts/gpu_preflight_check.sh",
105+
".github/scripts/install_aiter_wheel.sh",
97106
),
107+
ignore=("**/*.md", "atom/plugin/**", "atom/mesh/**"),
98108
smoke_job="Offline inference smoke test",
99109
old_gate_job="ATOM Test Gate",
100110
),
@@ -151,11 +161,21 @@ def _suite(
151161
"Atomesh Accuracy Validation",
152162
"ATOMesh Accuracy",
153163
("ci:full", "ci:mesh"),
154-
include=(
164+
include=_PACKAGING
165+
+ _GATE
166+
+ (
155167
"atom/mesh/**",
156168
".github/workflows/atomesh-accuracy-validation.yaml",
169+
".github/workflows/golden_outputs/**",
170+
".github/actions/docker-auth/**",
171+
".github/actions/setup-gpu-container/**",
157172
".github/scripts/accuracy_to_dashboard.py",
158173
".github/scripts/atomesh_pd_accuracy.sh",
174+
".github/scripts/atom_test.sh",
175+
".github/scripts/collect_gpu_info.sh",
176+
".github/scripts/download_aiter_wheel.sh",
177+
".github/scripts/download_model_with_lock.sh",
178+
".github/scripts/install_aiter_wheel.sh",
159179
".github/benchmark/models_accuracy.json",
160180
),
161181
old_gate_job="ATOMesh Accuracy Gate",

‎.github/workflows/atom-sglang-test.yaml‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,25 @@ jobs:
4848
CI_GATE_WORKFLOW: atom-sglang-test.yaml
4949
CI_GATE_LABELS: ci:full,ci:sglang
5050
# Approval alone does not start the sglang plugin CI: a PR runs it
51-
# when it changes the plugin, its CI or its image, or carries
52-
# ci:sglang / ci:full. Core-only changes are covered by the nightly.
51+
# when it changes the plugin, how ATOM is installed, the files its
52+
# PR-run steps use or its image, or carries ci:sglang / ci:full.
53+
# Core-only changes are covered by the nightly.
54+
# tests/test_ci_gate_suites.py derives the files the PR run uses
55+
# from this workflow and checks they are covered.
5356
CI_GATE_PATHS_INCLUDE: |
5457
atom/plugin/**
58+
setup.py
59+
pyproject.toml
60+
MANIFEST.in
5561
.github/workflows/atom-sglang-test.yaml
62+
.github/actions/evaluate-test-gate/**
5663
.github/scripts/plugin_ci/**
5764
.github/scripts/atom_sglang_test.sh
65+
.github/scripts/check_heavy_ci_gate.sh
66+
.github/scripts/check_signal.sh
67+
.github/scripts/download_aiter_wheel.sh
68+
.github/scripts/download_model_with_lock.sh
69+
.github/scripts/gpu_preflight_check.sh
5870
.github/workflows/docker-release.yaml
5971
.github/benchmark/sglang_models_accuracy.json
6072
docker/atom_release.dockerfile

‎.github/workflows/atom-test.yaml‎

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,26 +87,35 @@ jobs:
8787
CI_GATE_PR_CHECK_JOB: Offline inference smoke test
8888
CI_GATE_NOOP_JOB: Check Heavy CI Gate (no-op label)
8989
CI_GATE_LABELS: ci:full,ci:atom
90+
# What this workflow's PR run executes: the code it installs, how it
91+
# installs it, and the files its PR-run steps use. Anything else
92+
# (unit tests, docs, tools, other workflows) cannot change its
93+
# result. tests/test_ci_gate_suites.py derives the required part
94+
# from pyproject.toml and this file and checks it is covered.
95+
CI_GATE_PATHS_INCLUDE: |
96+
atom/**
97+
setup.py
98+
pyproject.toml
99+
MANIFEST.in
100+
.github/workflows/atom-test.yaml
101+
.github/workflows/golden_outputs/**
102+
.github/actions/docker-auth/**
103+
.github/actions/setup-gpu-container/**
104+
.github/actions/evaluate-test-gate/**
105+
.github/benchmark/models_accuracy.json
106+
.github/scripts/atom_test.sh
107+
.github/scripts/check_heavy_ci_gate.sh
108+
.github/scripts/check_signal.sh
109+
.github/scripts/collect_gpu_info.sh
110+
.github/scripts/download_aiter_wheel.sh
111+
.github/scripts/download_model_with_lock.sh
112+
.github/scripts/gpu_preflight_check.sh
113+
.github/scripts/install_aiter_wheel.sh
114+
# Within those: the parts the plugin and ATOMesh suites own.
90115
CI_GATE_PATHS_IGNORE: |
91116
**/*.md
92-
docs/**
93-
.claude/**
94-
atomrl/**
95-
.github/workflows/atomrl-*.yaml
96117
atom/plugin/**
97118
atom/mesh/**
98-
.github/benchmark/models_atomesh.yaml
99-
.github/scripts/atomesh/**
100-
.github/workflows/atomesh-*.yaml
101-
.github/workflows/atom-review-bot*.yml
102-
.github/scripts/atomesh_*.sh
103-
.github/dashboard/atomesh_*.html
104-
.github/workflows/atom-vllm-*.yaml
105-
.github/workflows/atom-sglang-*.yaml
106-
.github/benchmark/oot_models_accuracy.json
107-
.github/benchmark/sglang_models_accuracy.json
108-
LICENSE
109-
.gitignore
110119
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111120
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112121
run: bash ./.github/scripts/check_heavy_ci_gate.sh

‎.github/workflows/atom-vllm-test.yaml‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,26 @@ jobs:
4747
CI_GATE_WORKFLOW: atom-vllm-test.yaml
4848
CI_GATE_LABELS: ci:full,ci:vllm
4949
# Approval alone does not start the vllm plugin CI: a PR runs it
50-
# when it changes the plugin, its CI or its image, or carries
51-
# ci:vllm / ci:full. Core-only changes are covered by the nightly.
50+
# when it changes the plugin, how ATOM is installed, the files its
51+
# PR-run steps use or its image, or carries ci:vllm / ci:full.
52+
# Core-only changes are covered by the nightly.
53+
# tests/test_ci_gate_suites.py derives the files the PR run uses
54+
# from this workflow and checks they are covered.
5255
CI_GATE_PATHS_INCLUDE: |
5356
atom/plugin/**
57+
setup.py
58+
pyproject.toml
59+
MANIFEST.in
5460
.github/workflows/atom-vllm-test.yaml
61+
.github/actions/evaluate-test-gate/**
5562
.github/scripts/plugin_ci/**
5663
.github/scripts/atom_oot_test.sh
5764
.github/scripts/check_mtp_acceptance.sh
65+
.github/scripts/check_heavy_ci_gate.sh
66+
.github/scripts/check_signal.sh
67+
.github/scripts/download_aiter_wheel.sh
68+
.github/scripts/download_model_with_lock.sh
69+
.github/scripts/gpu_preflight_check.sh
5870
.github/benchmark/oot_models_accuracy.json
5971
docker/atom_release.dockerfile
6072
docker/vllm_release.dockerfile

‎.github/workflows/atomesh-accuracy-validation.yaml‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,30 @@ jobs:
8484
env:
8585
CI_GATE_WORKFLOW: atomesh-accuracy-validation.yaml
8686
CI_GATE_LABELS: ci:full,ci:mesh
87+
# A PR runs it when it changes ATOMesh, how ATOM is installed or the
88+
# files its PR-run steps use, or carries ci:mesh / ci:full. Changes
89+
# to the rest of ATOM are covered by ATOM Test and the nightly.
90+
# tests/test_ci_gate_suites.py derives the files the PR run uses
91+
# from this workflow and checks they are covered.
8792
CI_GATE_PATHS_INCLUDE: |
8893
atom/mesh/**
94+
setup.py
95+
pyproject.toml
96+
MANIFEST.in
8997
.github/workflows/atomesh-accuracy-validation.yaml
98+
.github/workflows/golden_outputs/**
99+
.github/actions/docker-auth/**
100+
.github/actions/evaluate-test-gate/**
101+
.github/actions/setup-gpu-container/**
90102
.github/scripts/accuracy_to_dashboard.py
91103
.github/scripts/atomesh_pd_accuracy.sh
104+
.github/scripts/atom_test.sh
105+
.github/scripts/check_heavy_ci_gate.sh
106+
.github/scripts/check_signal.sh
107+
.github/scripts/collect_gpu_info.sh
108+
.github/scripts/download_aiter_wheel.sh
109+
.github/scripts/download_model_with_lock.sh
110+
.github/scripts/install_aiter_wheel.sh
92111
.github/benchmark/models_accuracy.json
93112
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94113
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

‎tests/ci_gate_relevance.py‎

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# SPDX-License-Identifier: MIT
2+
# Copyright (C) 2026, Advanced Micro Devices, Inc. All rights reserved.
3+
# Copyright (c) 2026 ATOM Project Contributors
4+
"""What a suite's PR run executes, derived from the repository itself, so a
5+
suite's path list can be checked against it (test_ci_gate_suites.py):
6+
7+
- the code it installs: the packages pyproject.toml declares;
8+
- how it installs them: the packaging files;
9+
- the run's definition: its workflow file, the local actions, workflows,
10+
scripts, data files and Dockerfiles the steps that run on a PR use, and
11+
what those in turn use (a job or step that only runs on main does not run
12+
for a PR).
13+
"""
14+
15+
from __future__ import annotations
16+
17+
import re
18+
from pathlib import Path
19+
20+
import tomllib
21+
import yaml
22+
23+
REPO = Path(__file__).resolve().parent.parent
24+
PACKAGING_FILES = ("setup.py", "pyproject.toml", "MANIFEST.in")
25+
# Where a run's definition lives. A reference is a path below one of them:
26+
# stop at whitespace, quotes and expressions; not inside a longer path or name.
27+
_ROOTS = (
28+
".github/scripts",
29+
".github/actions",
30+
".github/benchmark",
31+
".github/workflows",
32+
"docker",
33+
)
34+
_REFERENCE = re.compile(
35+
rf"(?<![\w.-])(?:{'|'.join(map(re.escape, _ROOTS))})/[A-Za-z0-9_./-]*"
36+
)
37+
_ACTION_FILES = ("action.yml", "action.yaml")
38+
# Files the run executes, whose own references are part of the run. Any
39+
# other file a run names (a JSON, another workflow read for a pin) is its
40+
# data: relevant itself, but what it names is not run.
41+
_EXECUTED_SUFFIXES = (".sh", ".py", "dockerfile", "Dockerfile")
42+
_MAIN_ONLY = "refs/heads/main"
43+
44+
45+
def installed_package_dirs() -> list[str]:
46+
"""Top-level directories of the packages pyproject.toml installs."""
47+
config = tomllib.loads((REPO / "pyproject.toml").read_text(encoding="utf-8"))
48+
includes = config["tool"]["setuptools"]["packages"]["find"]["include"]
49+
return sorted({pattern.split(".", 1)[0] for pattern in includes})
50+
51+
52+
def _runs_on_pr(condition) -> bool:
53+
return _MAIN_ONLY not in str(condition or "")
54+
55+
56+
def _existing(reference: str) -> str | None:
57+
"""The repository path a reference names ('/'-terminated for a directory),
58+
or None when it names nothing that exists below a root."""
59+
name = reference.removesuffix("/.").rstrip("/")
60+
if name in _ROOTS:
61+
return None
62+
if (REPO / name).is_file():
63+
return name
64+
if (REPO / name).is_dir():
65+
return f"{name}/"
66+
return None
67+
68+
69+
def _named_in(text: str) -> set[str]:
70+
"""The paths a script, Dockerfile or step names outside its comment lines."""
71+
code = "\n".join(
72+
line for line in text.splitlines() if not line.lstrip().startswith("#")
73+
)
74+
return {path for path in map(_existing, _REFERENCE.findall(code)) if path}
75+
76+
77+
def _local(uses: str) -> str:
78+
"""A local action or reusable workflow's path; '' for a published one."""
79+
return uses.removeprefix("./") if uses.startswith("./") else ""
80+
81+
82+
def _executed_files(path: str) -> list[Path]:
83+
"""The files of a referenced path the run executes: a script or
84+
Dockerfile itself, an action directory's action file."""
85+
target = REPO / path
86+
if not path.endswith("/"):
87+
return [target] if path.endswith(_EXECUTED_SUFFIXES) else []
88+
return [target / name for name in _ACTION_FILES if (target / name).is_file()]
89+
90+
91+
def _with_what_they_use(paths: set[str]) -> set[str]:
92+
found = set(paths)
93+
pending = list(paths)
94+
while pending:
95+
for file in _executed_files(pending.pop()):
96+
for path in _named_in(file.read_text(encoding="utf-8", errors="ignore")):
97+
if path not in found:
98+
found.add(path)
99+
pending.append(path)
100+
return found
101+
102+
103+
def workflow_references(workflow_file: str) -> list[str]:
104+
"""Repository paths the workflow's PR-run steps use, and the paths those
105+
use in turn; a directory ends with '/'. A step's env is not read: a gate's
106+
own path lists live there."""
107+
workflow = yaml.safe_load(
108+
(REPO / ".github" / "workflows" / workflow_file).read_text(encoding="utf-8")
109+
)
110+
used: set[str] = set()
111+
for job in workflow["jobs"].values():
112+
if not _runs_on_pr(job.get("if")):
113+
continue
114+
used |= _named_in(_local(job.get("uses", "")))
115+
for step in job.get("steps") or []:
116+
if _runs_on_pr(step.get("if")):
117+
used |= _named_in(_local(step.get("uses", "")))
118+
used |= _named_in(str(step.get("run", "")))
119+
used |= _named_in(str(step.get("with") or ""))
120+
return sorted(_with_what_they_use(used) | {f".github/workflows/{workflow_file}"})
121+
122+
123+
def example_path(reference: str) -> str:
124+
"""A file the reference stands for: itself, or one inside a directory."""
125+
return reference + "x" if reference.endswith("/") else reference

0 commit comments

Comments
 (0)