Skip to content

Commit bb43ee6

Browse files
authored
Link to PR-specific grid in PR message (#576)
Also add the link to 'command' PR runs rather than just 'label' runs. Expansion of #571; ref #327. Note that, at present, the link does not actually filter to the specified branch. It is hoped that a later update to buildbot will enable that.
1 parent 34208ed commit bb43ee6

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

master/custom/pr_testing.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,20 @@
1515

1616
GITHUB_PROPERTIES_WHITELIST = ["*.labels"]
1717

18-
BUILD_SCHEDULED_MESSAGE_TEMPLATE = """\
18+
BUILD_MESSAGE_HEADER = """\
1919
:robot: New build scheduled with the buildbot fleet by @{user} for commit {commit} :robot:
2020
2121
Results will be shown at:
2222
23-
https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F30617%2Fmerge
23+
https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F{pr_number}%2Fmerge
2424
25-
If you want to schedule another build, you need to add the <kbd>{label}</kbd> label again.
2625
"""
2726

28-
BUILD_COMMAND_SCHEDULED_MESSAGE_TEMPLATE = """\
29-
:robot: New build scheduled with the buildbot fleet by @{user} for commit {commit} :robot:
27+
BUILD_SCHEDULED_MESSAGE_TEMPLATE = BUILD_MESSAGE_HEADER + """\
28+
If you want to schedule another build, you need to add the <kbd>{label}</kbd> label again.
29+
"""
3030

31+
BUILD_COMMAND_SCHEDULED_MESSAGE_TEMPLATE = BUILD_MESSAGE_HEADER + """\
3132
The command will test the builders whose names match following regular expression: `{filter}`
3233
3334
The builders matched are:
@@ -83,11 +84,15 @@ def _remove_label_and_comment(self, payload, label):
8384
url = payload["pull_request"]["comments_url"]
8485
username = payload["sender"]["login"]
8586
commit = payload["pull_request"]["head"]["sha"]
87+
pr_number = payload["issue"]["number"]
8688
yield http.post(
8789
url.replace(self.github_api_endpoint, ""),
8890
json={
8991
"body": BUILD_SCHEDULED_MESSAGE_TEMPLATE.format(
90-
user=username, commit=commit, label=label
92+
user=username,
93+
commit=commit,
94+
label=label,
95+
pr_number=pr_number,
9196
)
9297
},
9398
)
@@ -281,6 +286,7 @@ def handle_issue_comment(self, payload, event):
281286
user=payload["sender"]["login"],
282287
commit=head_sha,
283288
filter=builder_filter,
289+
pr_number=number,
284290
builders="\n".join(
285291
{
286292
f"- `{builder}`"

0 commit comments

Comments
 (0)