Skip to content

Commit 6c3de41

Browse files
committed
ci: enforce SCM metadata rules for each bindings release role
Require the maintenance selector to exclude the pre-maintenance .0 baseline, even when bindings and metapackage selectors are changed together. Require the current selector to include .0 and reject a current-root fallback_version. Three regression cases failed before the fix. Integrated CI-tool and Core floor tests passed with pure-Python PyYAML.
1 parent a83b550 commit 6c3de41

2 files changed

Lines changed: 56 additions & 15 deletions

File tree

‎ci/tools/bindings_config.py‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,14 @@ def check_package_metadata(config: BindingsConfig, repo_root: Path) -> None:
232232
):
233233
raise BindingsConfigError(f"{path} must specify one git_describe_command --match selector")
234234
selector = command[command.index("--match") + 1]
235-
# The second form excludes the pre-maintenance .0 tag on main.
236-
if selector not in {f"v{package.ctk_target}.*", f"v{package.ctk_target}.[1-9]*"}:
235+
# Maintenance excludes the old .0 baseline; agreement between copies alone
236+
# must not allow that baseline to reenter standard SCM version selection.
237+
patch_selector = "[1-9]*" if package.release_status == "maintenance" else "*"
238+
expected_selector = f"v{package.ctk_target}.{patch_selector}"
239+
if selector != expected_selector:
237240
raise BindingsConfigError(
238-
f"{path} --match must select registered CUDA {package.ctk_target}, got {selector!r}"
241+
f"{path} --match must select registered CUDA {package.ctk_target} "
242+
f"using {expected_selector!r} for the {package.release_status} root, got {selector!r}"
239243
)
240244
selectors[package.cuda_major] = selector
241245
if package.release_status == "maintenance":
@@ -247,6 +251,8 @@ def check_package_metadata(config: BindingsConfig, repo_root: Path) -> None:
247251
raise BindingsConfigError(
248252
f"{path} fallback_version must be a CUDA {package.ctk_target} development version"
249253
)
254+
elif "fallback_version" in scm:
255+
raise BindingsConfigError(f"{path} current bindings root must not declare fallback_version")
250256

251257
setup_path = repo_root / "cuda_python" / "setup.py"
252258
names = {"SCM_DESCRIBE_MATCH_BY_MAJOR", "MAINTENANCE_FALLBACK_VERSION"}

‎ci/tools/tests/test_bindings_config.py‎

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ def _write_config(root: Path, data: object, filename: str = "versions.yml") -> N
4747
path.write_text(yaml.safe_dump(data, sort_keys=False), encoding="utf-8")
4848

4949

50+
def _copy_package_metadata(root: Path) -> None:
51+
repo_root = Path(__file__).resolve().parents[3]
52+
_write_config(root, _registry())
53+
for relative in (
54+
"cuda_bindings/pyproject.toml",
55+
"cuda_bindings_12/pyproject.toml",
56+
"cuda_bindings_12/pixi.toml",
57+
"cuda_python/setup.py",
58+
):
59+
destination = root / relative
60+
destination.parent.mkdir(parents=True, exist_ok=True)
61+
shutil.copyfile(repo_root / relative, destination)
62+
63+
5064
@pytest.mark.parametrize(
5165
("tag", "package_root", "version"),
5266
(
@@ -144,24 +158,20 @@ def test_config_loader_reports_invalid_yaml(tmp_path):
144158
'[tool.setuptools_scm]\ntag_regex = "custom"',
145159
"must use setuptools-scm's default tag parser",
146160
),
161+
(
162+
"cuda_bindings/pyproject.toml",
163+
"[tool.setuptools_scm]",
164+
'[tool.setuptools_scm]\nfallback_version = "13.4.0.dev0"',
165+
"current bindings root must not declare fallback_version",
166+
),
147167
("cuda_python/setup.py", "v13.4.*", "v13.5.*", "SCM_DESCRIBE_MATCH_BY_MAJOR must match"),
148168
("cuda_python/setup.py", "12.9.10.dev0", "12.9.9.dev0", "MAINTENANCE_FALLBACK_VERSION must match"),
149169
("cuda_bindings_12/pixi.toml", "12.9.10.dev0", "12.9.9.dev0", "package.version must match"),
150170
),
151171
)
152-
@pytest.mark.agent_authored(model="gpt-6-astra")
172+
@pytest.mark.agent_authored(model="gpt-6")
153173
def test_metadata_check_rejects_independent_package_drift(tmp_path, capsys, path, before, after, message):
154-
repo_root = Path(__file__).resolve().parents[3]
155-
_write_config(tmp_path, _registry())
156-
for relative in (
157-
"cuda_bindings/pyproject.toml",
158-
"cuda_bindings_12/pyproject.toml",
159-
"cuda_bindings_12/pixi.toml",
160-
"cuda_python/setup.py",
161-
):
162-
destination = tmp_path / relative
163-
destination.parent.mkdir(parents=True, exist_ok=True)
164-
shutil.copyfile(repo_root / relative, destination)
174+
_copy_package_metadata(tmp_path)
165175
changed = tmp_path / path
166176
content = changed.read_text(encoding="utf-8")
167177
assert before in content
@@ -173,6 +183,31 @@ def test_metadata_check_rejects_independent_package_drift(tmp_path, capsys, path
173183
assert message in capsys.readouterr().err
174184

175185

186+
@pytest.mark.parametrize(
187+
("package_root", "role", "before", "after"),
188+
(
189+
("cuda_bindings_12", "maintenance", "v12.9.[1-9]*", "v12.9.*"),
190+
("cuda_bindings", "current", "v13.4.*", "v13.4.[1-9]*"),
191+
),
192+
)
193+
@pytest.mark.agent_authored(model="gpt-6")
194+
def test_metadata_check_rejects_selectors_changed_together(tmp_path, capsys, package_root, role, before, after):
195+
_copy_package_metadata(tmp_path)
196+
args = ["--config", str(tmp_path / "ci" / "versions.yml"), "--check-package-metadata"]
197+
assert main(args) == 0
198+
199+
for relative in (f"{package_root}/pyproject.toml", "cuda_python/setup.py"):
200+
changed = tmp_path / relative
201+
content = changed.read_text(encoding="utf-8")
202+
assert before in content
203+
changed.write_text(content.replace(before, after), encoding="utf-8")
204+
205+
with pytest.raises(SystemExit, match="2"):
206+
main(args)
207+
208+
assert f"using {before!r} for the {role} root" in capsys.readouterr().err
209+
210+
176211
@pytest.mark.agent_authored(model="gpt-6-sol")
177212
def test_cli_writes_selected_package_to_github_env(tmp_path, capsys, monkeypatch):
178213
output = tmp_path / "github-env"

0 commit comments

Comments
 (0)