Bug 192227 - Add script to automatically close GitHub pull requests
Summary: Add script to automatically close GitHub pull requests
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: PC Linux
: P2 Normal
Assignee: Michael Catanzaro
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-30 07:36 PST by Michael Catanzaro
Modified: 2019-07-10 11:45 PDT (History)
9 users (show)

See Also:


Attachments
Patch (4.82 KB, patch)
2018-11-30 07:40 PST, Michael Catanzaro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Catanzaro 2018-11-30 07:36:51 PST
This script will close all open pull requests at https://github.com/WebKit/webkit with a friendly message:

"""
Thank you for your interest in contributing to WebKit!

This repository is a mirror and does not accept pull requests. Please submit your contribution to [WebKit Bugzilla](https://bugs.webkit.org/) for code review. Please also read [Contributing Code](https://webkit.org/contributing-code/) for an introduction to the contribution process. We apologize for the inconvenience and hope to see you on WebKit Bugzilla soon!
"""

If we run the script on a daily basis, then potential contributors can be redirected to Bugzilla in a timely manner, instead of getting frustrated that their pull requests were ignored until somebody notices them weeks later.

We have two options to run it:

 (a) I could configure it to run nightly on my personal VPS, if Jon is OK with granting my GitHub account access to the WebKit repo.
 (b) Apple could run it on Apple infrastructure, if someone from Apple wants to manage this.

If we do (b) then the script should be rewritten in python2 instead of python3. (The configparser syntax is different enough that it's easier to support only one python version.)
Comment 1 Michael Catanzaro 2018-11-30 07:40:14 PST
Created attachment 356176 [details]
Patch
Comment 2 Don Olmstead 2018-11-30 09:07:01 PST
The script itself is fine but there's a GitHub app that looks like it would fit the bill.

https://probot.github.io/apps/close-issue/
Comment 3 Michael Catanzaro 2018-11-30 09:10:48 PST
(In reply to Don Olmstead from comment #2)
> The script itself is fine but there's a GitHub app that looks like it would
> fit the bill.
> 
> https://probot.github.io/apps/close-issue/

Not clear if that can close pull requests? Doesn't look like it?
Comment 4 Don Olmstead 2018-11-30 09:30:48 PST
Comment on attachment 356176 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=356176&action=review

> Tools/Scripts/close-pull-requests:77
> +    issue = github.Issue.Issue(requester=req._requester,
> +                               headers={},
> +                               attributes=issue_data,
> +                               completed=True)

I had thought all PRs are technically issues. So you could just try installing it on a dummy repo and see what happens.
Comment 5 Don Olmstead 2018-11-30 09:32:16 PST
So to be clear I think the script is perfectly fine as is the only reason I bring up the Close Issue Probot is the whole hosting issue.

https://github.com/offu/close-issue-app is the source for it so if it doesn't fit the bill maybe we can extend it and do a PR on it.
Comment 6 Michael Catanzaro 2018-12-01 08:41:45 PST
(In reply to Don Olmstead from comment #5)
> So to be clear I think the script is perfectly fine as is the only reason I
> bring up the Close Issue Probot is the whole hosting issue.
> 
> https://github.com/offu/close-issue-app is the source for it so if it
> doesn't fit the bill maybe we can extend it and do a PR on it.

I'm fine with using that app if that's what we want to do. I'd hesitate to give an app access to my own GitHub account, though.
Comment 7 Alexey Proskuryakov 2018-12-03 10:41:46 PST
Not maintaining a service that runs scripts seems better than maintaining it. Can we have a separate GitHub account for the app?
Comment 8 Don Olmstead 2018-12-03 10:45:51 PST
(In reply to Alexey Proskuryakov from comment #7)
> Not maintaining a service that runs scripts seems better than maintaining
> it. Can we have a separate GitHub account for the app?

Someone who has org access to WebKit on GitHub would need to enable it. When enabling it it will ask permissions for things. If the permissions it asks for are ok then it should just work.
Comment 9 Michael Catanzaro 2018-12-03 11:58:08 PST
(In reply to Don Olmstead from comment #8)
> Someone who has org access to WebKit on GitHub would need to enable it.

Of the five people who have access, the only name I recognize is Jon (CCed).
Comment 10 Michael Catanzaro 2019-01-01 12:02:53 PST
Anyway, I can have this dumb little script running immediately if we make the decision to go that route, if I'm granted access to the GitHub repo. If we want to use the app, someone else will have to take charge. Either way, it's blocked on Jon Davis since he's the only current contributor with access to the GitHub repo.
Comment 11 Michael Catanzaro 2019-05-06 19:03:00 PDT
Ping: Jon.
Comment 12 Michael Catanzaro 2019-05-10 08:56:17 PDT
(In reply to Michael Catanzaro from comment #0)
>  (a) I could configure it to run nightly on my personal VPS, if Jon is OK
> with granting my GitHub account access to the WebKit repo.

I actually no longer have a personal VPS, but Igalia could set this up easily enough. I'm sure Apple could, too.
Comment 13 Michael Catanzaro 2019-06-06 06:26:49 PDT
I tried emailing, Jon but I think he missed it.

We really need a response from Jon here, as he's the only Apple developer who controls the GitHub repo. It would be embarrassing to have to ask old Google developers for help with WebKit's GitHub repo. ;)
Comment 14 Ryosuke Niwa 2019-06-26 19:04:22 PDT
What do we need to do in the Github repo / account??
Comment 15 Michael Catanzaro 2019-06-27 07:31:36 PDT
To use my script, we would need a GitHub access token for an account with access to the GitHub repo. We could create a new GitHub account for this purpose, give it access to the WebKit repo, and then create an access token for it. Access tokens are created under GitHub settings -> Developer settings -> Access tokens. I've tested this already and the only permission required is the public_repo permission; everything else can be unchecked.

Then we would need to set up a server to run the script on a regular basis (e.g. daily). You could do that at Apple or we could do it at Igalia, whichever you would prefer.

We could alternatively forget about my script and try setting up https://github.com/offu/close-issue-app instead, as Don suggested. That may or may not be easier.

Either way, we need help from someone with access to the GitHub repo (Jon or Ryosuke).
Comment 16 Ryosuke Niwa 2019-06-27 19:00:45 PDT
We should probably also lock the conversation if we can. I had to lock the conversation on https://github.com/WebKit/webkit/pull/20 even after closing PR because the person kept commenting on it.
Comment 17 Michael Catanzaro 2019-06-28 08:10:27 PDT
Comment on attachment 356176 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=356176&action=review

> Tools/Scripts/close-pull-requests:79
> +    issue.create_comment(MESSAGE)
> +    req.edit(state='closed')

Not tested, but I think we would just need to do:

issue.lock('resolved')

Python API docs: https://pygithub.readthedocs.io/en/latest/github_objects/Issue.html?highlight=lock#github.Issue.Issue.lock

GitHub docs: https://developer.github.com/v3/issues/#lock-an-issue

In particular, note the 'resolved' string is important and the lock will fail if we don't have it there.
Comment 18 Jon Davis 2019-07-10 11:33:01 PDT
I've setup an instance of this script to run daily at around 9 AM on an internal instance at Apple.
Comment 19 Michael Catanzaro 2019-07-10 11:45:02 PDT
Awesome, thanks Jon!

I'll close this, I suppose. We can still commit it to Tools/Scripts if we want, but doesn't seem necessary.