block-ci: refuse only control changes the PR itself makes

The two-dot diff against current master listed every block workflow master
changed after the PR branched, so an older docs-only PR hit
workflow_review_required for good. Diff from the merge base; the gate
already requires the tested base to be current master.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 committed 2026-12-05 04:07:45 -08:00
1 parent eec9517c87
commit 25afda36b0
2 files changed
+12 -1

No files matched your search

@@ -183,6 +183,15 @@ class PortTests(unittest.TestCase):
head = git("rev-parse", "HEAD").decode().strip()
with patch.object(check.subprocess, "check_output", side_effect=lambda args, **kw: real_output(args, cwd=root, **kw)):
check.check_control_paths(base, head)
git("checkout", "-q", "-b", "master-later", base)
(root / ".github/workflows").mkdir(parents=True, exist_ok=True)
(root / ".github/workflows/block-test.yml").write_text("master control")
git("add", "."); git("commit", "-m", "master control")
master = git("rev-parse", "HEAD").decode().strip()
with patch.object(check.subprocess, "check_output", side_effect=lambda args, **kw: real_output(args, cwd=root, **kw)):
check.check_control_paths(master, head)
with self.assertRaisesRegex(ValueError, "workflow_review_required"):
check.check_control_paths(head, master)
with patch.object(check, "check_control_paths", side_effect=ValueError("workflow_review_required")), patch.object(check.subprocess, "check_output", side_effect=["base", "head"]), patch.object(check.subprocess, "run") as run:
with self.assertRaisesRegex(ValueError, "workflow_review_required"):
check.local_checks({"number": 1, "body": "body", "title": "title", "head": {"sha": "head"}}, "base")
+3 -1
View File
@@ -46,7 +46,9 @@ def successful_run(pr, current):
def check_control_paths(base, head):
# Inspect both sides of renames and fail on enumeration errors. These PRs
# need independent workflow review; their own Actions results cannot waive it.
paths = subprocess.check_output(["git", "diff", "--no-renames", "--name-only", "-z", base, head]).split(b"\0")
# Diff from the merge base: master's later control changes are not the PR's,
# and the tested merge commit already ran them.
paths = subprocess.check_output(["git", "diff", "--no-renames", "--name-only", "-z", base + "..." + head]).split(b"\0")
controls = [p.decode("utf-8", errors="replace") for p in paths if p.startswith((b".github/workflows/", b".github/block/", b".github/dockerfiles/block-", b"seaweed-block/.github/"))]
if controls:
raise ValueError("workflow_review_required: CI controls changed: " + ", ".join(controls))