graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Publish releases and betas only after CI passes
Rach Pradhan21b22822a494
diff --git a/.github/workflows/beta-release.yml b/.github/workflows/beta-release.ymlindex c6639456..b6c3147d 100644--- a/.github/workflows/beta-release.yml+++ b/.github/workflows/beta-release.yml@@ -7,6 +7,7 @@ on:permissions:contents: write+ actions: read# Publication is serialized across every release branch. The guard checks the# remote head again after the builds, so queued work cannot revive an old beta.@@ -73,8 +74,25 @@ jobs:path: graff-${{ matrix.target }}.tar.gzif-no-files-found: error+ # Builds run beside CI; nothing is published unless CI passed on this+ # exact push (scripts/wait-for-ci.py).+ ci-gate:+ needs: plan+ if: needs.plan.outputs.build == 'true'+ runs-on: ubuntu-latest+ timeout-minutes: 75+ steps:+ - uses: actions/checkout@v7+ with:+ sparse-checkout: scripts/wait-for-ci.py+ sparse-checkout-cone-mode: false+ - name: Wait for CI on this commit+ env:+ GH_TOKEN: ${{ github.token }}+ run: python3 scripts/wait-for-ci.py --repo "$GITHUB_REPOSITORY" --sha "$GITHUB_SHA" --ref "$GITHUB_REF_NAME"+publish:- needs: [plan, cli]+ needs: [plan, cli, ci-gate]if: needs.plan.outputs.build == 'true'runs-on: ubuntu-lateststeps:diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex a5e51e14..282aa980 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -24,6 +24,9 @@ jobs:- name: Zig source-size guard integrity testsrun: python3 scripts/test-zig-lines.py+ - name: Release CI gate integrity tests+ run: python3 scripts/test-wait-for-ci.py+- name: PTY cleanup integrityrun: python3 scripts/eval/test_pty_cleanup.pydiff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 3dd64968..a4ba27b1 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -20,6 +20,7 @@ on:permissions:contents: write+ actions: readjobs:build:@@ -202,8 +203,23 @@ jobs:security delete-keychain "$RUNNER_TEMP/release.keychain-db" 2>/dev/null || truerm -f "$RUNNER_TEMP/cert.p12" "$RUNNER_TEMP/ac_api_key.p8"+ # Builds run beside CI; nothing is published unless CI passed on this+ # exact push (scripts/wait-for-ci.py).+ ci-gate:+ runs-on: ubuntu-latest+ timeout-minutes: 75+ steps:+ - uses: actions/checkout@v7+ with:+ sparse-checkout: scripts/wait-for-ci.py+ sparse-checkout-cone-mode: false+ - name: Wait for CI on this commit+ env:+ GH_TOKEN: ${{ github.token }}+ run: python3 scripts/wait-for-ci.py --repo "$GITHUB_REPOSITORY" --sha "$GITHUB_SHA" --ref "$GITHUB_REF_NAME"+release:- needs: [build, macos-sign]+ needs: [build, macos-sign, ci-gate]runs-on: ubuntu-lateststeps:- uses: actions/checkout@v7diff --git a/scripts/test-wait-for-ci.py b/scripts/test-wait-for-ci.pynew file mode 100755index 00000000..37e413db--- /dev/null+++ b/scripts/test-wait-for-ci.py@@ -0,0 +1,39 @@+#!/usr/bin/env python3+"""Integrity tests for the CI gate in front of release and beta publication."""++from __future__ import annotations++import importlib.util+from pathlib import Path+import unittest+++SPEC = importlib.util.spec_from_file_location("wait_for_ci", Path(__file__).with_name("wait-for-ci.py"))+gate = importlib.util.module_from_spec(SPEC)+SPEC.loader.exec_module(gate)+++def run(run_id: int, status: str, conclusion: str = "") -> dict:+ return {"databaseId": run_id, "status": status, "conclusion": conclusion, "url": f"u/{run_id}"}+++class WaitForCiTests(unittest.TestCase):+ def test_waits_until_a_run_exists(self) -> None:+ self.assertEqual(gate.verdict([])[0], "wait")++ def test_waits_while_ci_runs(self) -> None:+ self.assertEqual(gate.verdict([run(1, "in_progress")])[0], "wait")+ self.assertEqual(gate.verdict([run(1, "queued")])[0], "wait")++ def test_only_success_passes(self) -> None:+ self.assertEqual(gate.verdict([run(1, "completed", "success")])[0], "pass")+ for conclusion in ("failure", "cancelled", "timed_out", "skipped", ""):+ self.assertEqual(gate.verdict([run(1, "completed", conclusion)])[0], "fail", conclusion)++ def test_newest_run_decides(self) -> None:+ self.assertEqual(gate.verdict([run(2, "completed", "failure"), run(1, "completed", "success")])[0], "fail")+ self.assertEqual(gate.verdict([run(1, "completed", "failure"), run(2, "in_progress")])[0], "wait")+++if __name__ == "__main__":+ unittest.main()diff --git a/scripts/wait-for-ci.py b/scripts/wait-for-ci.pynew file mode 100755index 00000000..a1aa436b--- /dev/null+++ b/scripts/wait-for-ci.py@@ -0,0 +1,69 @@+#!/usr/bin/env python3+"""Hold a publish step until CI passes on the same push.++release.yml and beta-release.yml start alongside the `ci` workflow on the+push that triggers them. Builds run in parallel; only publication waits here.+The run checked is the one for this exact commit and ref (the tag for a+release, the branch for a beta), so a green run elsewhere cannot vouch for it.+A failed or cancelled run blocks publication: re-run the failed CI job, then+re-run the release.+"""++import argparse+import json+import subprocess+import sys+import time+++def verdict(runs):+ """('wait' | 'pass' | 'fail', detail) for the newest matching CI run."""+ if not runs:+ return "wait", "no ci run yet"+ run = max(runs, key=lambda r: r["databaseId"])+ if run["status"] != "completed":+ return "wait", f"ci {run['status']}: {run['url']}"+ if run["conclusion"] == "success":+ return "pass", f"ci passed: {run['url']}"+ return "fail", f"ci {run['conclusion']}: {run['url']}"+++def ci_runs(repo, sha, ref):+ out = subprocess.run(+ ["gh", "run", "list", "--repo", repo, "--workflow", "ci",+ "--commit", sha, "--branch", ref, "--event", "push",+ "--json", "databaseId,status,conclusion,url", "--limit", "20"],+ check=True, capture_output=True, text=True,+ ).stdout+ return json.loads(out)+++def main():+ p = argparse.ArgumentParser()+ p.add_argument("--repo", required=True)+ p.add_argument("--sha", required=True)+ p.add_argument("--ref", required=True)+ p.add_argument("--timeout", type=int, default=60 * 60)+ p.add_argument("--interval", type=int, default=30)+ args = p.parse_args()++ deadline = time.monotonic() + args.timeout+ while True:+ try:+ state, detail = verdict(ci_runs(args.repo, args.sha, args.ref))+ except subprocess.CalledProcessError as err:+ state, detail = "wait", f"gh run list failed: {err.stderr.strip()}"+ print(detail, flush=True)+ if state == "pass":+ return 0+ if state == "fail":+ print("::error::CI did not pass on this commit; nothing was published.", flush=True)+ return 1+ if time.monotonic() >= deadline:+ print("::error::Timed out waiting for CI; nothing was published.", flush=True)+ return 1+ time.sleep(args.interval)+++if __name__ == "__main__":+ sys.exit(main())