From 9bb53300680a0e14a3a9ee4cf990c372f95674f5 Mon Sep 17 00:00:00 2001 From: Sebastian Gode Date: Tue, 20 Sep 2022 08:24:06 +0000 Subject: [PATCH] Failure list --- tools/attention_list.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/tools/attention_list.py b/tools/attention_list.py index daeb9c15..8e03c9e8 100644 --- a/tools/attention_list.py +++ b/tools/attention_list.py @@ -67,7 +67,9 @@ def main(): break pull_path = 'repos/docs/' + status_path = 'repos/docs/' pulls = [] + failed_commits = [] for repo in repositories: try: @@ -76,6 +78,28 @@ def main(): if res.json(): for pull in res.json(): pulls.append(pull) + + for pull in pulls: + try: + url = args.url + status_path + repo['name'] + '/commits/' + pull['head']['ref'] + '/statuses?limit=1' + res_sta = requests.request('GET', url=url, headers=headers) + if res_sta.json(): + if res_sta.json()[0]['status'] == 'failure': + # print("Pull Request " + pull['url'] + " has a failed check!") + failed_commits.append({ + 'url': pull['url'], + 'status': res_sta.json()[0]['status'], + 'target_url': res_sta.json()[0]['target_url'], + 'created_at': pull['created_at'], + 'updated_at': res_sta.json()[0]['updated_at'] + }) + continue + else: + continue + except Exception as e: + print("An error has occured: " + str(e)) + print("The request status is: " + str(res_sta.status_code) + " | " + str(res_sta.reason)) + break continue else: continue @@ -84,7 +108,12 @@ def main(): print("The request status is: " + str(res.status_code) + " | " + str(res.reason)) break - # print(len(pulls)) + + print(json.dumps(failed_commits)) + + + +