Skip to content

Commit

Permalink
fix check for downstreams
Browse files Browse the repository at this point in the history
  • Loading branch information
emilymye authored and modular-magician committed Sep 13, 2019
1 parent 1b289ee commit 1506011
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
24 changes: 14 additions & 10 deletions .ci/magic-modules/downstream_changelog_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
unset.
"""
from pyutils import strutils, downstreams
from github import Github
import github
import os
import sys
import argparse
Expand Down Expand Up @@ -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)

Expand All @@ -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.
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions .ci/magic-modules/pyutils/downstreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


0 comments on commit 1506011

Please sign in to comment.