Skip to content

Commit

Permalink
Script downstream check correlation (#1566)
Browse files Browse the repository at this point in the history
Adding a script that helps correlating
https://github.com/pulumi/pulumi-terraform-bridge/blob/master/.github/workflows/update-providers-test.yml
results. Forgive the Python and lack of integration into GitHub actions
but hoping it will prove useful as-is to make it easy to find failing
PRs and close succeeding ones. Courtesy @blampe for the logic.
  • Loading branch information
t0yv0 authored Dec 12, 2023
1 parent 0bd135b commit 69e0573
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions scripts/downstream_checks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import argparse
import json
import requests
import subprocess as sp

ap = argparse.ArgumentParser()
ap.add_argument('--hash', required=True)
args = ap.parse_args()
c = args.hash

query = """
{
search(query: "is:open is:pr org:pulumi ???", type: ISSUE, first: 100) {
edges {
node {
... on PullRequest {
number
url
mergeable
title
commits(last: 1) { nodes { commit { statusCheckRollup { state } } } }
}
}
}
}
}
""".replace("???", c)


token = sp.check_output(["gh", "auth", "token"]).decode('utf-8').strip()

resp = requests.post('https://api.github.com/graphql',
headers={'Authorization': f'bearer {token}'},
json={"query": query})

r = resp.json()

for e in r['data']['search']['edges']:
if e.get('node', {}).get('title', '') != f'Upgrade pulumi-terraform-bridge to {c}':
continue

checks = e.get('node', {}).get('commits', {}).get('nodes', [{}])[0]['commit']['statusCheckRollup']['state']
if checks == 'SUCCESS':
url = e['node']['url']
sp.check_call(['gh', 'pr', 'close', url])
else:
print('FAILED', e['node']['url'])

0 comments on commit 69e0573

Please sign in to comment.