Skip to content
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

Use github api for osg-bot PR interaction (SOFTWARE-3564) #444

Merged

Conversation

edquist
Copy link
Contributor

@edquist edquist commented Feb 13, 2019

Since we have @osg-bot now; the webhook app can use an access token for the github api to make comments directly on PRs, rather than emailing a select list.

Also, @osg-bot can hit the big green Merge button directly with the github api, rather than the webhook app needing to generate and push a merge commit manually with an ssh key.

This is currently functional on topology-itb, though i'm marking this PR WIP, as there was already some feedback about things that can be improved (#436), and i'm sure i'll want to clean up this branch before merging it.

@edquist edquist added the WIP label Feb 13, 2019
@edquist
Copy link
Contributor Author

edquist commented Feb 14, 2019

For @matyasselmeci and @brianhlin,

New osg-bot PR comments:

non-dt pr: #450 (no osg-bot message)
dt, automerge checks pass, but out-of-date pr: #449
dt, not all automerge checks pass: #451
dt, automerge checks pass but ci fail: #452
dt, automerge approved & merge success: #457
dt, automerge approved, unexpected merge failure: #458

... and, do we wanna add the help@ email always, or only on failures?

(SOFTWARE-3564)
(SOFTWARE-3564)
(SOFTWARE-3564)
(SOFTWARE-3564)
(SOFTWARE-3564)
(SOFTWARE-3564)
we only want to allow 'merge', which is the default, not 'squash' or
'rebase'.


(SOFTWARE-3564)
(SOFTWARE-3564)
(SOFTWARE-3564)
sendit! sendat comment!


(SOFTWARE-3564)
...required rearranging status_hook a bit...


(SOFTWARE-3564)
... if this all works, we'll strip out the stuff to generate the
merge commit, and maybe the mailx stuff too


(SOFTWARE-3564)
which probably belong in the github module... but one step at a time


(SOFTWARE-3564)
note we also dropped 👍 for mat


(SOFTWARE-3564)
(SOFTWARE-3564)
(SOFTWARE-3564)
if gh_api_user/token aren't configured, this will just be an empty call


(SOFTWARE-3564)
put validate_request_signature next to validate_webhook_signature


(SOFTWARE-3564)
status sender is the ci job owner, which is always derek


(SOFTWARE-3564)
@edquist edquist force-pushed the SOFTWARE-3564.github-api-comments branch from fe74251 to 03fb462 Compare February 21, 2019 18:00
@edquist
Copy link
Contributor Author

edquist commented Feb 21, 2019

The force-push just now was a rebase to tidy up git history a bit, no content changes.

This is currently working on topology-itb and will only make at most a single PR comment, rather than the multiple seen in previous iterations.

matyasselmeci and others added 2 commits February 21, 2019 12:14
(SOFTWARE-3564)

Co-Authored-By: edquist <edquist@users.noreply.github.com>
src/webapp/webhook_status_messages.py Outdated Show resolved Hide resolved
"Unexpected merge failure!\n"
"\n"
"{fail_message}\n"
"\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should express that OSG staff will investigate this issue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

import glob
import hmac
import logging
import os
import re
import subprocess
from subprocess import PIPE
from subprocess import PIPE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Errant whitespace change

Suggested change
from subprocess import PIPE
from subprocess import PIPE

src/webhook_app.py Show resolved Hide resolved
brianhlin and others added 2 commits February 25, 2019 15:08
(SOFTWARE-3564)

Co-Authored-By: edquist <edquist@users.noreply.github.com>
@edquist
Copy link
Contributor Author

edquist commented Feb 25, 2019

@matyasselmeci, @brianhlin, lmk if you have anything further for this

def github_api_call(self, method, url, data):
if data is not None:
data = json.dumps(data).encode()
req = urllib.request.Request(url, data)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does doing req = urllib.request.Request(url, data, method=method) not work? Then you wouldn't have to use a lambda below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about that.

In python2, urllib2.Request (which python3 moved to urllib.request.Request), the __init__ method did not take a method parameter, and it was somewhat annoyingly required that req.get_method be set to a function that would return the method to be used. Thus the lambda.

I didn't realize they added a method parameter. Apparently this was added in Python 3.3.

So, while this github_api_call goes about things in a way that is also python2 compatible, yeah it looks cleaner to just pass in a method parameter to Request, since we only care about python3.6+.

@matyasselmeci
Copy link
Collaborator

Feel free to merge once you've brought the branch up to date.

edquist and others added 3 commits February 26, 2019 20:48
Apparently in python3.3+, Request takes a method parameter, rather
than needing to provide a get_method function.  And since we only
care about python3.6+, we might as well just do that.

Suggested by Mat.

(SOFTWARE-3564)
@edquist edquist merged commit eb7c829 into opensciencegrid:master Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants