From 5783829bce34978942662910a92bdd9c866cb75f Mon Sep 17 00:00:00 2001 From: Austin Bozowski Date: Fri, 10 Jun 2022 17:48:39 +0000 Subject: [PATCH] Add error handling to build all --- examples/chef/chef.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/examples/chef/chef.py b/examples/chef/chef.py index 4bd9bac930c186..63e31491e2697d 100755 --- a/examples/chef/chef.py +++ b/examples/chef/chef.py @@ -486,14 +486,25 @@ 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}") @@ -501,6 +512,16 @@ def main(argv: Sequence[str]) -> None: 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) #