Skip to content
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

Print missing repos in downstream check script #1869

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions scripts/downstream_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@

QUERY = """
{
search(query: "is:open is:pr org:pulumi ???", type: ISSUE, first: 100) {
search(query: "is:pr org:pulumi ??? in:title", type: ISSUE, first: 100) {
edges {
node {
... on PullRequest {
number
url
mergeable
title
closed
repository {
name
}
commits(last: 1) {
nodes {
commit {
Expand All @@ -40,11 +44,22 @@
"""


def get_provider_map() -> dict[str, bool]:
resp = requests.get(
"https://raw.githubusercontent.com/pulumi/ci-mgmt/master/provider-ci/providers.json"
)
return {k: False for k in resp.json()}


def get_title(query_result: Any) -> str:
return str(query_result.get("node", {}).get("title", ""))


def iterate_prs(query_result: Any) -> Iterator[tuple[str, list[Any]]]:
def get_repo_name(query_result: Any) -> str:
return str(query_result.get("node", {}).get("repository", {}).get("name", ""))


def iterate_prs(query_result: Any) -> Iterator[tuple[str, bool, list[Any], str, str]]:
for e in query_result.get("data", {}).get("search", {}).get("edges", {}):
title = get_title(e)
checks = (
Expand All @@ -55,7 +70,9 @@ def iterate_prs(query_result: Any) -> Iterator[tuple[str, list[Any]]]:
.get("nodes", [{}])
)
url = e["node"]["url"]
yield title, checks, url
repo = get_repo_name(e)
closed = e["node"]["closed"]
yield title, closed, checks, url, repo


def get_sentinel_status(checks: list[Any]) -> str:
Expand All @@ -81,6 +98,10 @@ def get_gh_data(token: str, query: str) -> dict[str, Any]:
return resp.json()


def repo_actions_url(repo: str) -> str:
return "https://github.com/pulumi/pulumi-" + repo + "/actions/workflows/upgrade-bridge.yml"


def main():
ap = argparse.ArgumentParser()
ap.add_argument("--hash", required=True)
Expand All @@ -93,17 +114,27 @@ def main():

pr_suffix = f"Upgrade pulumi-terraform-bridge to {c}"

for pr_title, pr_checks, url in iterate_prs(r):
provider_map = get_provider_map()

for pr_title, closed, pr_checks, url, repo in iterate_prs(r):
if not pr_title.endswith(pr_suffix):
continue

provider_map[repo.removeprefix("pulumi-")] = True

if closed:
continue

sentinel_status = get_sentinel_status(pr_checks)
if sentinel_status == "SUCCESS":
print("SUCCESS", url)
sp.check_call(["gh", "pr", "close", url])
else:
print(sentinel_status, url)

for missing_repo in {repo for repo in provider_map if not provider_map[repo]}:
print("MISSING", repo_actions_url(missing_repo))


if __name__ == "__main__":
main()