-
Notifications
You must be signed in to change notification settings - Fork 13.5k
workflows: Add a simple pull request subscription workflow #64913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This repository does not accept pull requests. Please follow http://llvm.org/docs/Contributing.html#how-to-submit-a-patch for contribution to LLVM. |
Example pr-subscribers team: https://github.com/orgs/llvm/teams/pr-subscribers-mips |
Why aren't we using the native GitHub CODEOWNER files for subscription? Right now something quite annoying with the issue subscription, which will also happens with the action is that the subscription does not send the initial email containing all the information. What I'm looking for with an auto-subscription to pull-request is a notification with the title, the description, and ideally 500 lines of the diff! |
Using a text file in the repository doesn't scale and adds unneeded churn to the repository. |
@joker-eph Is this what Phabricator does? |
@joker-eph @MaskRay We could do a hybrid approach where we use CODEOWNERS but instead of putting individuals in the file, we create teams (like I'm proposing here) and specify the teams as the code owners in the files. The main difference also between using CODEOWNERS and what I'm proposing is that with the CODEOWNERS file, people are added as reviewers and with what I'm proposing, people are just subscribed to the PR. |
Yes, here is an example of the email Phab sends initially, and it includes all Herald subscribers (and has all the infos you needs about the revision without opening Phab, on GitHub you'd need to open the link and an extra click to get the list of paths and the diff I believe):
I shared the concern, but ultimately I care more about my code reviewing experience, if we have to talk about things "we cannot afford", I would say "we cannot afford a sub-par code review workflow" first. |
I've done some testing and using the CODEOWNERS file does generate an email with the full PR summary: [llvm_temp-issue-tester] Update README.md (PR #51).pdf I think if we use teams rather than individuals in the file, it's going to be much easier to manage. |
That seems fine to me! Are we gonna reuse the teams used for issues or have new ones? |
I was thinking we would create new ones, just in case people just want to subscribe to pull requests or issues only. |
Given that label-based issue notifications & subscriptions work now, we'd likely deprecate issue teams |
CODEOWNERS will subscribe you to an entire directory, right? Is there any solution for subscribing only to specific paths in a directory? |
You can use the same exact syntax that you can in a |
This new workflows will make it possible for people to subscribe to pull requests based on the files that are being modified. Whenever a pull request is created, this action will look through all of the teams whose name begins with pr-subscribers- and it will try to match the files changed in the pull request to a comma separated list of globs in the team's description. One limitation of this workflow is that it only runs when a pull request is created, so any files added in subsequent updates will not create notifications for the appropriate teams. This is planned to be fixed in a future update.
The labels are added based on the file paths so we still ultimately end up with file path based subscriptions, but using labels as an intermediary gives us more flexibility.
b16d046
to
2999769
Compare
llvm/utils/git/github-automation.py
Outdated
patch = requests.get(self.pr.diff_url).text | ||
except: | ||
patch = "" | ||
comment = "@llvm/{}".format(team.slug) + "\n\n<details><summary>Changes</summary><pre>\n" + patch + "\n</pre></details>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this shows up in the email, that's just gonna be great :)
Can we do it for issues when we're done with PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the patch
variable contain ```
? If not, maybe add ```diff
and ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MaskRay Do you mean the patch text?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Sorry for the typo, I mean whether the variable patch = requests.get(self.pr.diff_url).text
contains ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't normally have ```, but it could if one of the lines changed in the patch had it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the pre tag will prevent the markdown from being rendered if that is what your going for with the ``` suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. <pre></pre>
is sufficient. Resolved I think.
Another nice-to-have thing is to list modified files before showing diff --git
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe list the diffstat?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I'm not sure exactly how to do that, but I'll add it to my TODO.
I rewrote this so now labels are added to PRs based on the files changed by the PR, and then teams are notified with an @ mention based on the labels. I also added a diff of the PR to go along with the mention, so subscribers can see the context in their email without having to click on the PR link. Here is an example of what the comment/notification will look like. |
llvm/utils/git/github-automation.py
Outdated
if self.team_name != team.name.lower(): | ||
continue | ||
try: | ||
patch = requests.get(self.pr.diff_url).text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be arbitrarily large? Shall we limit the size here with a subset?
I don't know the limit for a comment size with GitHub API but I would be afraid of the comment posting failing because of that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like the comments are limited to 65536 characters. We can try to put some kind of limit on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great improvement, if the email notification works I'd say ship-it and refine!
self.repo = github.Github(token).get_repo(repo) | ||
self.org = github.Github(token).get_organization(self.repo.organization.login) | ||
self.pr = self.repo.get_issue(pr_number).as_pull_request() | ||
self._team_name = "pr-subscribers-{}".format(label_name).lower() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is some discrepancy between the label names and the pr-subscribers- team names.
For example, backend:X86
vs pr-subscribers-x86, and the issue-subscriber name https://github.com/orgs/llvm/teams/issue-subscribers-backend-X86 .
That said, this is a small issue. I think we can rename pr-subscribers- team names to improve consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MaskRay Yes, we are going to have to create new teams. I think in this case what we will do is to make pr-subscribers-backend:X86 a parent team of pr-subscribers-x86, so when you mention pr-subscribers-backend:X86, members of pr-subscribers-x86 will be mentioned too.
I have a python script mapping the current team names to the new names, so we should be able to fix this for every team.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good! Thanks for the effort.
Thank you for creating this patch and starting https://discourse.llvm.org/t/changes-to-pull-request-subscription-system/73296 . I only got to understand how this patch will help the situation after reading the Discourse post. This looks great to replace the current pr-subscribers via |
Consider linking to https://discourse.llvm.org/t/changes-to-pull-request-subscription-system/73296 in the description. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Make sure you run black
on the python file before submitting.
Please make sure this is limited to llvm/llvm-project like other issue-related workflows, otherwise forks will start running this action |
This new workflow will make it possible for people to subscribe to pull requests based on the labels that are added. Labels will be added automatically to the pull requests based on the modified files and each label will be associated with a GitHub team that will be notified when the label is added.
See https://discourse.llvm.org/t/changes-to-pull-request-subscription-system/73296