From a08acefddc0cb5996fd62c487e5b5940f1814644 Mon Sep 17 00:00:00 2001 From: VenelinMartinov Date: Fri, 12 Apr 2024 15:38:35 +0100 Subject: [PATCH] Print missing repos in downstream check script (#1869) fixes https://github.com/pulumi/pulumi-terraform-bridge/issues/1816 Hit it during https://github.com/pulumi/pulumi-terraform-bridge/pull/1854 It now prints links for the repos which don't have PRs for the commit at all: ``` FAILURE https://github.com/pulumi/pulumi-auth0/pull/493 FAILURE https://github.com/pulumi/pulumi-oci/pull/431 MISSING https://github.com/pulumi/pulumi-opsgenie/actions/workflows/upgrade-bridge.yml MISSING https://github.com/pulumi/pulumi-splunk/actions/workflows/upgrade-bridge.yml MISSING https://github.com/pulumi/pulumi-libvirt/actions/workflows/upgrade-bridge.yml MISSING https://github.com/pulumi/pulumi-minio/actions/workflows/upgrade-bridge.yml MISSING https://github.com/pulumi/pulumi-kafka/actions/workflows/upgrade-bridge.yml MISSING https://github.com/pulumi/pulumi-aws/actions/workflows/upgrade-bridge.yml MISSING https://github.com/pulumi/pulumi-onelogin/actions/workflows/upgrade-bridge.yml MISSING https://github.com/pulumi/pulumi-cloudamqp/actions/workflows/upgrade-bridge.yml MISSING https://github.com/pulumi/pulumi-rabbitmq/actions/workflows/upgrade-bridge.yml MISSING https://github.com/pulumi/pulumi-newrelic/actions/workflows/upgrade-bridge.yml MISSING https://github.com/pulumi/pulumi-dnsimple/actions/workflows/upgrade-bridge.yml MISSING https://github.com/pulumi/pulumi-nomad/actions/workflows/upgrade-bridge.yml MISSING https://github.com/pulumi/pulumi-mailgun/actions/workflows/upgrade-bridge.yml MISSING https://github.com/pulumi/pulumi-mysql/actions/workflows/upgrade-bridge.yml MISSING https://github.com/pulumi/pulumi-sumologic/actions/workflows/upgrade-bridge.yml MISSING https://github.com/pulumi/pulumi-vsphere/actions/workflows/upgrade-bridge.yml MISSING https://github.com/pulumi/pulumi-keycloak/actions/workflows/upgrade-bridge.yml MISSING https://github.com/pulumi/pulumi-slack/actions/workflows/upgrade-bridge.yml MISSING https://github.com/pulumi/pulumi-vault/actions/workflows/upgrade-bridge.yml ``` --- scripts/downstream_checks.py | 39 ++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/scripts/downstream_checks.py b/scripts/downstream_checks.py index 4d796d7dc..cc56b70bd 100644 --- a/scripts/downstream_checks.py +++ b/scripts/downstream_checks.py @@ -7,7 +7,7 @@ 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 { @@ -15,6 +15,10 @@ url mergeable title + closed + repository { + name + } commits(last: 1) { nodes { commit { @@ -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 = ( @@ -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: @@ -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) @@ -93,10 +114,17 @@ 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) @@ -104,6 +132,9 @@ def main(): 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()