From 86de3af37fc871f57342ad7af9963a5475e961af Mon Sep 17 00:00:00 2001 From: Austin Bozowski Date: Wed, 25 May 2022 20:40:59 +0000 Subject: [PATCH] Split builds --- examples/chef/chef.py | 22 ++++++++++++-------- examples/chef/chef_util.py | 26 +++++++++++++++++++---- integrations/cloudbuild/chef.yaml | 34 ++++++++++++++++++++++--------- 3 files changed, 59 insertions(+), 23 deletions(-) diff --git a/examples/chef/chef.py b/examples/chef/chef.py index 5f241497bb9be8..2049da05e48656 100755 --- a/examples/chef/chef.py +++ b/examples/chef/chef.py @@ -176,7 +176,7 @@ def main(argv: Sequence[str]) -> None: dest="validate_zzz", action="store_true") parser.add_option("", "--use_zzz", help="Use pre generated output from the ZAP tool found in the zzz_generated folder. Used to decrease execution time of CI jobs", dest="use_zzz", action="store_true") - parser.add_option("", "--build_all", help="Builds all chef examples across all platforms and collates artifacts. Chef exits after completion.", + parser.add_option("", "--build_all", help="Builds all chef examples for the specified platform and collates artifacts. Chef exits after completion.", dest="build_all", action="store_true") parser.add_option( "", "--ci", help="Builds Chef examples defined in chef_util.ci_allowlist. Uses specified target. Chef exits after completion.", dest="ci", action="store_true") @@ -283,21 +283,25 @@ def main(argv: Sequence[str]) -> None: if options.build_all: print("Building all chef examples") os.environ['GNUARMEMB_TOOLCHAIN_PATH'] = os.environ['PW_ARM_CIPD_INSTALL_DIR'] - platforms_and_outputs = chef_util.cd_platforms_and_outputs + archive_prefix = "/workspace/artifacts/" + if not os.path.exists(archive_prefix): + # shutil.rmtree(archive_prefix) + os.mkdir(archive_prefix) + archive_suffix = ".tar.gz" + + cd_platforms_meta = chef_util.cd_platforms_meta for device in os.listdir(chef_devices_dir): target_file_ext = ".zap" if device.endswith(target_file_ext): device_name = device[:-len(target_file_ext)] - for platform, directory in platforms_and_outputs.items(): + for platform, platform_meta in cd_platforms_meta.items(): + directory = platform_meta['build_dir'] + label = platform_meta['platform_label'] output_dir = os.path.join(_CHEF_SCRIPT_PATH, directory) - command = './chef.py -czbr -d {} -t {}'.format(device_name, platform) + command = './chef.py -czbr -d {} -t {}'.format(device_name, options.build_target) print(f"Building {command}") subprocess.check_call(command, cwd=_CHEF_SCRIPT_PATH, shell=True) - archive_prefix = "/workspace/artifacts/" - if not os.path.exists(archive_prefix): - os.mkdir(archive_prefix) - archive_name = f"{platform}-chef-{device_name}-wifi-rpc" - archive_suffix = ".tar.gz" + archive_name = f"{label}-chef-{device_name}-wifi-rpc" archive_full_name = archive_prefix + archive_name + archive_suffix print(f"Adding build output to archive {archive_full_name}") with tarfile.open(archive_full_name, "w:gz") as tar: diff --git a/examples/chef/chef_util.py b/examples/chef/chef_util.py index 61aa0c462c7974..7530be3053c515 100644 --- a/examples/chef/chef_util.py +++ b/examples/chef/chef_util.py @@ -3,14 +3,32 @@ import os import hashlib + ci_allowlist = ['lighting-app.zap'] -cd_platforms_and_outputs = { - 'linux': 'linux/out', - 'esp32': 'esp32/build', - 'nrfconnect': 'nrfconnect/build', +cd_platforms_meta = { + 'linux': { + 'build_dir': 'linux/out', + 'platform_label': 'linux_x86', + }, + 'esp32': { + 'build_dir': 'esp32/build', + 'platform_label': 'esp32-m5stack', + }, + 'nrfconnect': { + 'build_dir': 'nrfconnect/build', + 'platform_label': 'nrf-nrf52840dk', + }, } +def bundle(platform: str): + if platform == 'linux': + pass + if platform == 'esp32': + pass + if platform == 'nrfconnect': + pass + def check_zap_master(repo_base_path: str) -> str: """Produces hash of ZAP submodule in branch master""" git_cmd = ["git", "ls-tree", "master", "third_party/zap/repo"] diff --git a/integrations/cloudbuild/chef.yaml b/integrations/cloudbuild/chef.yaml index 37d01efc3e8616..e4799555d9718d 100644 --- a/integrations/cloudbuild/chef.yaml +++ b/integrations/cloudbuild/chef.yaml @@ -1,26 +1,40 @@ steps: - - name: "connectedhomeip/chip-build-vscode:0.5.75" + + - name: "connectedhomeip/chip-build:0.5.73" env: - PW_ENVIRONMENT_ROOT=/pwenv args: - - "-c" - - source ./scripts/bootstrap.sh - id: Bootstrap - entrypoint: /usr/bin/bash + - >- + ./examples/chef/chef.py --build_all -t linux + id: Linux + entrypoint: ./scripts/run_in_build_env.sh + volumes: + - name: pwenv + path: /pwenv + + - name: "connectedhomeip/chip-build-esp32:0.5.73" + env: + - PW_ENVIRONMENT_ROOT=/pwenv + args: + - >- + ./examples/chef/chef.py --build_all -t esp32 + id: ESP32 + waitFor: + - Linux + entrypoint: ./scripts/run_in_build_env.sh volumes: - name: pwenv path: /pwenv - timeout: 900s - - name: "connectedhomeip/chip-build-vscode:0.5.75" + - name: "connectedhomeip/chip-build-nrf-platform:0.5.73" env: - PW_ENVIRONMENT_ROOT=/pwenv args: - >- - ./examples/chef/chef.py --build_all - id: CompileAll + ./examples/chef/chef.py --build_all -t nrfconnect + id: NRFConnect waitFor: - - Bootstrap + - ESP32 entrypoint: ./scripts/run_in_build_env.sh volumes: - name: pwenv