mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-26 23:24:20 +02:00
ci: wrap checks with try block to avoid panic (#883)
This commit is contained in:
parent
938c4ccd52
commit
7e6e098e2b
@ -8,6 +8,7 @@
|
|||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
|
import traceback
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
from time import sleep, time
|
from time import sleep, time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -119,7 +120,7 @@ def main():
|
|||||||
try_download(build_id, dl_path)
|
try_download(build_id, dl_path)
|
||||||
else:
|
else:
|
||||||
# Try up to three times
|
# Try up to three times
|
||||||
MAX_ATTEMPTS = 3
|
MAX_ATTEMPTS = 5
|
||||||
success = False
|
success = False
|
||||||
|
|
||||||
for i in range(MAX_ATTEMPTS):
|
for i in range(MAX_ATTEMPTS):
|
||||||
@ -153,26 +154,31 @@ def main():
|
|||||||
|
|
||||||
for attempt in range(TRIES):
|
for attempt in range(TRIES):
|
||||||
print("Checking...")
|
print("Checking...")
|
||||||
status = check_build_status(key, build_id)
|
try:
|
||||||
if status.startswith("COMPLETE"):
|
status = check_build_status(key, build_id)
|
||||||
print("Build complete. Downloading artifact files.")
|
if status.startswith("COMPLETE"):
|
||||||
sleep(5)
|
print("Build complete. Downloading artifact files.")
|
||||||
try_download(build_id, dl_path)
|
sleep(5)
|
||||||
success = True
|
try_download(build_id, dl_path)
|
||||||
break
|
success = True
|
||||||
else:
|
|
||||||
print("Build status: {}".format(status or "unknown"))
|
|
||||||
if status == "ABORTED":
|
|
||||||
print("Build aborted, bailing.")
|
|
||||||
break
|
break
|
||||||
elif status.lower().startswith("fail"):
|
else:
|
||||||
print("Build failed, bailing.")
|
print("Build status: {}".format(status or "unknown"))
|
||||||
break
|
if status == "ABORTED":
|
||||||
elif attempt + 1 < TRIES:
|
print("Build aborted, bailing.")
|
||||||
sleep(SLEEP_SEC)
|
break
|
||||||
|
elif status.lower().startswith("fail"):
|
||||||
|
print("Build failed, bailing.")
|
||||||
|
break
|
||||||
|
elif attempt + 1 < TRIES:
|
||||||
|
sleep(SLEEP_SEC)
|
||||||
|
except Exception as ex:
|
||||||
|
print("Unexpected error:")
|
||||||
|
print(ex)
|
||||||
|
print(traceback.format_exc())
|
||||||
|
sleep(60) # Sleep for a minute if something went wrong, just in case.
|
||||||
else:
|
else:
|
||||||
print("Build failed to complete after {} minutes, bailing.".format(MINUTES))
|
print("Build failed to complete after {} minutes, bailing.".format(MINUTES))
|
||||||
continue
|
|
||||||
|
|
||||||
if not success:
|
if not success:
|
||||||
exit(2)
|
exit(2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user