Skip to content

Commit

Permalink
outi
Browse files Browse the repository at this point in the history
  • Loading branch information
sgliner-ledger committed Sep 5, 2023
1 parent 49fe775 commit a0e3350
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 85 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/_build_nanos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
10 changes: 5 additions & 5 deletions .github/workflows/_build_nanosp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
10 changes: 5 additions & 5 deletions .github/workflows/_build_nanox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
10 changes: 5 additions & 5 deletions .github/workflows/_build_stax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
10 changes: 5 additions & 5 deletions .github/workflows/_test_devices.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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: |
Expand All @@ -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
45 changes: 16 additions & 29 deletions scripts/build_and_test/build_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
41 changes: 16 additions & 25 deletions scripts/build_and_test/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -19,20 +19,23 @@ 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"

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
Expand All @@ -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", "[]")

Expand All @@ -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
Expand Down
17 changes: 9 additions & 8 deletions scripts/output_scripts/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit a0e3350

Please sign in to comment.