-
Notifications
You must be signed in to change notification settings - Fork 3
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
Large rework to enable sending pull requests as user. #10
base: main
Are you sure you want to change the base?
Conversation
This is done by using two GitHub Apps; (a) [OpenROAD Pull Request Sender ](https://github.com/organizations/The-OpenROAD-Project-staging/settings/apps/openroad-pull-request-sender) -- The GitHub App which is given permission by a user to actually send pull requests as them and then does the request. It is installed on the `upstream` and `staging` repositories. It needs the ability to modify pull requests. (b) [OpenROAD Pull Request Sender Auth Check ](https://github.com/organizations/The-OpenROAD-Project-private/settings/apps/openroad-pr-sender-auth-check) -- The GitHub App which checks that a user has given the OpenROAD Pull Request Sender the permission to send the pull requests. It is installed on the `private` repositories. It only needs the ability to update check status. The GitHub Apps run using [Google Cloud Run](https://cloud.google.com/run) (on Google Cloud Platform) under the `openroad-robot` project. Signed-off-by: Tim 'mithro' Ansell <[email protected]>
u = (datetime.datetime.utcnow() - self.updated).seconds | ||
ein = self.created + datetime.timedelta(seconds=self.expires_in) | ||
rin = self.created + datetime.timedelta(seconds=self.refresh_token_expires_in) | ||
return f"""\ |
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 these variable names should not be abbreviated.
From the python style guide.
Function names, variable names, and filenames should be descriptive; eschew abbreviation. In particular, do not use abbreviations that are ambiguous or unfamiliar to readers outside your project, and do not abbreviate by deleting letters within a word.
rm -rf $(BUILD_DIR) | ||
mkdir $(BUILD_DIR) | ||
cp -a $(SRCS) ./$(BUILD_DIR)/ | ||
find $(BUILD_DIR) -name '*.pem' -delete | ||
find $(BUILD_DIR) -name '*.pyc' -delete | ||
find $(BUILD_DIR) -name '.*.sw*' -delete | ||
find $(BUILD_DIR) -type d -empty -delete |
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.
Should these steps be extracted into a generic target named clean?
return f"{self.org}/{self.repo}" | ||
|
||
@classmethod | ||
def check(cls, s): |
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's not clear to me what this class method is checking I think a one line description would be helpful here. Also renaming s would be helpful as well.
assert user, s | ||
assert org, s | ||
assert repo, s | ||
assert pr, s | ||
assert rev , s |
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 we don't care about the message in the assertion it might just be best to replace s with empty string. I think the s adds confusion.
return cls.from_token(estate) | ||
|
||
@classmethod | ||
def from_json(cls, j): |
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.
Adding a comment on what this is extracting would be helpful. As a user I would like to know what I need to provide to this method to get a useful result out. Also rename j to something more representative of the input like user_get_response.
c.pop('app') | ||
if c['external_id'] != EXTERNAL_ID: | ||
continue | ||
if c['id'] in (2688818725,): |
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.
Magic numbers should have a comment explaining where they came from. Ideally this would be a global variable of some kind.
continue | ||
existing_checks.append(c) | ||
|
||
t = db.Token.latest(info.user) |
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.
Rename t latest_token.
EXTERNAL_ID = 'pr-auth' | ||
|
||
|
||
def auth_check_on_private_pr(info): |
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 method seems to be doing a lot. Giving a one line description with a few sentences underneath to explain intent would help with readability.
user = flask.request.args.get('user') | ||
|
||
# Get existing token | ||
t = db.Token.latest(user) |
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.
Renamed latest_token
now = time.time() | ||
|
||
targets = cls._cache | ||
if now - cls._cache_updated > 60*5: |
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 number needs to document what units it is in.
@mithro is this PR still relevant? |
Yes. This makes the pull requests come from the original user rather than the bot. However, I don't recall what the state here was or why it wasn't merged. |
I see a number of comments from @QuantamHD that need addressing. I agree the goal is still relevant. |
This is done by using two GitHub Apps;
OpenROAD Pull Request Sender -- The GitHub App which is given permission by a user to actually send pull requests as them and then does the request.
upstream
andstaging
repositories.OpenROAD Pull Request Sender Auth Check -- The GitHub App which checks that a user has given the OpenROAD Pull Request Sender the permission to send the pull requests.
private
repositories.The GitHub Apps run using Google Cloud Run (on Google Cloud Platform) under the
openroad-robot
project.Signed-off-by: Tim 'mithro' Ansell [email protected]