Skip to content

Commit 8bd0839

Browse files
chore: add Slack notification when merge-train is dequeued (#19119)
## Summary - Adds a GitHub Actions workflow that notifies #honk-team when the `merge-train/barretenberg` PR is removed from the merge queue ## Motivation This helps get people to look at it sooner when it's dequeued. ## Test plan - Merge to next, then verify notification fires when the merge-train/barretenberg PR is dequeued
2 parents de469a0 + 440dea5 commit 8bd0839

File tree

2 files changed

+56
-24
lines changed

2 files changed

+56
-24
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Notify Slack on Merge Queue Dequeue
2+
3+
on:
4+
pull_request:
5+
types: [dequeued]
6+
7+
jobs:
8+
notify-slack:
9+
name: Notify Slack
10+
runs-on: ubuntu-latest
11+
if: startsWith(github.event.pull_request.head.ref, 'merge-train/')
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
ref: ${{ github.event.pull_request.head.sha }}
17+
18+
- name: Send Slack notification
19+
env:
20+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
21+
REF_NAME: ${{ github.event.pull_request.head.ref }}
22+
PR_URL: ${{ github.event.pull_request.html_url }}
23+
run: ./ci3/merge_train_failure_slack_notify --dequeued
Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
#!/usr/bin/env bash
2-
NO_CD=1 source $(git rev-parse --show-toplevel)/ci3/source
3-
source $ci3/source_redis
2+
set -eu
3+
4+
# Parse arguments
5+
DEQUEUED=false
6+
while [[ $# -gt 0 ]]; do
7+
case $1 in
8+
--dequeued)
9+
DEQUEUED=true
10+
shift
11+
;;
12+
*)
13+
ci_log_id=$1
14+
shift
15+
;;
16+
esac
17+
done
418

5-
ci_log_id=$1
619
commit_title=$(git log -1 --pretty=format:'%s')
720
commit_author=$(git log -1 --pretty=format:'%an')
821

@@ -18,29 +31,25 @@ else
1831
exit 0
1932
fi
2033

21-
set -x
22-
23-
# Publish merge train failure to Redis channel
24-
redis_data=$(jq -n \
25-
--arg status "merge_train_failed" \
26-
--arg ref_name "$REF_NAME" \
27-
--arg channel "$channel" \
28-
--arg log_url "http://ci.aztec-labs.com/$ci_log_id" \
29-
--arg commit_title "$commit_title" \
30-
--arg commit_author "$commit_author" \
31-
--arg commit_hash "${COMMIT_HASH:-$(git rev-parse HEAD)}" \
32-
'{status: $status, ref_name: $ref_name, channel: $channel, log_url: $log_url, commit_title: $commit_title, commit_author: $commit_author, commit_hash: $commit_hash, timestamp: now | todate}')
33-
redis_publish "ci:merge-train:failed" "$redis_data"
34-
35-
# Send slack message
36-
data=$(cat <<EOF
34+
send_slack_message() {
35+
local message=$1
36+
local data=$(cat <<EOF
3737
{
3838
"channel": "$channel",
39-
"text": "There was a failure (http://ci.aztec-labs.com/$ci_log_id) in the merge-train:\\n$commit_title by $commit_author"
39+
"text": "$message"
4040
}
4141
EOF
4242
)
43-
curl -X POST https://slack.com/api/chat.postMessage \
44-
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \
45-
-H "Content-type: application/json" \
46-
--data "$data"
43+
curl -X POST https://slack.com/api/chat.postMessage \
44+
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \
45+
-H "Content-type: application/json" \
46+
--data "$data"
47+
}
48+
49+
set -x
50+
51+
if [[ "$DEQUEUED" == "true" ]]; then
52+
send_slack_message "PR was removed from the merge queue: <$PR_URL|View PR>"
53+
else
54+
send_slack_message "There was a failure (http://ci.aztec-labs.com/$ci_log_id) in the merge-train:\\n$commit_title by $commit_author"
55+
fi

0 commit comments

Comments
 (0)