-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check downstreams to make sure that there aren't any unmerged. (#1315)
Merged PR #1315.
- Loading branch information
1 parent
6e74928
commit 061bad3
Showing
4 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
# This file takes in only magic-modules, to get the code that | ||
# it runs. It does need the github API token. | ||
# It produces no output. | ||
platform: linux | ||
|
||
image_resource: | ||
type: docker-image | ||
source: | ||
# This task requires a container with python and the pip | ||
# package 'pygithub'. | ||
repository: gcr.io/magic-modules/python | ||
tag: '1.0' | ||
|
||
inputs: | ||
- name: mm-approved-prs | ||
|
||
params: | ||
GH_TOKEN: "" | ||
|
||
run: | ||
path: mm-approved-prs/.ci/magic-modules/ensure_downstreams_merged.py | ||
args: | ||
- mm-approved-prs/.git/id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env python | ||
|
||
import get_downstream_prs | ||
from github import Github | ||
import os | ||
import re | ||
import operator | ||
import itertools | ||
import sys | ||
|
||
|
||
def get_unmerged_prs(g, dependencies): | ||
parsed_dependencies = [re.match(r'https://github.com/([\w-]+/[\w-]+)/pull/(\d+)', d).groups() | ||
for d in dependencies] | ||
parsed_dependencies.sort(key=operator.itemgetter(0)) | ||
unmerged_dependencies = [] | ||
# group those dependencies by repo - e.g. [("terraform-provider-google", ["123", "456"]), ...] | ||
for r, pulls in itertools.groupby(parsed_dependencies, key=operator.itemgetter(0)): | ||
repo = g.get_repo(r) | ||
for pull in pulls: | ||
# check whether the PR is merged - if it is, add it to the list. | ||
pr = repo.get_pull(int(pull[1])) | ||
if not pr.is_merged(): | ||
unmerged_dependencies.append(pull) | ||
return unmerged_dependencies | ||
|
||
|
||
if __name__ == '__main__': | ||
g = Github(os.environ.get('GH_TOKEN')) | ||
assert len(sys.argv) == 2 | ||
id_filename = sys.argv[1] | ||
unmerged = get_unmerged_prs( | ||
g, get_downstream_prs.get_github_dependencies( | ||
g, int(open(id_filename).read()))) | ||
if unmerged: | ||
raise ValueError("some PRs are unmerged", unmerged) |
Empty file.