From e2b2cd6871780d030b4fcb42b13b2daa26505d0c Mon Sep 17 00:00:00 2001 From: AztecBot Date: Sat, 16 May 2026 06:05:43 +0000 Subject: [PATCH] fix(ci): include failing CI run link in merge-queue dequeue Slack notification --- .../workflows/merge-queue-dequeue-notify.yml | 3 + ci3/merge_train_failure_slack_notify | 58 ++++++++++++++++++- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/.github/workflows/merge-queue-dequeue-notify.yml b/.github/workflows/merge-queue-dequeue-notify.yml index 8b3746cbca33..8a678022ee5a 100644 --- a/.github/workflows/merge-queue-dequeue-notify.yml +++ b/.github/workflows/merge-queue-dequeue-notify.yml @@ -19,6 +19,9 @@ jobs: env: SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} GITHUB_TOKEN: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} + GITHUB_REPOSITORY: ${{ github.repository }} + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} REF_NAME: ${{ github.event.pull_request.head.ref }} PR_URL: ${{ github.event.pull_request.html_url }} run: ./ci3/merge_train_failure_slack_notify --dequeued diff --git a/ci3/merge_train_failure_slack_notify b/ci3/merge_train_failure_slack_notify index 436da1351405..519a6ead285b 100755 --- a/ci3/merge_train_failure_slack_notify +++ b/ci3/merge_train_failure_slack_notify @@ -41,12 +41,66 @@ fi TOPDIR=$(git rev-parse --show-toplevel) +github_api() { + local path="$1" + curl -fsS \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/$path" +} + +find_dequeued_failure_url() { + local repo="${GITHUB_REPOSITORY:-AztecProtocol/aztec-packages}" + local sha="${PR_HEAD_SHA:-}" + if [[ -z "${GITHUB_TOKEN:-}" || -z "$sha" ]]; then + return 0 + fi + + local url + url="$(github_api "repos/$repo/commits/$sha/check-runs?per_page=100" \ + | jq -r ' + [.check_runs[]? + | select(.conclusion == "failure" + or .conclusion == "timed_out" + or .conclusion == "action_required" + or .conclusion == "cancelled" + or .conclusion == "startup_failure") + | {url: (.details_url // .html_url // ""), at: (.completed_at // .started_at // "")}] + | sort_by(.at) + | reverse + | .[0].url // empty + ' 2>/dev/null || true)" + if [[ -n "$url" ]]; then + printf '%s\n' "$url" + return 0 + fi + + github_api "repos/$repo/commits/$sha/status" \ + | jq -r ' + [.statuses[]? + | select(.state == "failure" or .state == "error") + | {url: (.target_url // ""), at: (.updated_at // "")}] + | sort_by(.at) + | reverse + | .[0].url // empty + ' 2>/dev/null || true +} + set -x if [[ "$MODE" == "dequeued" ]]; then + failure_url="$(find_dequeued_failure_url)" + failure_link="" + failure_prompt="" + if [[ -n "$failure_url" ]]; then + failure_link="$(printf ' | <%s|View failing CI run>' "$failure_url")" + failure_prompt=" Failing CI run: $failure_url." + fi + "$TOPDIR/ci3/slack_notify_with_claudebox_kickoff" "$channel" \ - "$(printf 'PR was removed from the merge queue: <%s|View PR>\n%s by %s (🤖)' "$PR_URL" "$commit_title" "$commit_author")" \ - "PR was dequeued from merge queue for $REF_NAME: $PR_URL — $commit_title by $commit_author. Investigate why the PR was dequeued (check CI logs, merge conflicts, etc.), fix the issue, and create a PR targeting $REF_NAME (the exact merge-train branch). Run ./bootstrap.sh ci to verify the fix locally and iterate until CI passes. Follow the merge-trains skill (.claude/skills/merge-trains/SKILL.md)." \ + "$(printf 'PR was removed from the merge queue: <%s|View PR>%s\n%s by %s (🤖)' "$PR_URL" "$failure_link" "$commit_title" "$commit_author")" \ + "PR was dequeued from merge queue for $REF_NAME: $PR_URL.${failure_prompt} $commit_title by $commit_author. Investigate why the PR was dequeued (check CI logs, merge conflicts, etc.), fix the issue, and create a PR targeting $REF_NAME (the exact merge-train branch). Run ./bootstrap.sh ci to verify the fix locally and iterate until CI passes. Follow the merge-trains skill (.claude/skills/merge-trains/SKILL.md)." \ --target-ref "origin/$REF_NAME" elif [[ "$MODE" == "merged" ]]; then