From 6bf1871b7c4aeabffdfa00c6024889539813a62e Mon Sep 17 00:00:00 2001 From: Tomasz Jurtsch Date: Thu, 31 Dec 2020 10:04:21 +0100 Subject: [PATCH] Ensure that all the other jobs were completed before We use this simple counter condition to determine if all jobs were queued and completed. Not queued jobs aren't returned in API call. --- wait-for-statuses.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/wait-for-statuses.py b/wait-for-statuses.py index 1d1a283..105ffeb 100644 --- a/wait-for-statuses.py +++ b/wait-for-statuses.py @@ -10,15 +10,20 @@ + os.environ['GITHUB_RUN_ID'] \ + "/jobs" +numOfJobs = int(os.environ['NUM_OF_JOBS']) + while(True): time.sleep(60) - success = True + countCompleted = 0 + with urllib.request.urlopen(status_url) as url: data = json.loads(url.read().decode()) for j in data["jobs"]: - if(j["status"] != "completed" and j["name"] != "master-package"): - success = False - if(success): + if(j["status"] == "completed") + countCompleted += 1 + + print("Completed jobs:" + str(countCompleted) + ". Jobs overall: " + str(numOfJobs)) + if(countCompleted >= numOfJobs): break subprocess.call(os.environ['GITHUB_WORKSPACE'] + "/.github/scripts/master-package.sh")