Skip to content

Commit 101ebf2

Browse files
grunwegriccardobrasca
authored andcommitted
feat(CI): add emoji to maintainer merge'd PRs also (#24544)
The zulip bot reacts to all label changes, including arbitrary users setting that label. That seems harmless: the emoji is only informational, and the effect of false marking a PR with the label may simply be that it doesn't reviewed as well.
1 parent 9c826ca commit 101ebf2

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

.github/workflows/zulip_emoji_awaiting_author.yaml renamed to .github/workflows/zulip_emoji_labelling.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ on:
22
pull_request:
33
types: [labeled, unlabeled]
44
jobs:
5+
# When a PR is (un)labelled with awaiting-author or maintainer-merge,
6+
# add resp. remove the matching emoji reaction from zulip messages.
57
set_pr_emoji:
6-
if: github.event.label.name == 'awaiting-author'
8+
if: github.event.label.name == 'awaiting-author' || github.event.label.name == 'maintainer-merge'
79
runs-on: ubuntu-latest
810
steps:
911
- name: Checkout mathlib repository
@@ -30,5 +32,5 @@ jobs:
3032
PR_NUMBER: ${{ github.event.number}}
3133
LABEL_STATUS: ${{ github.event.action }}
3234
run: |
33-
printf $'Running the python script with pr "%s"\n' "$PR_NUMBER"
35+
printf $'Running the python script with pr "%s"\n' "$PR_NUMBER" "$LABEL_STATUS"
3436
python scripts/zulip_emoji_merge_delegate.py "$ZULIP_API_KEY" "$ZULIP_EMAIL" "$ZULIP_SITE" "$LABEL_STATUS" "$PR_NUMBER"

scripts/zulip_emoji_merge_delegate.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
has_bors = any(reaction['emoji_name'] == 'bors' for reaction in reactions)
7373
has_merge = any(reaction['emoji_name'] == 'merge' for reaction in reactions)
7474
has_awaiting_author = any(reaction['emoji_name'] == 'writing' for reaction in reactions)
75+
has_maintainer_merge = any(reaction['emoji_name'] == 'hammer' for reaction in reactions)
7576
has_closed = any(reaction['emoji_name'] == 'closed-pr' for reaction in reactions)
7677
first_in_thread = hashPR.search(message['subject']) and message['display_recipient'] == 'PR reviews' and message['subject'] not in first_by_subject
7778
first_by_subject[message['subject']] = message['id']
@@ -105,6 +106,13 @@
105106
"emoji_name": "merge"
106107
})
107108
print(f"result: '{result}'")
109+
if has_maintainer_merge:
110+
print('Removing maintainer-merge')
111+
result = client.remove_reaction({
112+
"message_id": message['id'],
113+
"emoji_name": "hammer"
114+
})
115+
print(f"result: '{result}'")
108116
if has_awaiting_author:
109117
print('Removing awaiting-author')
110118
result = client.remove_reaction({
@@ -137,6 +145,12 @@
137145
"message_id": message['id'],
138146
"emoji_name": "peace_sign"
139147
})
148+
elif 'maintainer-merge' == LABEL:
149+
print('adding maintainer-merge')
150+
client.add_reaction({
151+
"message_id": message['id'],
152+
"emoji_name": "hammer"
153+
})
140154
elif LABEL == 'labeled':
141155
print('adding awaiting-author')
142156
client.add_reaction({

0 commit comments

Comments
 (0)