-
Notifications
You must be signed in to change notification settings - Fork 26
art-2519 add check upstreampulls function #488
Changes from 5 commits
0c5aaf4
6b9462e
7f488d2
f1d3fec
2c9b67d
f0b802b
d9b15da
e66049a
8f0579c
32ee1d2
e55b574
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -13,7 +13,7 @@ | |||||||||
from doozerlib.model import Missing | ||||||||||
from doozerlib.pushd import Dir | ||||||||||
from doozerlib.cli import cli, pass_runtime | ||||||||||
from doozerlib import brew, state, exectools, model | ||||||||||
from doozerlib import brew, state, exectools, model, constants | ||||||||||
from doozerlib.util import get_docker_config_json, convert_remote_git_to_ssh, \ | ||||||||||
split_git_url, remove_prefix, green_print,\ | ||||||||||
yellow_print, red_print, convert_remote_git_to_https, \ | ||||||||||
|
@@ -530,6 +530,59 @@ def prs(): | |||||||||
pass | ||||||||||
|
||||||||||
|
||||||||||
@prs.command('list', short_help='List all open prs for upstream repo') | ||||||||||
@pass_runtime | ||||||||||
def images_upstreampulls(runtime): | ||||||||||
runtime.initialize(clone_distgits=False, clone_source=False) | ||||||||||
retdata = {} | ||||||||||
upstreams = [] | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. efficiency isn't exactly important here, but just on principle i would not make this a list since order doesn't matter...
Suggested change
|
||||||||||
github_client = Github(constants.GTIHUB_TOKEN) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
also I think you want to pass the contents of the env var, not its name:
Suggested change
|
||||||||||
for image_meta in runtime.ordered_image_metas(): | ||||||||||
time.sleep(1) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... why? with a proper github token the rate limiting should not kick in |
||||||||||
source_repo_url, source_repo_branch = _get_upstream_source(runtime, image_meta, skip_branch_check=True) | ||||||||||
if not source_repo_url or 'github.com' not in source_repo_url: | ||||||||||
runtime.logger.info('Skipping PR check since there is no configured github source URL') | ||||||||||
continue | ||||||||||
|
||||||||||
public_repo_url, public_branch = runtime.get_public_upstream(source_repo_url) | ||||||||||
if not public_branch: | ||||||||||
public_branch = source_repo_branch | ||||||||||
_, org, repo_name = split_git_url(public_repo_url) | ||||||||||
if public_repo_url in upstreams: | ||||||||||
continue | ||||||||||
else: | ||||||||||
upstreams.append(public_repo_url) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need for
Suggested change
|
||||||||||
public_source_repo = github_client.get_repo(f'{org}/{repo_name}') | ||||||||||
pulls = public_source_repo.get_pulls(state='open', sort='created') | ||||||||||
for pr in pulls: | ||||||||||
time.sleep(1) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should go a lot faster without this
Suggested change
|
||||||||||
if pr.user.login == github_client.get_user().login and pr.base.ref == source_repo_branch: | ||||||||||
if pr.assignee is not None: | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so... PRs with no assignee are just ignored? |
||||||||||
if pr.assignee.email is not None: | ||||||||||
if pr.assignee.email not in retdata.keys(): | ||||||||||
retdata[pr.assignee.email] = {} | ||||||||||
if public_repo_url not in retdata[pr.assignee.email].keys(): | ||||||||||
retdata[pr.assignee.email][public_repo_url] = [] | ||||||||||
retdata[pr.assignee.email][public_repo_url].append("[{} ][created_at:{}]".format( | ||||||||||
pr.html_url, pr.created_at)) | ||||||||||
else: | ||||||||||
if "no assignee" not in retdata.keys(): | ||||||||||
retdata["no assignee"] = {} | ||||||||||
if public_repo_url not in retdata["no assignee"].keys(): | ||||||||||
retdata["no assignee"][public_repo_url] = [] | ||||||||||
retdata["no assignee"][public_repo_url].append("[{} ][created_at:{}]".format( | ||||||||||
pr.html_url, pr.created_at)) | ||||||||||
# format output | ||||||||||
for key, val in retdata.items(): | ||||||||||
if len(val) == 0: | ||||||||||
continue | ||||||||||
print(">[{}]".format(key)) | ||||||||||
for img, prs in val.items(): | ||||||||||
print(" -[{}]".format(img)) | ||||||||||
for pr in prs: | ||||||||||
print(" {}".format(pr)) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. formatting yaml yourself is a recipe for disaster, how about just using the |
||||||||||
|
||||||||||
|
||||||||||
@prs.command('open', short_help='Open PRs against upstream component repos that have a FROM that differs from ART metadata.') | ||||||||||
@click.option('--github-access-token', metavar='TOKEN', required=True, help='Github access token for user.') | ||||||||||
@click.option('--bug', metavar='BZ#', required=False, default=None, help='Title with Bug #: prefix') | ||||||||||
|
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 description here should note that the token env var is required