From 27a456d08e5f7d281d86957b554b4bb67679c9f3 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Sat, 28 Nov 2026 17:58:46 -0800 Subject: [PATCH 1/2] Group Merge-Bot Check Runs by App and Name Co-Authored-By: Claude Opus 5.5 --- .github/workflows/merge-bot-task.yml | 6 +++--- tests/test_merge_bot_merge.py | 23 +++++++++++++++++++++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/.github/workflows/merge-bot-task.yml b/.github/workflows/merge-bot-task.yml index 3f569030b..a6db99590 100644 --- a/.github/workflows/merge-bot-task.yml +++ b/.github/workflows/merge-bot-task.yml @@ -137,9 +137,9 @@ jobs: passing_since=0 while :; do read_pr - read_api "the head's check runs" "checks: read" gh api --paginate "repos/$REPO/commits/$HEAD_SHA/check-runs?per_page=100" --jq '.check_runs[] | {id, name, status, conclusion}' - # A re-run leaves its earlier attempt on the head, so only the newest run of each name counts. - runs=$(jq -sc 'group_by(.name) | map(max_by(.id))[]' <<<"$out") + read_api "the head's check runs" "checks: read" gh api --paginate "repos/$REPO/commits/$HEAD_SHA/check-runs?per_page=100" --jq '.check_runs[] | {id, name, status, conclusion, app: .app.id}' + # A re-run leaves its earlier attempt on the head, so only the newest run of each App and name counts, since another App's passing run of the same name must not hide a failure. + runs=$(jq -sc 'group_by([.app, .name]) | map(max_by(.id))[]' <<<"$out") read_api "the head's commit statuses" "statuses: read" gh api --paginate "repos/$REPO/commits/$HEAD_SHA/status?per_page=100" --jq '.statuses[] | {name: .context, status: (if .state == "pending" then "pending" else "completed" end), conclusion: .state}' # This workflow's own jobs post on the head too, as a caller job name, a slash, and the job name, so the wait leaves them out. checks=$(jq -sc --argjson own "$OWN_JOBS" ' diff --git a/tests/test_merge_bot_merge.py b/tests/test_merge_bot_merge.py index d6f03c4a5..0879c5b74 100755 --- a/tests/test_merge_bot_merge.py +++ b/tests/test_merge_bot_merge.py @@ -54,9 +54,19 @@ def check_run( - name: str, status: str = "completed", conclusion: str | None = "success", run_id: int = 1 + name: str, + status: str = "completed", + conclusion: str | None = "success", + run_id: int = 1, + app_id: int = 1, ) -> dict[str, Any]: - return {"id": run_id, "name": name, "status": status, "conclusion": conclusion} + return { + "id": run_id, + "name": name, + "status": status, + "conclusion": conclusion, + "app": {"id": app_id}, + } def runs(*checks: dict[str, Any]) -> dict[str, Any]: @@ -328,6 +338,15 @@ def test_only_the_newest_run_of_a_re_run_check_counts(self) -> None: self.assertEqual(0, result.returncode, result.stdout + result.stderr) self.assertEqual(1, len(self.merges(calls))) + def test_a_passing_run_of_another_app_does_not_hide_a_failed_one(self) -> None: + failed = check_run("Lint job", conclusion="failure", run_id=1, app_id=1) + result, calls = self.merge( + UNREQUIRED, [runs(check_run("Lint job", run_id=2, app_id=2), failed)] + ) + self.assertEqual(1, result.returncode, result.stdout + result.stderr) + self.assertIn("Lint job (failure)", result.stdout + result.stderr) + self.assertEqual(0, len(self.merges(calls))) + def test_a_pull_request_closed_during_the_merge_retry_ends_without_failing(self) -> None: refused = {"error": "GraphQL: Pull request is closed"} closed = {"json": {**OPEN, "state": "closed"}} From 1aea5ba10469991191fdd64c417334fd95bb7bf2 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Sat, 28 Nov 2026 18:17:46 -0800 Subject: [PATCH 2/2] Split the Check Dedupe Comment Into Short Sentences Co-Authored-By: Claude Opus 5.5 --- .github/workflows/merge-bot-task.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/merge-bot-task.yml b/.github/workflows/merge-bot-task.yml index a6db99590..9bcc62186 100644 --- a/.github/workflows/merge-bot-task.yml +++ b/.github/workflows/merge-bot-task.yml @@ -138,7 +138,8 @@ jobs: while :; do read_pr read_api "the head's check runs" "checks: read" gh api --paginate "repos/$REPO/commits/$HEAD_SHA/check-runs?per_page=100" --jq '.check_runs[] | {id, name, status, conclusion, app: .app.id}' - # A re-run leaves its earlier attempt on the head, so only the newest run of each App and name counts, since another App's passing run of the same name must not hide a failure. + # A re-run leaves its earlier attempt on the head, so only the newest run counts. + # A run is keyed by App and name, so another App's passing run never hides a failure. runs=$(jq -sc 'group_by([.app, .name]) | map(max_by(.id))[]' <<<"$out") read_api "the head's commit statuses" "statuses: read" gh api --paginate "repos/$REPO/commits/$HEAD_SHA/status?per_page=100" --jq '.statuses[] | {name: .context, status: (if .state == "pending" then "pending" else "completed" end), conclusion: .state}' # This workflow's own jobs post on the head too, as a caller job name, a slash, and the job name, so the wait leaves them out.