Skip to content

Commit

Permalink
Add error handling to build all
Browse files Browse the repository at this point in the history
  • Loading branch information
aBozowski committed Jun 10, 2022
1 parent 083b072 commit 5783829
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions examples/chef/chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,21 +486,42 @@ def main(argv: Sequence[str]) -> None:
archive_prefix = "/workspace/artifacts/"
archive_suffix = ".tar.gz"
os.makedirs(archive_prefix, exist_ok=True)
failed_builds = []
for device_name in _DEVICE_LIST:
for platform, label in cicd_config["cd_platforms"].items():
command = f"./chef.py -cbr --use_zzz -d {device_name} -t {platform}"
flush_print(f"Building {command}", with_border=True)
shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}")
shell.run_cmd("export GNUARMEMB_TOOLCHAIN_PATH=\"$PW_ARM_CIPD_INSTALL_DIR\"")
shell.run_cmd(command)
bundle(platform, device_name)
try:
shell.run_cmd(command)
except RuntimeError as build_fail_error:
failed_builds.append((device_name, platform, "build"))
flush_print(str(build_fail_error))
break
try:
bundle(platform, device_name)
except FileNotFoundError as bundle_fail_error:
failed_builds.append((device_name, platform, "bundle"))
flush_print(str(bundle_fail_error))
break
archive_name = f"{label}-{device_name}"
archive_full_name = archive_prefix + archive_name + archive_suffix
flush_print(f"Adding build output to archive {archive_full_name}")
if os.path.exists(archive_full_name):
os.remove(archive_full_name)
with tarfile.open(archive_full_name, "w:gz") as tar:
tar.add(_CD_STAGING_DIR, arcname=".")
if len(failed_builds) == 0:
flush_print("No build failures", with_border=True)
else:
flush_print("Logging build failures", with_border=True)
for failed_build in failed_builds:
fail_log = f"""\
Device: {failed_build[0]},
Platform: {failed_build[1]},
Phase: {failed_build[2]}"""
flush_print(unwrap_cmd(fail_log))
exit(0)

#
Expand Down

0 comments on commit 5783829

Please sign in to comment.