Skip to content

Commit

Permalink
client: Actually wait for the checks before moving on with committing
Browse files Browse the repository at this point in the history
  • Loading branch information
barthalion committed Nov 3, 2023
1 parent 195f7d5 commit 90b6e4e
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions flat-manager-client
Original file line number Diff line number Diff line change
Expand Up @@ -462,21 +462,28 @@ async def wait_for_job(session, job_url, token):
)
async def wait_for_checks(session, build_url, token):
print("Waiting for checks, if any...")
resp = await session.get(build_url + "/extended", headers={'Authorization': 'Bearer ' + token})
async with resp:
if resp.status == 404:
return
if resp.status >= 500:
raise ServerApiError(resp, await resp.text())
elif resp.status != 200:
raise ApiError(resp, await resp.text())
while True:
resp = await session.get(build_url + "/extended", headers={'Authorization': 'Bearer ' + token})
async with resp:
if resp.status == 404:
return
if resp.status >= 500:
raise ServerApiError(resp, await resp.text())
elif resp.status != 200:
raise ApiError(resp, await resp.text())

build = await resp.json()
build = await resp.json()

for check in build["checks"]:
print("Waiting for check: %s" % (check["check_name"]))
job_url = build_url + "/check/" + check["check_name"] + "/job"
await wait_for_job(session, job_url, token)
# wait for the repo to be validated
if build["build"]["repo_state"] == 1:
time.sleep(2)
else:
break

for check in build["checks"]:
print("Waiting for check: %s" % (check["check_name"]))
job_url = build_url + "/check/" + check["check_name"] + "/job"
await wait_for_job(session, job_url, token)

resp = await session.get(build_url + "/extended", headers={'Authorization': 'Bearer ' + token})
async with resp:
Expand All @@ -489,7 +496,7 @@ async def wait_for_checks(session, build_url, token):

build = await resp.json()
for check in build["checks"]:
if check["status"] == 2:
if check["status"] == 3:
print("\ Check {} has failed".format(check["check_name"]))
raise FailedJobError(check)

Expand Down

0 comments on commit 90b6e4e

Please sign in to comment.