Skip to content

Commit

Permalink
Ensure that all the other jobs were completed before
Browse files Browse the repository at this point in the history
We use this simple counter condition to determine if
all jobs were queued and completed. Not queued jobs
aren't returned in API call.
  • Loading branch information
tjurtsch committed Dec 31, 2020
1 parent ca3f9ef commit 6bf1871
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions wait-for-statuses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 6bf1871

Please sign in to comment.