Skip to content

The agent that grows with you

feat(release): admit rc.N-vX.Y.Z claim refs

ethernet60c023c7afa1
diff --git a/scripts/releases/stable.py b/scripts/releases/stable.py
index 639d933a438..6e81be61e85 100644
--- a/scripts/releases/stable.py
+++ b/scripts/releases/stable.py
@@ -26,22 +26,22 @@ SMOKE_JOBS = {
def admit_claim(tag: str, commit: str, *, on_main) -> dict:
- """Admit a release from its claim tag. The checkout version is not read.
+ """Admit a release from its attempt ref. The checkout version is not read.
- ``main`` carries ``0.0.0`` on purpose, so the version comes from the
- ``-rc`` tag and the only question about the commit is whether it is on
- ``main``.
+ ``main`` carries ``0.0.0`` on purpose, so the version and the attempt come
+ from ``rc.<N>-vX.Y.Z`` and the only question about the commit is whether
+ it is on ``main``.
"""
- from scripts.releases.versioning import version_from_tag
+ from scripts.releases.versioning import parse_attempt_ref
- if not isinstance(tag, str) or not tag.endswith("-rc"):
- raise ValueError(f"{tag} is not a claim tag")
- version = version_from_tag(tag[:-3])
- if version is None:
+ parsed = parse_attempt_ref(tag)
+ if parsed is None:
raise ValueError(f"{tag} is not a claim tag")
+ version, attempt = parsed
if not on_main(commit):
raise ValueError(f"{commit} is not on main")
- return {"claim_tag": tag, "tag": f"v{version}", "version": version, "commit": commit}
+ return {"claim_tag": tag, "tag": f"v{version}", "version": version, "attempt": attempt,
+ "commit": commit}
def require_stable_identity(tag: str, commit: str) -> None:
@@ -185,12 +185,12 @@ def output(argv: list[str]) -> str:
return subprocess.check_output(argv, text=True, encoding="utf-8").strip()
-def _claim_metadata(raw: str, *, version: str, commit: str) -> dict:
+def _claim_metadata(raw: str, *, version: str, attempt: int, commit: str) -> dict:
try:
metadata = json.loads(raw)
except (TypeError, json.JSONDecodeError) as error:
raise ValueError("Stable claim metadata is invalid") from error
- expected = {"schema": 1, "version": version, "commit": commit}
+ expected = {"schema": 1, "version": version, "attempt": attempt, "commit": commit}
if (not isinstance(metadata, dict)
or any(metadata.get(key) != value for key, value in expected.items())
or not isinstance(metadata.get("autopublish"), bool)
@@ -248,7 +248,8 @@ def check_claim(env: dict, run=output) -> dict:
admitted = admit_claim(claim_tag, commit, on_main=on_main)
raw_metadata = run(["git", "tag", "-l", claim_tag, "--format=%(contents)"])
- metadata = _claim_metadata(raw_metadata, version=admitted["version"], commit=commit)
+ metadata = _claim_metadata(raw_metadata, version=admitted["version"],
+ attempt=admitted["attempt"], commit=commit)
claim_epoch = tagger_epoch(local_object, run)
if metadata["claimEpoch"] != claim_epoch:
raise ValueError("Stable claim epoch differs from its annotated tagger timestamp")
@@ -299,7 +300,7 @@ def final_context(env: dict, run=output) -> tuple[str, str, dict]:
run(["git", "merge-base", "--is-ancestor", commit, "origin/main"])
claim = _claim_metadata(
run(["git", "tag", "-l", claim_tag, "--format=%(contents)"]),
- version=admitted["version"], commit=commit,
+ version=admitted["version"], attempt=admitted["attempt"], commit=commit,
)
final = json.loads(run(["git", "tag", "-l", tag, "--format=%(contents)"]))
expected = {
diff --git a/tests/ci/test_desktop_release_tag_admission.py b/tests/ci/test_desktop_release_tag_admission.py
index 562c29d72c8..e07f1184788 100644
--- a/tests/ci/test_desktop_release_tag_admission.py
+++ b/tests/ci/test_desktop_release_tag_admission.py
@@ -186,6 +186,7 @@ def _claim_message(clone: Path) -> str:
return json.dumps({
"schema": 1,
"version": "0.1.2",
+ "attempt": 1,
"commit": _git("rev-parse", "HEAD", cwd=clone),
"autopublish": False,
"claimEpoch": 1_790_000_000,
@@ -196,10 +197,10 @@ def test_claim_on_origin_main_is_admitted_and_exports_the_full_sha(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
_origin, clone = _seed_repo(tmp_path)
monkeypatch.setenv("GIT_COMMITTER_DATE", "@1790000000 +0000")
- _git("tag", "-a", "v0.1.2-rc", "-m", _claim_message(clone), cwd=clone)
- _git("push", "origin", "refs/tags/v0.1.2-rc", cwd=clone)
+ _git("tag", "-a", "rc.1-v0.1.2", "-m", _claim_message(clone), cwd=clone)
+ _git("push", "origin", "refs/tags/rc.1-v0.1.2", cwd=clone)
- proc = _run_admission(clone, "v0.1.2", "v0.1.2-rc")
+ proc = _run_admission(clone, "v0.1.2", "rc.1-v0.1.2")
assert proc.returncode == 0, proc.stdout + proc.stderr
gh_output = (clone / "github_output.txt").read_text(encoding="utf-8")
@@ -213,10 +214,10 @@ def test_claim_not_on_origin_main_is_refused(tmp_path: Path):
(clone / "rogue.txt").write_text("unreviewed\n", encoding="utf-8")
_git("add", "-A", cwd=clone)
_git("commit", "-m", "rogue", cwd=clone)
- _git("tag", "-a", "v0.1.2-rc", "-m", _claim_message(clone), cwd=clone)
- _git("push", "origin", "refs/tags/v0.1.2-rc", cwd=clone)
+ _git("tag", "-a", "rc.1-v0.1.2", "-m", _claim_message(clone), cwd=clone)
+ _git("push", "origin", "refs/tags/rc.1-v0.1.2", cwd=clone)
- proc = _run_admission(clone, "v0.1.2", "v0.1.2-rc")
+ proc = _run_admission(clone, "v0.1.2", "rc.1-v0.1.2")
assert proc.returncode != 0, "a tag off origin/main must not be admitted"
assert "is not on main" in proc.stdout + proc.stderr
# And nothing was exported for the signing jobs to consume.
diff --git a/tests/scripts/test_stable_admission.py b/tests/scripts/test_stable_admission.py
index 5083c215830..1cbc753d7a6 100644
--- a/tests/scripts/test_stable_admission.py
+++ b/tests/scripts/test_stable_admission.py
@@ -1,21 +1,22 @@
-"""Stable admission reads the version from the claim, not from the checkout.
+"""Stable admission reads the version and the attempt from the attempt ref, not from the checkout.
``main`` carries ``0.0.0`` by design, so comparing the tag against
-``pyproject.toml`` would refuse every release. The claim tag is the version,
-and the only question about the commit is whether it is on ``main``.
+``pyproject.toml`` would refuse every release. The attempt ref
+``rc.<N>-vX.Y.Z`` names the version and the attempt, and the only question
+about the commit is whether it is on ``main``.
"""
import pytest
-def test_admission_reads_the_version_from_the_claim():
+def test_admission_reads_the_version_and_attempt_from_the_attempt_ref():
from scripts.releases.stable import admit_claim
commit = "a" * 40
- admitted = admit_claim("v0.21.5-rc", commit, on_main=lambda sha: sha == commit)
+ admitted = admit_claim("rc.2-v0.21.5", commit, on_main=lambda sha: sha == commit)
assert admitted == {
- "claim_tag": "v0.21.5-rc", "tag": "v0.21.5",
- "version": "0.21.5", "commit": commit,
+ "claim_tag": "rc.2-v0.21.5", "tag": "v0.21.5",
+ "version": "0.21.5", "attempt": 2, "commit": commit,
}
@@ -23,11 +24,12 @@ def test_admission_refuses_a_claim_for_a_commit_off_main():
from scripts.releases.stable import admit_claim
with pytest.raises(ValueError, match="not on main"):
- admit_claim("v0.21.5-rc", "b" * 40, on_main=lambda _sha: False)
+ admit_claim("rc.1-v0.21.5", "b" * 40, on_main=lambda _sha: False)
-def test_admission_refuses_a_tag_that_is_not_a_claim():
[email protected]("tag", ["v0.21.5", "v0.21.5-rc", "abandoned-rc.1-v0.21.5"])
+def test_admission_refuses_a_tag_that_is_not_an_attempt_ref(tag):
from scripts.releases.stable import admit_claim
- with pytest.raises(ValueError, match="claim"):
- admit_claim("v0.21.5", "a" * 40, on_main=lambda _sha: True)
+ with pytest.raises(ValueError, match="not a claim tag"):
+ admit_claim(tag, "a" * 40, on_main=lambda _sha: True)
diff --git a/tests/scripts/test_stable_release.py b/tests/scripts/test_stable_release.py
index cec4afaf8ce..7ac46dd18cf 100644
--- a/tests/scripts/test_stable_release.py
+++ b/tests/scripts/test_stable_release.py
@@ -79,7 +79,7 @@ def test_transitions_bind_all_arches_identity_version_and_archive():
old = candidates("v1.2.3", "a" * 40, "1" * 64)
new = candidates("v1.2.4", "b" * 40, "2" * 64)
require_stable_identity(new["tag"], new["commit"])
- for tag in ("v1.2.4+canary.20260907T143420Z", "v1.2.4-rc"):
+ for tag in ("v1.2.4+canary.20260907T143420Z", "v1.2.4-rc", "rc.1-v1.2.4"):
with pytest.raises(ValueError):
require_stable_identity(tag, new["commit"])
transitions = plan_transitions(old, new, BASE)
@@ -197,9 +197,11 @@ def test_manifest_origin_checks_with_real_https(https_origin):
def test_claim_object_movement_and_lightweight_tags_fail_closed(tmp_path, monkeypatch):
commit = "a" * 40
claim_object = "b" * 40
- ref = "refs/tags/v1.2.3-rc"
- env = {"RELEASE_CLAIM_TAG": "v1.2.3-rc", "RELEASE_CLAIM_OBJECT": claim_object,
+ ref = "refs/tags/rc.1-v1.2.3"
+ env = {"RELEASE_CLAIM_TAG": "rc.1-v1.2.3", "RELEASE_CLAIM_OBJECT": claim_object,
"GITHUB_SHA": commit, "GITHUB_REF": ref}
+ message = {"schema": 1, "version": "1.2.3", "attempt": 1, "commit": commit,
+ "autopublish": False, "claimEpoch": 1_790_000_000}
def git(argv):
if argv[1] == "ls-remote":
@@ -211,17 +213,18 @@ def test_claim_object_movement_and_lightweight_tags_fail_closed(tmp_path, monkey
if argv[1] == "rev-parse":
return claim_object if argv[-1] == ref else commit
if argv[1] == "tag":
- return json.dumps({
- "schema": 1, "version": "1.2.3", "commit": commit,
- "autopublish": False, "claimEpoch": 1_790_000_000,
- })
+ return json.dumps(message)
return ""
assert check_claim(env, git) == {
- "claim_tag": "v1.2.3-rc", "claim_object": claim_object,
- "tag": "v1.2.3", "version": "1.2.3", "commit": commit,
+ "claim_tag": "rc.1-v1.2.3", "claim_object": claim_object,
+ "tag": "v1.2.3", "version": "1.2.3", "attempt": 1, "commit": commit,
"autopublish": False, "claim_epoch": 1_790_000_000,
}
+ # The metadata binds the attempt its ref names.
+ for wrong in ({**message, "attempt": 2}, {k: v for k, v in message.items() if k != "attempt"}):
+ with pytest.raises(ValueError, match="metadata is invalid"):
+ check_claim(env, lambda argv, wrong=wrong: json.dumps(wrong) if argv[1] == "tag" else git(argv))
with pytest.raises(ValueError, match="moved"):
check_claim(env, lambda argv: f"{'c' * 40}\t{ref}\n{commit}\t{ref}^{{}}"
if argv[1] == "ls-remote" else git(argv))
@@ -242,14 +245,14 @@ def test_claim_object_movement_and_lightweight_tags_fail_closed(tmp_path, monkey
actual = subprocess.check_output(["git", "rev-parse", "HEAD"], text=True, encoding="utf-8").strip()
subprocess.run(["git", "remote", "add", "origin", str(remote)], check=True)
metadata = json.dumps({
- "schema": 1, "version": "1.2.3", "commit": actual,
+ "schema": 1, "version": "1.2.3", "attempt": 1, "commit": actual,
"autopublish": False, "claimEpoch": 1_790_000_000,
}, sort_keys=True, separators=(",", ":"))
subprocess.run(
- ["git", "tag", "-a", "v1.2.3-rc", "-m", metadata], check=True,
+ ["git", "tag", "-a", "rc.1-v1.2.3", "-m", metadata], check=True,
env={**os.environ, "GIT_COMMITTER_DATE": "@1790000000 +0000"},
)
- subprocess.run(["git", "push", "origin", "main", "v1.2.3-rc"], check=True, capture_output=True)
+ subprocess.run(["git", "push", "origin", "main", "rc.1-v1.2.3"], check=True, capture_output=True)
env.update({"GITHUB_SHA": actual, "RELEASE_CLAIM_OBJECT": subprocess.check_output(
["git", "rev-parse", ref], text=True, encoding="utf-8").strip()})
claim = check_claim(env)