fix(ci): match the privileged run of a fork PR by its number as well

The wait job picks the newest privileged run on the head commit of the
PR. Two fork PRs that share a head repository, branch and commit but
target different bases each start such a run, and the commit alone cannot
tell them apart. A failed run of the other PR would then end the wait of
this one while its images are still being built.

The run name of the workflow carries the PR number, so the match now
requires it next to the head commit. A run without that name matches
nothing, and the wait does what it does whenever no run is found: it
keeps polling for the images until they exist or the wait times out.

Raised by the CodeRabbit review of this PR.

Refs #784

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-10-05 12:07:14 +02:00
1 parent 22129c2d5a
commit 7c7b895ae9
2 files changed
+30

No files matched your search

@@ -11,6 +11,7 @@ from utils.cache.files import PROJECT_ROOT
SCRIPT = PROJECT_ROOT / "scripts" / "meta" / "wait" / "images.sh"
HEAD_SHA = "5b002678df222f1095fae2f42e3bb10964adb8ef"
RUN_TITLE = "pull_request_target / PR #1 / synchronize / fork:branch"
STUBS = {
"docker": '#!/usr/bin/env bash\n[[ -e "${STUB_DIR}/images-ready" ]]\n',
"gh": (
@@ -96,6 +97,7 @@ class TestWaitForImages(unittest.TestCase):
"conclusion": "failure",
"created_at": "2026-10-04T12:41:18Z",
"head_sha": HEAD_SHA,
"display_title": RUN_TITLE,
"pull_requests": [],
}
with tempfile.TemporaryDirectory() as tmp:
@@ -113,6 +115,7 @@ class TestWaitForImages(unittest.TestCase):
"conclusion": "failure",
"created_at": "2026-10-04T12:41:18Z",
"head_sha": "0" * 40,
"display_title": RUN_TITLE,
"pull_requests": [],
}
with tempfile.TemporaryDirectory() as tmp:
@@ -123,6 +126,32 @@ class TestWaitForImages(unittest.TestCase):
)
self.assertIn("Timed out waiting for CI images", result.stderr)
def test_run_of_another_pull_request_on_the_same_head_is_ignored(self) -> None:
own_run = {
"id": 7,
"status": "in_progress",
"conclusion": None,
"created_at": "2026-10-04T12:41:18Z",
"head_sha": HEAD_SHA,
"display_title": RUN_TITLE,
"pull_requests": [],
}
other_run = {
"id": 9,
"status": "completed",
"conclusion": "failure",
"created_at": "2026-10-04T12:45:00Z",
"head_sha": HEAD_SHA,
"display_title": "pull_request_target / PR #12 / synchronize / fork:branch",
"pull_requests": [],
}
with tempfile.TemporaryDirectory() as tmp:
result = wait_for_images(tmp, runs=[own_run, other_run], WAIT_ATTEMPTS="2")
self.assertEqual(result.returncode, 1, result.stdout + result.stderr)
self.assertIn("Privileged run 7 ", result.stdout)
self.assertNotIn("Privileged run 9", result.stdout + result.stderr)
self.assertIn("Timed out waiting for CI images", result.stderr)
if __name__ == "__main__":
unittest.main()