Skip to content

Commit

Permalink
Print missing repos in downstream check script (#1869)
Browse files Browse the repository at this point in the history
fixes #1816

Hit it during
#1854

It now prints links for the repos which don't have PRs for the commit at
all:


```
FAILURE pulumi/pulumi-auth0#493
FAILURE pulumi/pulumi-oci#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
```
  • Loading branch information
VenelinMartinov authored Apr 12, 2024
1 parent 17265a0 commit a08acef
Showing 1 changed file with 35 additions and 4 deletions.
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()

0 comments on commit a08acef

Please sign in to comment.