Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Use automatic PR CI for direct merges without requiring a queue (#1004)

Dee5491aaa68171
diff --git a/AGENTS.md b/AGENTS.md
index df11fafa5..e785f2cbb 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -34,9 +34,16 @@ For product names, terminology, and visible copy, follow the
Do the code review while CI runs, and keep review independent of implementation.
- Base the branch on current `main`. A branch older than #991 runs the old
planner and fails `ci/required`; use **Update branch** or rebase first.
- - Merge with `make merge-pr ARGS="N --queue --reviewed-head SHA --reviewed-base SHA --merge"`.
- The queue reruns only the plan and process checks. Do not use `--run/--scope`
- (legacy direct mode). Never replay an uncertain enqueue or merge; inspect the PR.
+ - Merge with `make merge-pr ARGS="N --reviewed-head SHA --reviewed-base SHA --merge"`.
+ It verifies automatic `ci/required` evidence and directly squash-merges the
+ reviewed head. A merge queue is not a prerequisite for merging or releasing;
+ do not add `--queue` or ask for queue setup. The helper respects a queue only
+ if GitHub actually requires it. Do not use `--run/--scope` for ordinary merges
+ (legacy manual evidence). Never replay an uncertain merge; inspect the PR.
+ If another merge advances `main`, fetch and integrate it, review the combined
+ change, reuse unchanged validation and run only newly affected checks. Then
+ continue the authorized merge without another permission question. Do not
+ toggle repository rules based on how many PRs or CI jobs are running.
- Do not start extra runs for a PR: no manual **CI → Run workflow** while its
automatic run exists, no repeated pushes to retrigger a red check. Read the
failure, fix it, push once. Rerun a job only for a recorded flaky test.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 7013c72b3..3aabc5560 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -176,10 +176,11 @@ Security reports go through [SECURITY.md](SECURITY.md).
4. **Review together.** A maintainer checks the change while automatic CI selects complete
component suites from its Git diff. Native, browser, real-engine and hardware acceptance
still need the checks relevant to the change; report those separately.
-5. **Merge and release.** Reviewed PRs enter the merge queue, which validates them with current
- `main` and changes ahead in the queue before squash merging. Rebase to resolve conflicts;
- ordinary main movement does not require another manual validation/rebase cycle. Harness
- catalog changes publish after merge; app, CLI and firmware releases keep their schedules.
+5. **Merge and release.** After review and required checks pass, squash-merge the reviewed PR
+ with the [merge helper](docs/validation-and-release.md#merge-an-already-reviewed-pr).
+ No merge queue is required. If `main` moved, inspect and integrate its changes, reusing
+ validation where the tested inputs still match. Harness catalog changes publish after
+ merge; app, CLI and firmware releases keep their schedules.
## Conventions across this repository
diff --git a/docs/validation-and-release.md b/docs/validation-and-release.md
index 16c84e042..25c28f704 100644
--- a/docs/validation-and-release.md
+++ b/docs/validation-and-release.md
@@ -41,8 +41,9 @@ PR CI is deliberately fast. Each changed component runs only its own Linux suite
`plan` (actionlint and suite selection), `process-checks` and `ci/required` always
run; `ci/required` is the only required check. On a draft PR only those three run
and `ci/required` stays blocked; marking the PR ready runs the component checks.
-Merge-queue runs rerun only the three always-on jobs (about 2 minutes): the PR run
-already tested the change.
+Normal merges directly squash the reviewed head after successful PR CI. If GitHub
+requires a merge queue, its runs rerun only the three always-on jobs (about 2 minutes):
+the PR run already tested the change. Queue setup is not required to merge or release.
The `plan` and `ci/required` jobs run `scripts/ci-plan.py` from the PR head. A branch
created before #991 still carries the old planner, which expects removed jobs and
@@ -310,7 +311,7 @@ and rerun only validation invalidated by the merge. Native checks absent from CI
still need their own evidence.
Prepare the PR description and review the diff while CI is running. For a normal
-merge you need nothing more: `make merge-pr --queue` collects and verifies the
+merge you need nothing more: `make merge-pr` collects and verifies the
`ci/required` receipt itself. The collector below is for manual runs only, and its
`cli` and `desktop` scopes still expect the job set from before #991, so they fail
on current runs; `process` still works. To collect a manual run's record:
@@ -449,22 +450,37 @@ until they disappear.
After independent code review, required non-CI acceptance and merge authorization:
```bash
-make merge-pr ARGS="PR_NUMBER --queue --reviewed-head HEAD_SHA --reviewed-base REVIEW_BASE_SHA --merge --wait-timeout 1800"
+make merge-pr ARGS="PR_NUMBER --reviewed-head HEAD_SHA --reviewed-base REVIEW_BASE_SHA --merge --wait-timeout 1800"
```
-The checkout must be clean at the exact reviewed head and include the review-base
-commit. Main may advance after that review. The helper verifies successful automatic
-PR CI, enqueues with GitHub's `expectedHeadOid`, follows the same PR and verifies
-that its merged full tree matches successful `merge_group` CI and its immutable gate
-receipt. It retains source, run, attempt, artifact digest and phase timings under
-`.harness/validation/*-merge-*/`. Omit `--merge` for a read-only queue preview.
-
-Queue rejection, a changed head/target, missing coverage, failed/skipped required
-jobs or a lost response cannot report success. An uncertain enqueue is inspected
-without replaying the mutation. If the wait budget expires, follow that same queued
-PR; do not start another validation or merge request. GitHub enforces the required
-check and the queue. Do not use `--run/--scope`: that legacy direct mode depends on
-the collector's pre-#991 job lists.
+The checkout must be clean at the exact reviewed head and include the reviewed
+`main` commit. The helper follows the latest automatic PR CI for that head, verifies
+its immutable `ci/required` receipt, rechecks the source and GitHub mergeability,
+then directly squash-merges with the exact reviewed head. It verifies that the
+merged full tree matches the reviewed and tested tree. It retains source, run,
+attempt, artifact digest and phase timings under `.harness/validation/*-merge-*/`.
+Omit `--merge` for a read-only preview.
+
+A merge queue is not a prerequisite for merging or releasing. Do not add `--queue`
+to ordinary commands or stop an authorized merge to request queue setup. If GitHub
+actually enforces a queue, the helper detects its rule and uses it, verifying the
+merged tree against successful candidate CI. Explicit `--queue` is only for an
+intentionally configured queue, such as a disposable integration trial.
+
+If `main` moved before a direct merge, inspect and integrate the new source, then
+supply the updated reviewed head/base. Reuse validation only for unchanged inputs;
+rerun checks affected by the integration. This is routine handling of concurrent
+merges: continue the user's already-authorized merge without asking for permission
+again. A quiet branch takes the direct path immediately after checks and review;
+concurrent changes require only the additional review and validation they affect.
+Do not enable or disable a queue based on the number of open PRs or running jobs.
+
+A changed head/target, missing coverage,
+failed/skipped required jobs or a lost response cannot report success. Inspect an
+uncertain merge or enqueue without replaying the mutation. If a wait expires,
+follow the same run or queued PR; do not start another validation or merge request.
+Do not use `--run/--scope` for normal merges: that legacy manual-evidence mode
+depends on the collector's pre-#991 job lists.
## Automatic CI and rollout
@@ -483,10 +499,10 @@ reads, say so in the PR and run that component's tests locally or with
**CI → Run workflow** (`scope=desktop`, `tui`, `companions` or `mobile`).
Separate PR groups prevent cross-cancellation, but still share available runner
-capacity. Related branches validate independently; the merge queue validates
-their combined source before integration. Keep PRs small and coordinate edits to
-shared interfaces and frequently changed files. Main background validation may
-coalesce pending snapshots; distinct merge candidates must not share that group.
+capacity. Related branches validate independently. Keep PRs small, inspect changes
+from `main` before direct integration, and coordinate edits to shared interfaces
+and frequently changed files. Main background validation may coalesce pending
+snapshots; any configured queue's distinct candidates must not share that group.
The stable `ci/required` job runs even after an upstream failure. It accepts only
successful selected jobs. Deliberately inapplicable jobs may be skipped; a required
@@ -494,14 +510,10 @@ skip, cancellation, failure or missing result fails integration. Manual `full`
selects the five core suites; `all` selects every suite. Manual dispatch is extra
evidence and cannot substitute for the automatic PR gate.
-Enable main's queue only after passing automatic CI and a disposable-branch queue
-trial. Start with three candidate builds, squash, ALLGREEN, a minimum of one PR and
-no batch accumulation delay. Check timeout is 60 minutes to permit required slower
-component work. Required checks are non-strict on the PR branch because the queue
-validates current main. Require PRs and resolved discussions, preserving the existing
-approval count instead of inventing a new human-review bottleneck. Preserve main's
-delete/force-push guards. Queue jumping invalidates work and is reserved for urgent
-integration. The queue's merge limits do not batch its CI builds.
+Do not enable or change repository protection rules as part of an ordinary merge
+or release. Preserve configured PR, discussion, approval, deletion and force-push
+rules. Optional queue rollout is separate repository administration, not a step
+agents must complete before shipping a reviewed change.
New revisions replace active checks for the same PR, job and matrix row. Cancellation
locks belong to work jobs, leaving summaries and the always-running final gate independent: an obsolete
@@ -526,6 +538,6 @@ time. Investigate/revert confirmed main regressions promptly. Preserve explicit
and incomplete-suite reporting; do not retry assertions until they disappear.
Release publication and Desktop prepared-package reuse retain their existing
-source/evidence, signing and artifact contracts. Release admission based on automatic
-candidate receipts is a subsequent rollout step after the queue is stable; no release
-workflow is bypassed by this integration change.
+source/evidence, signing and artifact contracts. They do not depend on a merge
+queue or queue rollout. After the authorized merge, follow the component's normal
+release workflow and verify its published artifacts.
diff --git a/scripts/merge-validated-pr.py b/scripts/merge-validated-pr.py
index 52cc86f2b..076b8bfc0 100644
--- a/scripts/merge-validated-pr.py
+++ b/scripts/merge-validated-pr.py
@@ -18,6 +18,10 @@ spec = importlib.util.spec_from_file_location("ci_evidence", Path(__file__).with
ci = importlib.util.module_from_spec(spec)
spec.loader.exec_module(ci)
+queue_spec = importlib.util.spec_from_file_location("queue_merge", Path(__file__).with_name("queue-validated-pr.py"))
+queue = importlib.util.module_from_spec(queue_spec)
+queue_spec.loader.exec_module(queue)
+
def git(root, *args):
return subprocess.check_output(["git", *args], cwd=root, stderr=subprocess.PIPE, timeout=15, text=True).strip()
@@ -79,6 +83,7 @@ def finish(client, root, number, run_id, scope, head, base, output, *, merge=Fal
pr=number, run_id=run_id, scope=scope, reviewed_head=head, reviewed_base=base,
merge_authorized=merge, started_at=ci.utc_now(), status="not_merged", phases={})
evidence = None
+ automatic = run_id is None and scope is None
def save():
temporary = output / "receipt.tmp"
@@ -98,17 +103,32 @@ def finish(client, root, number, run_id, scope, head, base, output, *, merge=Fal
try:
client.deadline = time.monotonic() + timeout
record["reviewed_source"] = phase("preflight", lambda: preflight(client, root, number, head, base))
+ if automatic:
+ run = phase("find_automatic_ci", lambda: queue.pr_run(client, head))
+ record["run_id"] = run_id = run["id"]
client.deadline = time.monotonic() + wait_timeout
observed = phase("waiting", lambda: ci.wait_for_run(client, run_id))
client.deadline = time.monotonic() + timeout
evidence_dir = output / "ci"
evidence_dir.mkdir()
- evidence = phase("collection", lambda: ci.collect(client, root, run_id, scope, head,
- evidence_dir, number, expected_run=observed))
- (evidence_dir / "receipt.json").write_text(json.dumps(evidence, indent=2) + "\n")
- (evidence_dir / "validation.md").write_text(ci.markdown(evidence))
- if evidence["status"] != "passed":
- raise ValueError("CI evidence requires source review; no merge requested")
+ if automatic:
+ evidence = phase("collection", lambda: queue.gate_evidence(client, observed, evidence_dir))
+ record["pr_evidence"] = evidence
+ if (evidence["source_sha"] != head
+ or evidence["source_tree"] != record["reviewed_source"]["tree"]):
+ raise ValueError("automatic CI does not cover the reviewed source")
+ latest = queue.pr_run(client, head)
+ if latest["id"] != run_id or latest["run_attempt"] != observed["run_attempt"]:
+ raise ValueError("automatic PR CI changed during verification; follow the latest run")
+ tested_tree = evidence["source_tree"]
+ else:
+ evidence = phase("collection", lambda: ci.collect(client, root, run_id, scope, head,
+ evidence_dir, number, expected_run=observed))
+ (evidence_dir / "receipt.json").write_text(json.dumps(evidence, indent=2) + "\n")
+ (evidence_dir / "validation.md").write_text(ci.markdown(evidence))
+ if evidence["status"] != "passed":
+ raise ValueError("CI evidence requires source review; no merge requested")
+ tested_tree = evidence["source"]["tested_tree"]
if phase("final_source_check", lambda: preflight(client, root, number, head, base, ready=True)) != record["reviewed_source"]:
raise ValueError("reviewed source changed before merge")
record["status"] = "ready"
@@ -127,8 +147,7 @@ def finish(client, root, number, run_id, scope, head, base, output, *, merge=Fal
# Inspection gets a fresh bounded budget even if the write timed out.
client.deadline = time.monotonic() + min(timeout, 30)
record["merge"] = phase("verification", lambda: confirm_merge(
- client, number, head, evidence["source"]["target_tree"], response,
- tested_tree=evidence["source"]["tested_tree"]))
+ client, number, head, record["reviewed_source"]["tree"], response, tested_tree=tested_tree))
record["status"] = "merged" if record["merge"]["same_reviewed_tree"] else "merged_source_review_required"
except (OSError, RuntimeError, ValueError, KeyError, TypeError, subprocess.SubprocessError, ci.zipfile.BadZipFile) as error:
record["error"] = str(error)
@@ -144,7 +163,10 @@ def finish(client, root, number, run_id, scope, head, base, output, *, merge=Fal
lines.append(f"Merged commit `{result['commit']}`; reviewed target tree matches: `{result['same_reviewed_tree']}`; "
f"full tested tree matches: `{result['same_tested_tree']}`.")
if evidence is not None:
- lines += ["", ci.markdown(evidence)]
+ if automatic:
+ lines += ["", f"Verified [automatic PR CI]({evidence['url']}) for `{evidence['source_sha']}`."]
+ else:
+ lines += ["", ci.markdown(evidence)]
(output / "merge.md").write_text("\n".join(lines) + "\n")
return record
@@ -152,9 +174,9 @@ def finish(client, root, number, run_id, scope, head, base, output, *, merge=Fal
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("pr", type=int)
- parser.add_argument("--run", type=int, help="required for legacy direct merging; queue mode follows automatic CI")
- parser.add_argument("--scope", choices=ci.SCOPES, help="required for legacy direct merging")
- parser.add_argument("--queue", action="store_true", help="enqueue and verify the tested merge candidate")
+ parser.add_argument("--run", type=int, help="legacy manual-run evidence; normally follows automatic PR CI")
+ parser.add_argument("--scope", choices=ci.SCOPES, help="required only with legacy --run")
+ parser.add_argument("--queue", action="store_true", help="explicitly use an available merge queue; not required for ordinary merges")
parser.add_argument("--base-branch", default="main", help="queue target; use a disposable branch for rollout trials")
parser.add_argument("--reviewed-head", required=True, help="full commit SHA already reviewed, including required non-CI checks")
parser.add_argument("--reviewed-base", required=True, help="full main SHA included in the reviewed head")
@@ -173,19 +195,16 @@ def main():
root = Path(git(Path.cwd(), "rev-parse", "--show-toplevel")).resolve()
output = args.output or root / ".harness/validation" / (datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%S.%fZ") + f"-merge-{args.pr}")
client = ci.Client(args.repo, time.monotonic() + args.timeout)
- # Existing commands transparently use the queue once the target's rule is
- # active. An explicit --queue supports testing before main is enforced.
+ # Ordinary merges use automatic PR CI directly. Respect an actual queue
+ # rule without making queue setup a prerequisite for every repository.
rules = client.api(f"rules/branches/{args.base_branch}")
queued = args.queue or any(rule.get("type") == "merge_queue" for rule in rules)
if queued:
- queue_spec = importlib.util.spec_from_file_location("queue_merge", Path(__file__).with_name("queue-validated-pr.py"))
- queue = importlib.util.module_from_spec(queue_spec)
- queue_spec.loader.exec_module(queue)
record = queue.finish(client, root, args.pr, args.reviewed_head, args.reviewed_base, output,
merge=args.merge, wait_timeout=args.wait_timeout, timeout=args.timeout, branch=args.base_branch)
else:
- if args.run is None or args.scope is None or args.base_branch != "main":
- parser.error("direct merging requires --run, --scope and main; use --queue for queued integration")
+ if (args.run is None) != (args.scope is None) or args.base_branch != "main":
+ parser.error("direct merging targets main; supply --run and --scope together only for legacy manual evidence")
record = finish(client, root, args.pr, args.run, args.scope, args.reviewed_head,
args.reviewed_base, output, merge=args.merge, wait_timeout=args.wait_timeout, timeout=args.timeout)
print(f"{record['status']}: {output / 'merge.md'}")
diff --git a/scripts/queue-validated-pr.py b/scripts/queue-validated-pr.py
index 747d04685..66c96339e 100644
--- a/scripts/queue-validated-pr.py
+++ b/scripts/queue-validated-pr.py
@@ -87,12 +87,17 @@ def gate_evidence(client, run, output):
suites=receipt["suites"], artifact_id=artifact["id"], artifact_digest=artifact["digest"])
-def pr_gate(client, head, output):
+def pr_run(client, head):
runs = client.pages("actions/workflows/ci.yml/runs?event=pull_request&head_sha=" + head, "workflow_runs")
- candidates = sorted((r for r in runs if r.get("head_sha") == head), key=lambda r: r["id"], reverse=True)
+ candidates = sorted((r for r in runs if r.get("head_sha") == head and r.get("event") == "pull_request"),
+ key=lambda r: r["id"], reverse=True)
if not candidates:
raise ValueError("automatic CI has not run for the reviewed PR head")
- return gate_evidence(client, candidates[0], output)
+ return candidates[0]
+
+
+def pr_gate(client, head, output):
+ return gate_evidence(client, pr_run(client, head), output)
def merged_gate(client, tree, branch, started_at, output):
diff --git a/scripts/tests/test_merge_validated_pr.py b/scripts/tests/test_merge_validated_pr.py
index dd599df63..263bd2797 100644
--- a/scripts/tests/test_merge_validated_pr.py
+++ b/scripts/tests/test_merge_validated_pr.py
@@ -1,11 +1,14 @@
import copy
+import hashlib
import importlib.util
+import io
import json
from pathlib import Path
import subprocess
import tempfile
import unittest
from unittest import mock
+import zipfile
spec = importlib.util.spec_from_file_location("merge_pr", Path(__file__).resolve().parents[1] / "merge-validated-pr.py")
merger = importlib.util.module_from_spec(spec)
@@ -43,12 +46,82 @@ class MergeTests(unittest.TestCase):
self.addCleanup(patcher.stop)
return value
- def finish(self, merge=True):
- result = merger.finish(self.client, self.root, 5, 123, "process", self.head, self.base,
+ def finish(self, merge=True, automatic=False):
+ self.client.required_gate = automatic
+ result = merger.finish(self.client, self.root, 5, None if automatic else 123,
+ None if automatic else "process", self.head, self.base,
self.output, merge=merge)
self.assertEqual(json.loads((self.output / "receipt.json").read_text()), result)
return result
+ def test_automatic_pr_gate_merges_without_queue_or_legacy_job_inventory(self):
+ self.patch(merger.ci, "collect", side_effect=AssertionError("legacy collector must not run"))
+ result = self.finish(automatic=True)
+ self.assertEqual(result["status"], "merged")
+ self.assertEqual(result["run_id"], 123)
+ self.assertEqual(result["pr_evidence"]["source_sha"], self.head)
+ self.assertTrue(result["merge"]["same_tested_tree"])
+ self.assertEqual(len(self.client.writes), 1)
+ self.assertIn("sha=" + self.head, self.client.writes[0])
+ self.assertTrue((self.output / "ci/ci-required.zip").is_file())
+ self.assertIn("automatic PR CI", (self.output / "merge.md").read_text())
+
+ def test_automatic_preview_verifies_the_gate_without_merging(self):
+ self.assertEqual(self.finish(merge=False, automatic=True)["status"], "ready")
+ self.assertEqual(self.client.writes, [])
+
+ def test_failed_automatic_ci_or_missing_gate_cannot_merge(self):
+ self.client.run["conclusion"] = "failure"
+ self.assertEqual(self.finish(automatic=True)["status"], "not_merged")
+ self.output = self.output.with_name("missing-gate")
+ self.client.run["conclusion"] = "success"
+ self.client.gate_jobs = []
+ result = self.finish(automatic=True)
+ self.assertIn("required CI gate did not pass", result["error"])
+ self.assertEqual(self.client.writes, [])
+
+ def test_manual_ci_cannot_replace_automatic_pr_ci(self):
+ self.client.run["event"] = "workflow_dispatch"
+ result = self.finish(automatic=True)
+ self.assertEqual(result["status"], "not_merged")
+ self.assertIn("automatic CI has not run", result["error"])
+ self.assertEqual(self.client.writes, [])
+
+ def test_automatic_gate_must_cover_the_local_reviewed_tree(self):
+ self.client.tested_tree = "e" * 40
+ result = self.finish(automatic=True)
+ self.assertEqual(result["status"], "not_merged")
+ self.assertIn("does not cover the reviewed source", result["error"])
+ self.assertEqual(self.client.writes, [])
+
+ def test_superseded_automatic_run_or_attempt_cannot_authorize_merge(self):
+ for change in [dict(id=124), dict(run_attempt=2)]:
+ self.client = FakeClient(self)
+ self.client.superseding_run = dict(self.client.run, **change)
+ self.output = self.output.with_name("superseded-" + next(iter(change)))
+ with self.subTest(change=change):
+ result = self.finish(automatic=True)
+ self.assertEqual(result["status"], "not_merged")
+ self.assertIn("CI changed during verification", result["error"])
+ self.assertEqual(self.client.writes, [])
+
+ def test_default_command_uses_direct_merge_unless_github_requires_queue(self):
+ direct = self.patch(merger, "finish", return_value={"status": "ready"})
+ queued = self.patch(merger.queue, "finish", return_value={"status": "ready_for_queue"})
+ self.patch(merger, "git", return_value=str(self.root))
+ self.patch(merger.ci, "Client", return_value=self.client)
+ self.patch(merger.sys, "argv", new=["merge-validated-pr.py", "5", "--reviewed-head", self.head,
+ "--reviewed-base", self.base])
+ self.patch(merger, "print", create=True)
+ self.assertEqual(merger.main(), 0)
+ self.assertEqual(direct.call_args.args[2:5], (5, None, None))
+ queued.assert_not_called()
+ direct.reset_mock()
+ self.client.rules = [{"type": "merge_queue"}]
+ self.assertEqual(merger.main(), 0)
+ queued.assert_called_once()
+ direct.assert_not_called()
+
def test_preview_verifies_full_evidence_without_mutating_github(self):
result = self.finish(merge=False)
self.assertEqual(result["status"], "ready")
@@ -208,18 +281,25 @@ class FakeClient:
self.deadline, self.run_reads = 0, 0
self.writes, self.behavior = [], "success"
self.merged_sha, self.merged_tree = "c" * 40, fixture.tree
+ self.tested_tree = fixture.tree
+ self.required_gate, self.run_list_reads, self.superseding_run = False, 0, None
+ self.rules = []
self.pr = dict(number=5, state="open", draft=False, merged=False, mergeable=True, mergeable_state="clean",
html_url="https://github.com/owner/repo/pull/5", head=dict(sha=fixture.head),
base=dict(sha=fixture.base, ref="main", repo=dict(full_name=self.repository)))
self.run = dict(id=123, repository=dict(full_name=self.repository), path=".github/workflows/ci.yml",
+ event="pull_request",
head_sha=fixture.head, run_attempt=1, status="completed", conclusion="success",
html_url="https://github.com/owner/repo/actions/runs/123",
created_at="2026-10-03T00:00:00Z", updated_at="2026-10-03T00:01:00Z")
self.jobs = [dict(id=1, name="process-checks", run_id=123, run_attempt=1, head_sha=fixture.head,
status="completed", conclusion="success", steps=[],
started_at="2026-10-03T00:00:01Z", completed_at="2026-10-03T00:01:00Z")]
+ self.gate_jobs = [dict(self.jobs[0], name="ci/required")]
def api(self, path):
+ if path == "rules/branches/main":
+ return copy.deepcopy(self.rules)
if path == "pulls/5":
return copy.deepcopy(self.pr)
if path == "git/ref/heads/main":
@@ -229,13 +309,36 @@ class FakeClient:
return copy.deepcopy(self.run)
if path == f"git/commits/{self.merged_sha}":
return dict(sha=self.merged_sha, tree=dict(sha=self.merged_tree), parents=[dict(sha=self.actual_base)])
+ if path == f"git/commits/{self.fixture.head}":
+ return dict(sha=self.fixture.head, tree=dict(sha=self.tested_tree))
raise AssertionError(path)
def pages(self, path, key):
+ if key == "workflow_runs":
+ self.run_list_reads += 1
+ return [copy.deepcopy(self.superseding_run if self.run_list_reads > 1 and self.superseding_run else self.run)]
+ if self.required_gate:
+ if key == "jobs":
+ return copy.deepcopy(self.gate_jobs)
+ if key == "artifacts":
+ receipt = dict(schema=1, kind="ci-required", status="passed", source_sha=self.fixture.head,
+ source_tree=self.tested_tree, event="pull_request", run_id=123, run_attempt=1,
+ suites=[], required_jobs=["process-checks"],
+ results={"plan": "success", "process-checks": "success"})
+ buf = io.BytesIO()
+ with zipfile.ZipFile(buf, "w") as bundle:
+ bundle.writestr("ci-required.json", json.dumps(receipt))
+ self.archive = buf.getvalue()
+ return [dict(id=20, name="ci-required", expired=False, size_in_bytes=len(self.archive),
+ workflow_run=dict(id=123, head_sha=self.fixture.head),
+ digest="sha256:" + hashlib.sha256(self.archive).hexdigest())]
assert key in {"jobs", "artifacts"}, key
return copy.deepcopy(self.jobs) if key == "jobs" else []
def command(self, *args, binary=False):
+ if binary:
+ assert args == ("api", "repos/owner/repo/actions/artifacts/20/zip")
+ return self.archive
self.writes.append(args)
before = json.loads((self.fixture.output / "receipt.json").read_text())
assert before["status"] == "merge_requested" and before["reviewed_head"] == self.fixture.head