Skip to content
This repository was archived by the owner on Nov 25, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/candidate-pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Keeps exactly one acceptance PR next -> main open while next holds unreleased commits.
# Keeps exactly one acceptance PR next -> main open while next holds unreleased commits. The merge commits
# of sync-main-to-next do not count: without other commits there is no RC tag and no candidate PR.
# Per push to next: RC tag, preview (deployment / TestPyPI / build artifact), screenshots,
# PR body (changes, preview link, test script from the feature PRs, screenshots), milestone.
# Auto-merge (merge commit) is enabled; candidate-approval stays red until the owner approves the head.
Expand Down Expand Up @@ -52,7 +53,7 @@ jobs:
GH_TOKEN: ${{ steps.app.outputs.token }}
run: |
git fetch --quiet --tags origin main next
count=$(git rev-list --count origin/main..origin/next)
count=$(python3 "$GOV/scripts/release_tools.py" unreleased-count)
echo "count=$count" >> "$GITHUB_OUTPUT"
pr=$(gh pr list --repo "$GITHUB_REPOSITORY" --base main --head next --state open --json number,isCrossRepository --jq '[.[] | select(.isCrossRepository | not)][0].number // empty')
echo "pr=$pr" >> "$GITHUB_OUTPUT"
Expand Down
2 changes: 1 addition & 1 deletion ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Branch and release model per project repository: `main` is released, `next` coll

- Issue → triage (small model) → owner applies `po:ready` → po-ready-gate verifies the actor in the issue timeline → nightly roadmap pre-filter picks one issue → implementer PR.
- Push to `main` → release-please (release PR auto-merges; minor/major only after an owner-accepted candidate) → docs to Pages, deploy, smoke test, automatic rollback to the previous tag; plus sync PR `main → next` (merge commit).
- Push to `next` → RC tag, preview (deployment, TestPyPI or build artifact), screenshots, candidate PR with changes, preview link, test script from the feature PRs → owner approves the current head → merge commit → minor release.
- Push to `next` with commits `main` lacks (sync merges do not count; without any, an open candidate PR is closed) → RC tag, preview (deployment, TestPyPI or build artifact), screenshots, candidate PR with changes, preview link, test script from the feature PRs → owner approves the current head → merge commit → minor release.
- Schedule → pre-filters (`scripts/housekeeping.py`) → Claude only when a tool found something; audit, cleanup and fuzzing need no model.
- Fork PR → scheduled pre-qualification (`po:review`) → owner approval (roadmap decision) → Claude ports it with co-author credit and closes the fork PR.

Expand Down
13 changes: 13 additions & 0 deletions scripts/release_tools.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
"""Release helpers for the reusable workflows.

unreleased-count number of commits on next that main lacks, sync merges excluded
rc-version next release-candidate version for the current next branch (vX.Y.Z-rc.N)
version-smoke run the profile's version command and require the expected version in its output
previous-tag stable tag released before the given tag (rollback target)
Expand Down Expand Up @@ -123,11 +124,21 @@ def accepted_candidate(merged_candidates: list[dict], reviews_by_pr: dict[int, l
return None


def unreleased_count(repo_dir: str = ".", base: str = "origin/main", head: str = "origin/next") -> int:
"""Non-merge commits on head that base lacks. The merge commits of sync-main-to-next carry nothing to release."""
return int(govlib.git("rev-list", "--count", "--no-merges", f"{base}..{head}", cwd=repo_dir) or 0)


def git_tags(repo_dir: str) -> list[str]:
govlib.run(["git", "fetch", "--tags", "--quiet", "origin"], cwd=repo_dir)
return [t for t in govlib.git("tag", "--list", cwd=repo_dir).splitlines() if t]


def cmd_unreleased_count(args) -> int:
print(unreleased_count(args.repo_dir))
return 0


def cmd_rc_version(args) -> int:
subjects = govlib.git("log", "--no-merges", "--format=%s", "origin/main..origin/next", cwd=args.repo_dir).splitlines()
version = next_rc(git_tags(args.repo_dir), subjects)
Expand Down Expand Up @@ -221,6 +232,7 @@ def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("--repo-dir", default=".")
sub = parser.add_subparsers(dest="cmd", required=True)
sub.add_parser("unreleased-count")
sub.add_parser("rc-version")
vs = sub.add_parser("version-smoke")
vs.add_argument("--expected")
Expand All @@ -240,6 +252,7 @@ def main(argv: list[str] | None = None) -> int:
rg.add_argument("--pr", required=True, type=int)
args = parser.parse_args(argv)
return {
"unreleased-count": cmd_unreleased_count,
"rc-version": cmd_rc_version,
"version-smoke": cmd_version_smoke,
"previous-tag": cmd_previous_tag,
Expand Down
20 changes: 19 additions & 1 deletion tests/test_release_tools.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import unittest

from helpers import ROOT
from helpers import ROOT, git, make_repo
import install
import release_tools as rt
import set_version
Expand Down Expand Up @@ -90,6 +90,24 @@ def test_set_version(self):
self.assertIn('version = "1.1.0"', text)
self.assertIn('version = "9"', text)

def test_unreleased_count_ignores_sync_merges(self):
tmp, root = make_repo({"a.txt": "a"})
self.addCleanup(tmp.cleanup)
git(root, "branch", "next")
(root / "a.txt").write_text("fix", encoding="utf-8")
git(root, "commit", "-qam", "fix: on main")
git(root, "switch", "-q", "next")
git(root, "merge", "-q", "--no-ff", "-m", "chore: sync main into next", "main")
self.assertEqual(rt.unreleased_count(str(root), "main", "next"), 0)
(root / "b.txt").write_text("feat", encoding="utf-8")
git(root, "add", "b.txt")
git(root, "commit", "-qm", "feat: on next")
git(root, "switch", "-q", "main")
git(root, "commit", "-q", "--allow-empty", "-m", "fix: second")
git(root, "switch", "-q", "next")
git(root, "merge", "-q", "--no-ff", "-m", "chore: sync main into next", "main")
self.assertEqual(rt.unreleased_count(str(root), "main", "next"), 1)


if __name__ == "__main__":
unittest.main()
9 changes: 9 additions & 0 deletions tests/test_repo_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@ def test_caller_names_cover_all_templates(self):
self.assertEqual(len(install.caller_names("private")), 6)
self.assertEqual(len(install.caller_names("public")), 7)

def test_candidate_counts_without_sync_merges(self):
# Sync merges main -> next must not produce an RC tag or a candidate PR.
steps = load(WF / "candidate-pr.yml")["jobs"]["candidate"]["steps"]
state = next(s for s in steps if s.get("id") == "state")
self.assertIn('release_tools.py" unreleased-count', state["run"])
self.assertIn("gh pr close", state["run"])
tag = next(s for s in steps if s.get("name") == "Tag release candidate")
self.assertEqual(tag["if"], "steps.state.outputs.count != '0'")

def test_third_party_actions_are_sha_pinned(self):
# Scorecard Pinned-Dependencies; the comment keeps the version readable and lets Dependabot update it.
for path in sorted(WF.glob("*.yml")) + sorted((ROOT / "callers").glob("*.yml")):
Expand Down