The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(release): check the draft body before the claim; release takes --no-changelog
ethernet74c365a85a6a
diff --git a/scripts/release.py b/scripts/release.pyindex 0c29aa70864..0ebaf0aec7a 100755--- a/scripts/release.py+++ b/scripts/release.py@@ -2742,6 +2742,10 @@ def main():release_cmd.add_argument("--bump", choices=["major", "minor", "patch"], default="patch")release_cmd.add_argument("--autopublish", action="store_true",help="Publish on green instead of leaving a draft")+ # SUPPRESS keeps a --no-changelog given before the subcommand from being+ # reset by this parser's default.+ release_cmd.add_argument("--no-changelog", action="store_true", default=argparse.SUPPRESS,+ help="Leave the commit list out of the draft body")release_cmd.add_argument("--remote", type=str)publish_cmd = subcommands.add_parser("publish", help="Publish a green stable release through the ordered sequencer")diff --git a/scripts/releases/entrypoint.py b/scripts/releases/entrypoint.pyindex 595608ec6fe..32aa2717883 100644--- a/scripts/releases/entrypoint.py+++ b/scripts/releases/entrypoint.py@@ -150,8 +150,12 @@ def _next_claim_epoch(repo: Path) -> int:return max(int(time.time()), max(previous, default=0) + 1)+# GitHub refuses a release body longer than this with HTTP 422.+GITHUB_BODY_LIMIT = 125_000++def _changelog(repo: Path, repository: str, *, commit: str, tag: str, version: str,- published: tuple[str, str | None]) -> str:+ published: tuple[str, str | None], no_changelog: bool) -> str:"""The commit changelog from the stable base to the cut commit.GitHub's generate-notes lists merged pull requests since the last published@@ -169,12 +173,12 @@ def _changelog(repo: Path, repository: str, *, commit: str, tag: str, version: scommits = release_script.get_commits(since_tag=base, until=commit, cwd=repo)return release_script.generate_changelog(commits, tag, version, repo_url=f"https://github.com/{repository}",- prev_tag=receipt if base else None,+ prev_tag=receipt if base else None, no_changelog=no_changelog,)def release(commit: str, *, bump: str, repo: Path, remote: str, repository: str,- execute, autopublish: bool = False,+ execute, autopublish: bool = False, no_changelog: bool = False,published: tuple[str, str | None] = (SEED, None)) -> dict:"""Claim the next attempt of the derived version, cut its draft, and start the gate.@@ -192,6 +196,15 @@ def release(commit: str, *, bump: str, repo: Path, remote: str, repository: str,version = derive_next_version(published=published_version, bump=bump)attempt = next_attempt(version, _claims(repo))tag = attempt_ref(version, attempt)+ # Built before the claim: a body GitHub refuses would otherwise burn the attempt.+ body = draft_body(version=version, attempt_ref=tag, notes=_changelog(+ repo, repository, commit=commit, tag=tag, version=version, published=published,+ no_changelog=no_changelog,+ ))+ if len(body) > GITHUB_BODY_LIMIT:+ raise ReleaseRefused(+ f"the {tag} draft body is {len(body)} characters; GitHub accepts at most "+ f"{GITHUB_BODY_LIMIT}. Nothing was claimed. Re-run with --no-changelog.")claim_epoch = _next_claim_epoch(repo)claim = json.dumps({"schema": 1,@@ -222,14 +235,11 @@ def release(commit: str, *, bump: str, repo: Path, remote: str, repository: str,_refresh_claims(repo, remote)_outstanding_attempt(repo, remote)try:- notes = _changelog(repo, repository, commit=commit, tag=tag, version=version,- published=published)- # The body carries a warning at both ends, so it is built here and- # handed over as a file.+ # The body carries a warning at both ends, so it is handed over as a file.file = tempfile.NamedTemporaryFile("w", suffix=".md", delete=False, encoding="utf-8", newline="\n")try:- file.write(draft_body(version=version, attempt_ref=tag, notes=notes))+ file.write(body)finally:file.close()try:@@ -408,7 +418,7 @@ def cmd_release(args) -> None:from scripts.releases.versioning import published_stable_identityresult = release(commit, bump=args.bump, repo=repo, remote=remote, repository=repository,- execute=execute, autopublish=args.autopublish,+ execute=execute, autopublish=args.autopublish, no_changelog=args.no_changelog,published=published_stable_identity(repository),)print(next_steps(result))diff --git a/tests/scripts/test_release_entrypoint.py b/tests/scripts/test_release_entrypoint.pyindex e364227051c..8ddea2a06a7 100644--- a/tests/scripts/test_release_entrypoint.py+++ b/tests/scripts/test_release_entrypoint.py@@ -323,6 +323,66 @@ def test_a_dispatch_that_never_starts_is_an_error(source):assert "rc.1-v0.21.5" in git(source, "tag", "--list")+def _oversized_commit(repo, tmp_path):+ """A commit whose subject alone overflows GitHub's release body limit."""+ from scripts.releases.entrypoint import GITHUB_BODY_LIMIT++ message = tmp_path / "message.txt"+ message.write_text("feat: " + "x" * GITHUB_BODY_LIMIT, encoding="utf-8")+ git(repo, "commit", "--allow-empty", "--quiet", "-F", str(message))+ git(repo, "push", "--quiet", "origin", "main")+ return git(repo, "rev-parse", "HEAD")+++def test_an_oversized_body_is_refused_before_the_claim(source, tmp_path):+ from scripts.releases.entrypoint import ReleaseRefused++ commit = _oversized_commit(source, tmp_path)++ with pytest.raises(ReleaseRefused, match="--no-changelog"):+ _release(source, commit, execute=lambda command: pytest.fail(f"must not run {command}"))++ # Nothing was claimed, so the attempt is not burned.+ assert git(source, "ls-remote", "origin", "refs/tags/*") == ""+ assert git(source, "tag", "-l", "rc.*") == ""+++def test_no_changelog_releases_what_the_full_changelog_could_not(source, tmp_path):+ from scripts.releases.entrypoint import GITHUB_BODY_LIMIT++ commit = _oversized_commit(source, tmp_path)+ seen = {}++ def execute(command):+ if command[:3] == ["gh", "release", "create"]:+ with open(command[command.index("--notes-file") + 1], encoding="utf-8") as file:+ seen["body"] = file.read()+ return ""++ result = _release(source, commit, execute=execute, no_changelog=True)++ assert result["tag"] == "rc.1-v0.21.5"+ assert len(seen["body"]) <= GITHUB_BODY_LIMIT+ assert "<!-- HERMES_BUILDS_TABLE -->" in seen["body"]++[email protected]("argv", [+ ["release", "--commit", "HEAD", "--no-changelog"],+ ["--no-changelog", "release", "--commit", "HEAD"],+])+def test_release_command_accepts_no_changelog(argv, monkeypatch):+ from scripts import release as release_script+ from scripts.releases import entrypoint++ seen = {}+ monkeypatch.setattr(entrypoint, "cmd_release", lambda args: seen.setdefault("args", args))+ monkeypatch.setattr(release_script.sys, "argv", ["release.py", *argv])++ release_script.main()++ assert seen["args"].no_changelog is True++def test_publish_and_abandon_output_name_the_result():from scripts.releases.entrypoint import abandon_steps, publish_steps