The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(release): the green workflow no longer writes the final tag
ethernet6f8d7dd3f7ec
diff --git a/.github/workflows/stable-release.yml b/.github/workflows/stable-release.ymlindex 92844d19496..2f89cbab3c1 100644--- a/.github/workflows/stable-release.yml+++ b/.github/workflows/stable-release.yml@@ -342,18 +342,14 @@ jobs:- run: python -m scripts.releases.stable gate admit ci docker acceptance candidates publication publish-dockerenv:RELEASE_NEEDS: ${{ toJSON(needs) }}- - name: Create the final tag and retarget the accepted release+ - name: Validate the accepted candidate archiverun: python -m scripts.releases.stable completeenv:- RELEASE_NEEDS: ${{ toJSON(needs) }}- GH_TOKEN: ${{ github.token }}RELEASE_TAG: ${{ needs.admit.outputs.tag }}RELEASE_CLAIM_TAG: ${{ needs.admit.outputs.claim-tag }}RELEASE_CLAIM_OBJECT: ${{ needs.admit.outputs.claim-object }}- RELEASE_ID: ${{ needs.admit.outputs.release-id }}CANDIDATE_MANIFEST_URL: ${{ needs.candidates.outputs.manifest-url }}CANDIDATE_MANIFEST_SHA256: ${{ needs.candidates.outputs.manifest-sha256 }}- DOCKER_MANIFEST_DIGEST: ${{ needs.publish-docker.outputs.manifest-digest }}CLOUDFLARE_R2_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_R2_ACCOUNT_ID }}CLOUDFLARE_R2_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }}CLOUDFLARE_R2_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }}diff --git a/scripts/releases/sequencer.py b/scripts/releases/sequencer.pyindex e2bb07ca88a..bc8aca407ee 100644--- a/scripts/releases/sequencer.py+++ b/scripts/releases/sequencer.py@@ -118,8 +118,13 @@ def _utc(value: str) -> datetime:def classify_runs(runs: list[dict], *, claimed_at: datetime | None = None,- now: datetime | None = None) -> tuple[str, dict | None]:- """Keep failed claims live until two failed-job retries are exhausted."""+ now: datetime | None = None, has_draft: bool = False) -> tuple[str, dict | None]:+ """Keep failed claims live until two failed-job retries are exhausted.++ Success with a draft on the attempt ref is green: the final tag moves to+ publish. A missing draft after success is an error, because the tool is+ the only thing that deletes drafts; abandonment is the marker ref.+ """if not runs:if claimed_at is None:raise ValueError("A claim without a workflow needs its immutable claim time")@@ -135,7 +140,9 @@ def classify_runs(runs: list[dict], *, claimed_at: datetime | None = None,if latest.get("status") != "completed":return "running", Noneif latest.get("conclusion") == "success":- raise ValueError("Stable workflow succeeded without a final tag")+ if not has_draft:+ raise ValueError("Stable workflow succeeded without a draft release")+ return "green", Noneif attempt >= MAX_ATTEMPTS:return "burned", Noneupdated_at = latest.get("updated_at")@@ -280,6 +287,7 @@ def discover(repository: str, run=output) -> list[dict]:state, retry = classify_runs(matching_runs,claimed_at=datetime.fromtimestamp(claim_epoch, tz=timezone.utc),+ has_draft=release is not None,)records.append({diff --git a/scripts/releases/stable.py b/scripts/releases/stable.pyindex 6e81be61e85..a7e421773b8 100644--- a/scripts/releases/stable.py+++ b/scripts/releases/stable.py@@ -504,20 +504,11 @@ def retarget_release(repository: str, release_id: int, tag: str, commit: str, *,def complete(env: dict) -> None:+ """Validate the accepted candidate archive. The final tag moves to publish."""tag, commit, claim = stable_context(env)base = env["CLOUDFLARE_R2_PUBLIC_URL"].rstrip("/")candidate = read_candidate(env)validate_candidates(candidate, tag, commit, base, claim["claim_epoch"])- release_id = env.get("RELEASE_ID", "")- if not str(release_id).isdigit():- raise ValueError("Stable release database ID is required")- ensure_final_tag(- tag, commit, claim,- candidate_manifest_sha256=env["CANDIDATE_MANIFEST_SHA256"],- docker_manifest_digest=env.get("DOCKER_MANIFEST_DIGEST", ""),- release_id=int(release_id),- )- retarget_release(env["GITHUB_REPOSITORY"], int(release_id), tag, commit, publish=False)def main(argv: list[str] | None = None, env: dict | None = None) -> None:diff --git a/tests/scripts/test_release_sequencer.py b/tests/scripts/test_release_sequencer.pyindex 1b0406c6d03..87d8d71f51b 100644--- a/tests/scripts/test_release_sequencer.py+++ b/tests/scripts/test_release_sequencer.py@@ -110,6 +110,19 @@ def test_failed_run_retries_twice_after_backoff_before_burning():assert classify_runs([failed]) == ("burned", None)+def test_a_succeeded_run_is_green_only_with_its_draft():+ from scripts.releases.sequencer import classify_final_release, classify_runs++ succeeded = {"id": 9, "status": "completed", "conclusion": "success", "run_attempt": 1}+ assert classify_runs([succeeded], has_draft=True) == ("green", None)+ # The tool is the only thing that deletes drafts; a missing draft after+ # success is an error, not an inferred abandonment.+ with pytest.raises(ValueError, match="without a draft"):+ classify_runs([succeeded], has_draft=False)+ draft = {"id": 9, "tag_name": "rc.1-v0.21.5", "draft": True, "prerelease": False}+ assert classify_final_release("v0.21.5", "rc.1-v0.21.5", draft) == ("green", True)++def test_a_burned_claim_is_spent_and_skipped():from scripts.releases.sequencer import classify_final_release, plandiff --git a/tests/scripts/test_stable_release.py b/tests/scripts/test_stable_release.pyindex 7ac46dd18cf..ddabfd1e364 100644--- a/tests/scripts/test_stable_release.py+++ b/tests/scripts/test_stable_release.py@@ -274,6 +274,64 @@ def test_claim_object_movement_and_lightweight_tags_fail_closed(tmp_path, monkeycheck_claim(env)+def _claim_fixture(tmp_path, *, tag, version):+ """A real checkout + bare remote carrying one annotated attempt claim."""+ from scripts.releases.versioning import parse_attempt_ref++ epoch = candidates("v" + version, "0" * 40, "0" * 64)["releaseEpoch"]+ repo, remote = tmp_path / "repo", tmp_path / "remote.git"+ repo.mkdir()+ subprocess.run(["git", "init", "-b", "main"], cwd=repo, check=True, capture_output=True)+ subprocess.run(["git", "init", "--bare", str(remote)], check=True, capture_output=True)+ subprocess.run(["git", "config", "user.name", "fixture"], cwd=repo, check=True)+ subprocess.run(["git", "config", "user.email", "[email protected]"], cwd=repo, check=True)+ (repo / "input").write_text("first", encoding="utf-8")+ subprocess.run(["git", "add", "input"], cwd=repo, check=True)+ subprocess.run(["git", "commit", "-m", "first"], cwd=repo, check=True, capture_output=True)+ commit = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=repo, text=True, encoding="utf-8").strip()+ attempt = parse_attempt_ref(tag)[1]+ metadata = json.dumps({+ "schema": 1, "version": version, "attempt": attempt, "commit": commit,+ "autopublish": False, "claimEpoch": epoch,+ }, sort_keys=True, separators=(",", ":"))+ subprocess.run(+ ["git", "tag", "-a", tag, "-m", metadata], cwd=repo, check=True,+ env={**os.environ, "GIT_COMMITTER_DATE": f"@{epoch} +0000"},+ )+ subprocess.run(["git", "remote", "add", "origin", str(remote)], cwd=repo, check=True)+ subprocess.run(["git", "push", "origin", "main", tag], cwd=repo, check=True, capture_output=True)+ tag_object = subprocess.check_output(["git", "rev-parse", tag], cwd=repo, text=True, encoding="utf-8").strip()+ return commit, tag_object+++def test_complete_writes_no_final_tag_and_leaves_the_draft_on_the_attempt_ref(tmp_path, monkeypatch):+ from scripts.releases import stable++ commit, tag_object = _claim_fixture(tmp_path, tag="rc.1-v1.2.3", version="1.2.3")+ candidate = candidates("v1.2.3", commit, "c" * 64)+ calls = []++ def record(argv):+ calls.append(argv)+ if argv[0] == "gh":+ raise AssertionError("complete must not touch GitHub")+ return subprocess.check_output(argv, text=True, encoding="utf-8").strip()++ monkeypatch.setattr(stable, "output", record)+ monkeypatch.setattr(stable, "read_candidate", lambda env: candidate)+ monkeypatch.chdir(tmp_path / "repo")+ stable.complete({+ "RELEASE_CLAIM_TAG": "rc.1-v1.2.3", "RELEASE_CLAIM_OBJECT": tag_object,+ "GITHUB_SHA": commit, "GITHUB_REF": "refs/tags/rc.1-v1.2.3",+ "RELEASE_TAG": "v1.2.3", "CANDIDATE_MANIFEST_SHA256": "c" * 64,+ "CLOUDFLARE_R2_PUBLIC_URL": BASE,+ })+ remote = subprocess.check_output(+ ["git", "ls-remote", "origin", "refs/tags/*"], text=True, encoding="utf-8")+ assert "refs/tags/v1.2.3" not in remote+ assert not [argv for argv in calls if argv[0] == "gh"]++@pytest.mark.parametrize("publish", [False, True])def test_retarget_release_preserves_the_database_id_and_explicit_draft_policy(publish):commit = "a" * 40