From a0e33504ec8b635bea75efb1216bb493673a15fa Mon Sep 17 00:00:00 2001 From: Sarah GLINER Date: Tue, 5 Sep 2023 11:20:00 +0200 Subject: [PATCH] outi --- .github/workflows/_build_nanos.yml | 6 ++-- .github/workflows/_build_nanosp.yml | 10 +++---- .github/workflows/_build_nanox.yml | 10 +++---- .github/workflows/_build_stax.yml | 10 +++---- .github/workflows/_test_devices.yml | 10 +++---- scripts/build_and_test/build_app.py | 45 ++++++++++------------------- scripts/build_and_test/test_app.py | 41 ++++++++++---------------- scripts/output_scripts/status.py | 17 ++++++----- 8 files changed, 64 insertions(+), 85 deletions(-) diff --git a/.github/workflows/_build_nanos.yml b/.github/workflows/_build_nanos.yml index b78017c..adf2ab1 100644 --- a/.github/workflows/_build_nanos.yml +++ b/.github/workflows/_build_nanos.yml @@ -21,11 +21,11 @@ jobs: - name: Setup repos run: | - python3 scripts/build_and_test/main.py --input_file input_files/input_test.json + python3 scripts/build_and_test/main.py --input_file input_files/input.json - name: Launch build nanos run: | - python3 scripts/build_and_test/main.py --sdk_ref ${{ inputs.sdk_ref}} --input_file input_files/input_test.json --build --nanos --skip_setup --output_file build_nanos.json + python3 scripts/build_and_test/main.py --sdk_ref ${{ inputs.sdk_ref}} --input_file input_files/input.json --build --nanos --skip_setup --output_file build_nanos.json #- name: Push info to DB # run: | @@ -44,4 +44,4 @@ jobs: - name: Set job status run: | - python3 scripts/output_scripts/status.py --input_file build_nanos.json + python3 scripts/output_scripts/status.py --input_file build_nanos.json --key build diff --git a/.github/workflows/_build_nanosp.yml b/.github/workflows/_build_nanosp.yml index acc3025..0089522 100644 --- a/.github/workflows/_build_nanosp.yml +++ b/.github/workflows/_build_nanosp.yml @@ -21,11 +21,11 @@ jobs: - name: Setup repos run: | - python3 scripts/build_and_test/main.py --input_file input_files/input_test.json + python3 scripts/build_and_test/main.py --input_file input_files/input.json - name: Launch build nanosp run: | - python3 scripts/build_and_test/main.py --sdk_ref ${{ inputs.sdk_ref}} --input_file input_files/input_test.json --build --nanosp --skip_setup --output_file build_nanosp.json + python3 scripts/build_and_test/main.py --sdk_ref ${{ inputs.sdk_ref}} --input_file input_files/input.json --build --nanosp --skip_setup --output_file build_nanosp.json #- name: Push info to DB # run: | @@ -35,13 +35,13 @@ jobs: uses: actions/upload-artifact@v3 with: name: report.json - path: build_output_nanosp.json + path: build_nanosp.json - name: Convert to markdown run: | - python3 scripts/output_scripts/convert.py --input_file build_output_nanosp.json --output_file out.md --key build + python3 scripts/output_scripts/convert.py --input_file build_nanosp.json --output_file out.md --key build cat out.md >> $GITHUB_STEP_SUMMARY - name: Set job status run: | - python3 scripts/output_scripts/status.py --input_file build_output_nanosp.json + python3 scripts/output_scripts/status.py --input_file build_nanosp.json --key build diff --git a/.github/workflows/_build_nanox.yml b/.github/workflows/_build_nanox.yml index ccd01c5..76f0bb3 100644 --- a/.github/workflows/_build_nanox.yml +++ b/.github/workflows/_build_nanox.yml @@ -21,11 +21,11 @@ jobs: - name: Setup repos run: | - python3 scripts/build_and_test/main.py --input_file input_files/input_test.json + python3 scripts/build_and_test/main.py --input_file input_files/input.json - name: Launch build nanox run: | - python3 scripts/build_and_test/main.py --sdk_ref ${{ inputs.sdk_ref}} --input_file input_files/input_test.json --build --nanox --skip_setup --output_file build_nanox.json + python3 scripts/build_and_test/main.py --sdk_ref ${{ inputs.sdk_ref}} --input_file input_files/input.json --build --nanox --skip_setup --output_file build_nanox.json #- name: Push info to DB # run: | @@ -35,13 +35,13 @@ jobs: uses: actions/upload-artifact@v3 with: name: report.json - path: build_output_nanox.json + path: build_nanox.json - name: Convert to markdown run: | - python3 scripts/output_scripts/convert.py --input_file build_output_nanox.json --output_file out.md --key build + python3 scripts/output_scripts/convert.py --input_file build_nanox.json --output_file out.md --key build cat out.md >> $GITHUB_STEP_SUMMARY - name: Set job status run: | - python3 scripts/output_scripts/status.py --input_file build_output_nanox.json + python3 scripts/output_scripts/status.py --input_file build_nanox.json --key build diff --git a/.github/workflows/_build_stax.yml b/.github/workflows/_build_stax.yml index 80f13e2..b3ea6e8 100644 --- a/.github/workflows/_build_stax.yml +++ b/.github/workflows/_build_stax.yml @@ -21,11 +21,11 @@ jobs: - name: Setup repos run: | - python3 scripts/build_and_test/main.py --input_file input_files/input_test.json + python3 scripts/build_and_test/main.py --input_file input_files/input.json - name: Launch build stax run: | - python3 scripts/build_and_test/main.py --sdk_ref ${{ inputs.sdk_ref}} --input_file input_files/input_test.json --build --stax --skip_setup --output_file build_stax.json + python3 scripts/build_and_test/main.py --sdk_ref ${{ inputs.sdk_ref}} --input_file input_files/input.json --build --stax --skip_setup --output_file build_stax.json #- name: Push info to DB # run: | @@ -35,13 +35,13 @@ jobs: uses: actions/upload-artifact@v3 with: name: report.json - path: build_output_stax.json + path: build_stax.json - name: Convert to markdown run: | - python3 scripts/output_scripts/convert.py --input_file build_output_stax.json --output_file out.md --key build + python3 scripts/output_scripts/convert.py --input_file build_stax.json --output_file out.md --key build cat out.md >> $GITHUB_STEP_SUMMARY - name: Set job status run: | - python3 scripts/output_scripts/status.py --input_file build_output_stax.json + python3 scripts/output_scripts/status.py --input_file build_stax.json --key build diff --git a/.github/workflows/_test_devices.yml b/.github/workflows/_test_devices.yml index e78c347..936705b 100644 --- a/.github/workflows/_test_devices.yml +++ b/.github/workflows/_test_devices.yml @@ -43,7 +43,7 @@ jobs: - name: Setup repos run: | - python3 scripts/build_and_test/main.py --input_file input_files/input_test.json + python3 scripts/build_and_test/main.py --input_file input_files/input.json - name: Install tests dependencies run: | @@ -52,17 +52,17 @@ jobs: - name: Launch test nanosp if: ${{ inputs.run_nanosp }} run: | - python3 scripts/build_and_test/main.py --sdk_ref ${{ inputs.sdk_ref_nanosp }} --input_file input_files/input_test.json --test --nanosp --skip_setup --output_file test_nanosp.json + python3 scripts/build_and_test/main.py --sdk_ref ${{ inputs.sdk_ref_nanosp }} --input_file input_files/input.json --test --nanosp --skip_setup --output_file test_nanosp.json - name: Launch test nanox if: ${{ inputs.run_nanox }} run: | - python3 scripts/build_and_test/main.py --sdk_ref ${{ inputs.sdk_ref_nanox }} --input_file input_files/input_test.json --test --nanox --skip_setup --output_file test_nanox.json + python3 scripts/build_and_test/main.py --sdk_ref ${{ inputs.sdk_ref_nanox }} --input_file input_files/input.json --test --nanox --skip_setup --output_file test_nanox.json - name: Launch test stax if: ${{ inputs.run_stax }} run: | - python3 scripts/build_and_test/main.py --sdk_ref ${{ inputs.sdk_ref_stax }} --input_file input_files/input_test.json --test --stax --skip_setup --output_file test_stax.json + python3 scripts/build_and_test/main.py --sdk_ref ${{ inputs.sdk_ref_stax }} --input_file input_files/input.json --test --stax --skip_setup --output_file test_stax.json - name: Merge output files run: | @@ -81,4 +81,4 @@ jobs: - name: Set job status run: | - python3 scripts/output_scripts/status.py --input_file test_output.json + python3 scripts/output_scripts/status.py --input_file test_output.json --key test diff --git a/scripts/build_and_test/build_app.py b/scripts/build_and_test/build_app.py index e683287..645c67a 100644 --- a/scripts/build_and_test/build_app.py +++ b/scripts/build_and_test/build_app.py @@ -16,29 +16,29 @@ def build_variant(target: str, sdk_path: str, variant_param: str, variant_value: return error -def build_all_variants(target: str, sdk_path: str, variant_param: str, variant_list: list, - variants_blacklist: list, app_build_path: Path): +def build_all_variants(target: str, sdk_path: str, variant_param: str, variant_list: list, app_build_path: Path): output = {} for variant in variant_list: - if variant not in variants_blacklist: - error = build_variant(target, sdk_path, variant_param, variant, app_build_path) + error = build_variant(target, sdk_path, variant_param, variant, app_build_path) - if (error): - output[variant] = "Fail" - else: - output[variant] = "Success" + if (error): + output[variant] = "Fail" + else: + output[variant] = "Success" return output def build_device(device: Device, variant_param: str, app_build_path: Path, sdk_path: Path, app_json: dict): + blacklist = app_json.get("build_blacklist", "[]") + + if device.model_name in blacklist: + return "Skipped" + variants = app_json.get(f"variants_{device.model_name}", []) - variants_blacklist = app_json.get(f"variants_{device.model_name}_blacklist", []) variant_output = {} - if device.selected and len(variants) > 0: - variant_output = build_all_variants(device.target_name, sdk_path, variant_param, variants, - variants_blacklist, app_build_path) + variant_output = build_all_variants(device.target_name, sdk_path, variant_param, variants, app_build_path) return variant_output @@ -47,32 +47,19 @@ def build_all_devices(devices: Devices, sdk_path: Path, app_json: dict, workdir: repo_name = app_json.get("name") variant_param = app_json.get("variant_param") app_build_path = workdir / Path(app_json.get("name") + "/" + app_json.get("build_path", ".")) - blacklist = app_json.get("build_blacklist", "[]") output = { "name": repo_name, } output["build"] = {} - if "nanos" in blacklist: - nanos_output = "Skipped" - else: - nanos_output = build_device(devices.nanos, variant_param, app_build_path, sdk_path, app_json) + nanos_output = build_device(devices.nanos, variant_param, app_build_path, sdk_path, app_json) - if "nanosp" in blacklist: - nanosp_output = "Skipped" - else: - nanosp_output = build_device(devices.nanosp, variant_param, app_build_path, sdk_path, app_json) + nanosp_output = build_device(devices.nanosp, variant_param, app_build_path, sdk_path, app_json) - if "nanox" in blacklist: - nanox_output = "Skipped" - else: - nanox_output = build_device(devices.nanox, variant_param, app_build_path, sdk_path, app_json) + nanox_output = build_device(devices.nanox, variant_param, app_build_path, sdk_path, app_json) - if "stax" in blacklist: - stax_output = "Skipped" - else: - stax_output = build_device(devices.stax, variant_param, app_build_path, sdk_path, app_json) + stax_output = build_device(devices.stax, variant_param, app_build_path, sdk_path, app_json) if nanos_output: output["build"]["nanos"] = nanos_output diff --git a/scripts/build_and_test/test_app.py b/scripts/build_and_test/test_app.py index 2b8bbff..bb37cd8 100644 --- a/scripts/build_and_test/test_app.py +++ b/scripts/build_and_test/test_app.py @@ -3,9 +3,9 @@ from build_app import build_variant from utils import run_cmd -def test(model: str, app_test_path: Path): +def test(model: str, app_test_path: Path, app_build_path: Path): output = {} - error = run_cmd(f"pytest {app_test_path}/ --tb=short -v --device {model} -k version", cwd=".", no_throw=True) + error = run_cmd(f"pytest {app_test_path}/ --tb=short -v --device {model} -k version", cwd=app_build_path, no_throw=True) if (error): output = "Fail" @@ -19,12 +19,15 @@ def install_dependencies(app_test_path: Path): error = run_cmd("pip install -r requirements.txt", cwd=app_test_path, no_throw=True) return error -def test_device(device: Device, variant_param: str, app_build_path: Path, app_test_path: Path, sdk_path: Path, extra_flags: str): +def test_device(device: Device, variant_param: str, app_build_path: Path, app_test_path: Path, sdk_path: Path, extra_flags: str, blacklist: str): test_output = {} if not device.selected: return + if device.model_name in blacklist: + return "Skipped" + if install_dependencies(app_test_path): print("Error installing dependencies") return "Fail" @@ -32,7 +35,7 @@ def test_device(device: Device, variant_param: str, app_build_path: Path, app_te if build_variant(device.target_name, sdk_path, "", "", app_build_path): return "Fail" - test_output = test(device.model_name, app_test_path) + test_output = test(device.model_name, app_test_path, app_build_path) print(test_output) return test_output @@ -42,7 +45,7 @@ def test_all_devices(devices: Devices, sdk_path: Path, app_json: dict, workdir: repo_name = app_json.get("name") variant_param = app_json.get("variant_param") app_build_path = workdir / Path(app_json.get("name") + "/" + app_json.get("build_path", ".")) - app_test_path = workdir / Path(app_json.get("name") + "/" + app_json.get("test_path", ".")) + app_test_path = workdir / Path(app_json.get("name") + "/" + app_json.get("test_dir", ".")) extra_flags = app_json.get("extra_flags", "") blacklist = app_json.get("build_blacklist", "[]") @@ -53,30 +56,18 @@ def test_all_devices(devices: Devices, sdk_path: Path, app_json: dict, workdir: blacklist = app_json.get(f"test_blacklist", []) - if "nanos" in blacklist: - nanos_output = "Skipped" - else: - nanos_output = test_device(devices.nanos, variant_param, app_build_path, app_test_path, - sdk_path, extra_flags) + nanos_output = test_device(devices.nanos, variant_param, app_build_path, app_test_path, + sdk_path, extra_flags, blacklist) - if "nanosp" in blacklist: - nanosp_output = "Skipped" - else: - nanosp_output = test_device(devices.nanosp, variant_param, app_build_path, app_test_path, - sdk_path, extra_flags) + nanosp_output = test_device(devices.nanosp, variant_param, app_build_path, app_test_path, + sdk_path, extra_flags, blacklist) - if "nanox" in blacklist: - nanox_output = "Skipped" - else: - nanox_output = test_device(devices.nanox, variant_param, app_build_path, app_test_path, - sdk_path, extra_flags) + nanox_output = test_device(devices.nanox, variant_param, app_build_path, app_test_path, + sdk_path, extra_flags, blacklist) - if "stax" in blacklist: - stax_output = "Skipped" - else: - stax_output = test_device(devices.stax, variant_param, app_build_path, app_test_path, - sdk_path, extra_flags) + stax_output = test_device(devices.stax, variant_param, app_build_path, app_test_path, + sdk_path, extra_flags, blacklist) if nanos_output: output["test"]["nanos"] = nanos_output diff --git a/scripts/output_scripts/status.py b/scripts/output_scripts/status.py index c027372..3e6265c 100755 --- a/scripts/output_scripts/status.py +++ b/scripts/output_scripts/status.py @@ -2,23 +2,24 @@ from argparse import ArgumentParser from pathlib import Path - -def check_status(json_data): - for app_data in json_data.values(): - for build_data in app_data.values(): - for status in build_data.values(): +def check_status(json_data, key): + for app_data in json_data: + name = app_data["name"] + target_data = app_data.get(key) # Use .get() to safely access the key + if target_data is not None and isinstance(target_data, dict): + for _, status in target_data.items(): if status == "Fail": - raise ValueError("Build Failed") - + raise ValueError(f"Failed for {name}") if __name__ == "__main__": parser = ArgumentParser() parser.add_argument("--input_file", required=True, type=Path) + parser.add_argument("--key", required=True) args = parser.parse_args() with open(args.input_file) as json_file: json_data = json.load(json_file) - check_status(json_data) + check_status(json_data, args.key)