-
Notifications
You must be signed in to change notification settings - Fork 3k
Improve domain handling and status checking of updated examples. #5332
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
Changes from all commits
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 |
---|---|---|
|
@@ -36,7 +36,7 @@ | |
# | ||
# Command usage: | ||
# | ||
# update.py -c <config file> - T <github_token> -l <logging level> -f -b | ||
# update.py -c <config file> - T <github_token> -f -b -s | ||
# | ||
# Where: | ||
# -c <config file> - Optional path to an examples file. | ||
|
@@ -47,8 +47,10 @@ | |
# -b - Update branched repos. This will use the "src-branch" and | ||
# "dst-branch" parameters in the 'via-branch' section. The destination | ||
# branch is created from the source branch (if it doesn't already exist). | ||
# -s - Show the status of any pull requests with a tag matching that in the | ||
# json config file | ||
# | ||
# The options -f and -b are mutually exlusive. Only one can be specified. | ||
# The options -f, -b and -s are mutually exlusive. Only one can be specified. | ||
# | ||
# | ||
|
||
|
@@ -431,6 +433,47 @@ def create_work_directory(path): | |
|
||
os.makedirs(path) | ||
|
||
def check_update_status(examples, github, tag): | ||
""" Check the status of previously raised update pull requests | ||
|
||
Args: | ||
examples - list of examples which should have had PRs raised against them. | ||
github - github rest API instance | ||
tag - release tag used for the update | ||
|
||
""" | ||
|
||
for example in examples: | ||
|
||
repo_name = ''.join(['ARMmbed/', example['name']]) | ||
try: | ||
repo = github.get_repo(repo_name, False) | ||
|
||
except Exception as exc: | ||
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. Can you not cache 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. As far as I know there is no specific documentation on how the pygithub module returns the github exceptions. I've had a lot of issues in the past trying to narrow down a list and TBH in this case if any exception comes back at all then it's basically fatal... 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. Sounds good. I'm generally trying to promote defensive programming because python's "unchecked exceptions" error handling is beginning to drive me crazy. 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. I agree, we could definitely do with more defensive programming ! |
||
text = "Cannot access: " + str(repo_name) | ||
userlog.error(text) | ||
userlog.exception(exc) | ||
sys.exit(1) | ||
|
||
# Create the full repository filter component | ||
org_str = ''.join(['repo:ARMmbed/', example['name']]) | ||
filt = ' '.join([org_str, 'is:pr', tag]) | ||
merged = False | ||
|
||
issues = github.search_issues(query=(filt)) | ||
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. Are the 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. It's the pygithub syntax for that command... 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. Thanks! |
||
pr_list = [repo.get_pull(issue.number) for issue in issues] | ||
|
||
# Should only be one matching PR but just in case, go through paginated list | ||
for pr in pr_list: | ||
if pr.merged: | ||
userlog.info("%s - '%s': MERGED", example['name'], pr.title) | ||
elif pr.state == 'open': | ||
userlog.info("%s - '%s': PENDING", example['name'], pr.title) | ||
elif pr.state == 'closed': | ||
userlog.info("%s - '%s': CLOSED NOT MERGED", example['name'], pr.title) | ||
else: | ||
userlog.error("%s: Cannot find a pull request for %s", example['name'], tag) | ||
|
||
if __name__ == '__main__': | ||
|
||
parser = argparse.ArgumentParser(description=__doc__, | ||
|
@@ -441,6 +484,7 @@ def create_work_directory(path): | |
exclusive = parser.add_mutually_exclusive_group(required=True) | ||
exclusive.add_argument('-f', '--fork', help="Update a fork", action='store_true') | ||
exclusive.add_argument('-b', '--branch', help="Update a branch", action='store_true') | ||
exclusive.add_argument('-s', '--status', help="Show examples update status", action='store_true') | ||
|
||
args = parser.parse_args() | ||
|
||
|
@@ -451,8 +495,6 @@ def create_work_directory(path): | |
sys.exit(1) | ||
json_data = json.load(config) | ||
|
||
# Create working directory | ||
create_work_directory('examples') | ||
|
||
github = Github(args.github_token) | ||
config = json_data['update-config'] | ||
|
@@ -462,6 +504,15 @@ def create_work_directory(path): | |
src = "master" | ||
dst = None | ||
|
||
if args.status: | ||
|
||
# This option should only be called after an update has been performed | ||
check_update_status(json_data['examples'], github, tag) | ||
exit(0) | ||
|
||
# Create working directory | ||
create_work_directory('examples') | ||
|
||
if args.fork: | ||
user = config['via-fork']['github-user'] | ||
elif args.branch: | ||
|
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.
While I'm sure we want to test this, I'm sure they don't want it publicly advertised.
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.
The client team asked for it to be added.....
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.
Okay!