diff --git a/build_tools/github_actions/configure_ci_labels.py b/build_tools/github_actions/configure_ci_labels.py index bf1fb6f77ef..e25dc2e6957 100755 --- a/build_tools/github_actions/configure_ci_labels.py +++ b/build_tools/github_actions/configure_ci_labels.py @@ -64,6 +64,7 @@ class Label: Label("ci:asan", COLOR_CI_GENERAL, "Opt-in to building ASAN"), Label("ci:host-asan", COLOR_CI_GENERAL, "Opt-in to running multi-arch host-asan CI on a pull request"), Label("ci:run-multi-gpu", COLOR_CI_GENERAL, "Opt-in to running multi-GPU tests"), + Label("ci:cpu-test-only", COLOR_CI_GENERAL, "Run only CPU tests (skip GPU tests)"), # ci:platform: labels (platform selection) Label("ci:platform:linux", COLOR_CI_PLATFORM, "Run CI only on Linux (skip Windows builds/tests)"), Label("ci:platform:windows", COLOR_CI_PLATFORM, "Run CI only on Windows (skip Linux builds/tests)"), diff --git a/build_tools/github_actions/configure_multi_arch_ci.py b/build_tools/github_actions/configure_multi_arch_ci.py index 395f205cad7..1963242475f 100755 --- a/build_tools/github_actions/configure_multi_arch_ci.py +++ b/build_tools/github_actions/configure_multi_arch_ci.py @@ -1601,6 +1601,13 @@ def _expand_build_config_for_platform( f"(global={jobs.test_rocm.test_type})" ) + # ci:cpu-test-only label: disable GPU tests, only run CPU-only tests. + # This is useful for changes that don't require GPU testing (e.g., docs, + # build scripts, CPU-only components). + if "ci:cpu-test-only" in ci_inputs.pr_labels and test_runs_on: + test_runs_on = "" + print(f" {family_name}: GPU tests disabled by 'ci:cpu-test-only' label") + # CPU test runner for components that don't need GPU access (e.g., # components with linux_cpu_runner: True). This allows CPU-only tests # to run even when GPU testing is gated (e.g., trigger_test_label_only). diff --git a/build_tools/github_actions/tests/configure_multi_arch_ci_test.py b/build_tools/github_actions/tests/configure_multi_arch_ci_test.py index d43e2ec0cda..c832c2a8701 100644 --- a/build_tools/github_actions/tests/configure_multi_arch_ci_test.py +++ b/build_tools/github_actions/tests/configure_multi_arch_ci_test.py @@ -3046,5 +3046,55 @@ def test_families_without_multi_label_use_primary_only(self): self.assertEqual(gfx103x_info["test-runs-on"], "linux-gfx1030-gpu-rocm") +# --------------------------------------------------------------------------- +class TestCpuTestOnlyLabel(unittest.TestCase): + """ci:cpu-test-only label: disable GPU tests, keep CPU-only tests.""" + + def _expand(self, pr_labels=None, platform="linux", family="gfx94x"): + ci_inputs = cm.CIInputs( + run_id="1", + event_name="pull_request", + commit_ref="feature", + base_ref="HEAD^1", + build_variant="release", + pr_labels=pr_labels or [], + ) + result = cm.expand_build_configs( + ci_inputs=ci_inputs, + git_context=cm.GitContext(), + targets=cm.TargetSelection(**{f"{platform}_families": [family]}), + jobs=_jobs(), + ) + return getattr(result, platform).per_family_info[0] + + def test_label_disables_gpu_keeps_cpu(self): + """Label disables GPU tests but keeps CPU runner and tests_enabled.""" + entry = self._expand(pr_labels=["ci:cpu-test-only"]) + self.assertEqual(entry["test-runs-on"], "") + self.assertNotEqual(entry["test-runs-on-cpu"], "") + self.assertTrue(entry["tests_enabled"]) + + def test_without_label_gpu_tests_run(self): + """Without label, GPU tests run normally.""" + self.assertNotEqual(self._expand()["test-runs-on"], "") + + def test_works_on_windows(self): + """Label works on Windows.""" + entry = self._expand(["ci:cpu-test-only"], platform="windows", family="gfx110x") + self.assertEqual(entry["test-runs-on"], "") + + def test_label_disables_multi_gpu(self): + """Label also disables multi-GPU tests.""" + entry = self._expand(pr_labels=["ci:cpu-test-only"]) + self.assertNotIn("test-runs-on-multi-gpu", entry) + self.assertNotIn("test-runs-on-multi-gpu-labels", entry) + + def test_without_label_multi_gpu_present(self): + """Without label, multi-GPU info is present (when platform supports it).""" + entry = self._expand() + # gfx94x has multi-GPU support + self.assertIn("test-runs-on-multi-gpu-labels", entry) + + if __name__ == "__main__": unittest.main() diff --git a/docs/development/ci_behavior_manipulation.md b/docs/development/ci_behavior_manipulation.md index 99631af1dc5..4b528f659f0 100644 --- a/docs/development/ci_behavior_manipulation.md +++ b/docs/development/ci_behavior_manipulation.md @@ -26,6 +26,7 @@ The following labels may be added to a pull request to modify CI behavior: | `ci:asan` | Enable ASAN CI builds and tests. ASAN CI is skipped by default on PRs unless this label is present. | | `ci:host-asan` | Alias for `ci:asan`. Enable ASAN CI builds and tests. | | `ci:run-multi-gpu` | Opt-in to running multi-GPU tests. | +| `ci:cpu-test-only` | Run only CPU tests (skip GPU tests). Useful for changes that don't require GPU testing. | | `ci:platform:linux` | Run CI only on Linux (skip Windows builds/tests) | | `ci:platform:windows` | Run CI only on Windows (skip Linux builds/tests) | | `ci:gfx...` | Opt-in to building and testing the specified gfx family (e.g. `ci:gfx120X-all`, `ci:gfx950-dcgpu`) |