diff --git a/.github/block/scripts/block-ci-port-test.py b/.github/block/scripts/block-ci-port-test.py index 976b854a74..b79fee5c8d 100644 --- a/.github/block/scripts/block-ci-port-test.py +++ b/.github/block/scripts/block-ci-port-test.py @@ -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") diff --git a/.github/block/scripts/safe-merge-check.py b/.github/block/scripts/safe-merge-check.py index e87d0df48e..28040608e7 100644 --- a/.github/block/scripts/safe-merge-check.py +++ b/.github/block/scripts/safe-merge-check.py @@ -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))