diff --git a/.ci/magic-modules/downstream_changelog_metadata.py b/.ci/magic-modules/downstream_changelog_metadata.py index b1d3643c9bda..7ff4af8b8143 100755 --- a/.ci/magic-modules/downstream_changelog_metadata.py +++ b/.ci/magic-modules/downstream_changelog_metadata.py @@ -11,7 +11,7 @@ unset. """ from pyutils import strutils, downstreams -from github import Github +import github import os import sys import argparse @@ -46,20 +46,18 @@ def downstream_changelog_info(gh, upstream_pr_num, changelog_repos): print "Labels: %s" % labels_to_add parsed_urls = downstreams.get_parsed_downstream_urls(gh, upstream_pr.number) - if not parsed_urls: - print "No downstreams found for upstream PR %d, returning!" % ( - upstream_pr.number) - return + found = False for repo_name, pulls in parsed_urls: + found = True print "Found downstream PR for repo %s" % repo_name - + if repo_name not in changelog_repos: print "[DEBUG] skipping repo %s with no CHANGELOG" % repo_name continue print "Generating changelog for pull requests in %s" % repo_name - + print "Fetching repo %s" % repo_name ghrepo = gh.get_repo(repo_name) @@ -68,6 +66,9 @@ def downstream_changelog_info(gh, upstream_pr_num, changelog_repos): pr = ghrepo.get_pull(int(prnum)) set_changelog_info(pr, release_note, labels_to_add) + if not found: + print "No downstreams found for upstream PR %d, returning!" % upstream_pr.number + def set_changelog_info(gh_pull, release_note, labels_to_add): """Set release note and labels on a downstream PR in Github. @@ -95,9 +96,12 @@ def set_changelog_info(gh_pull, release_note, labels_to_add): print "Skipping, no downstreams repos given to downstream changelog info for" sys.exit(0) - gh = Github(os.environ.get('GITHUB_TOKEN')) - + gh = github.Github(os.environ.get('GITHUB_TOKEN')) assert len(sys.argv) == 2, "expected id filename as argument" with open(sys.argv[1]) as f: pr_num = int(f.read()) - downstream_changelog_info(gh, pr_num, downstream_repos) + try: + downstream_changelog_info(gh, pr_num, downstream_repos) + except e: + print "got error %s" % e + raise e \ No newline at end of file diff --git a/.ci/magic-modules/pyutils/downstreams.py b/.ci/magic-modules/pyutils/downstreams.py index 7f1a2be941d4..e26e767878cb 100644 --- a/.ci/magic-modules/pyutils/downstreams.py +++ b/.ci/magic-modules/pyutils/downstreams.py @@ -81,9 +81,9 @@ def get_downstream_urls(client, pr_num): List of downstream PR URLs. """ urls = [] + print "Getting downstream URLs for PR %d..." % pr_num pr = client.get_repo(UPSTREAM_REPO).get_pull(pr_num) for comment in pr.get_issue_comments(): urls = urls + find_dependency_urls_in_comment(comment.body) + print "Found downstream URLs: %s" % urls return urls - -