diff --git a/scripts/output_scripts/convert.py b/scripts/output_scripts/convert.py index f012173..7ebcce8 100755 --- a/scripts/output_scripts/convert.py +++ b/scripts/output_scripts/convert.py @@ -16,9 +16,9 @@ def json_to_markdown(json_list, key): # Start constructing the row with app_name row = "| {} |".format(app_name) - # Iterate over each build and append the status - for build in ["nanos", "nanosp", "nanox", "stax"]: - build_data = app_data.get(build, {}) + # Iterate over each device and append the status + for d in ["nanos", "nanosp", "nanox", "stax"]: + build_data = app_data.get(d, {}) if isinstance(build_data, dict): # nested structure status_icon = ":red_circle:" if "Fail" in build_data.values() else ":heavy_check_mark:" if "Success" in build_data.values() else ":fast_forward:" if "Skipped" in build_data.values() else "" else: diff --git a/scripts/output_scripts/slack.py b/scripts/output_scripts/slack.py index c3244df..2fa7166 100644 --- a/scripts/output_scripts/slack.py +++ b/scripts/output_scripts/slack.py @@ -15,27 +15,31 @@ def count_status(json_list, key): app_name = json_data.get("name", {}) fail_list[app_name] = {} - failed_devices = "" - for key_data, build_data in app_data.items(): + for d in ["nanos", "nanosp", "nanox", "stax"]: + build_data = app_data.get(d, {}) + if isinstance(build_data, dict): # nested structure - variant, status = build_data.popitem() + failed_variant_list = [] + for variant, status in build_data.items(): + if status == "Success": + total_count += 1 + success_count += 1 + elif status == "Fail": + total_count += 1 + fail_count += 1 + failed_variant_list.append(variant) + + if failed_variant_list: + fail_list[app_name][d] = failed_variant_list else: status = build_data - - - if status == "Success": - total_count += 1 - success_count += 1 - elif status == "Fail": - total_count += 1 - fail_count += 1 - if variant: - fail_list[app_name][key_data] = variant - else: - failed_devices += f"{key_data}, " - - if key == "test" and failed_devices: - fail_list[app_name] = failed_devices + if status == "Success": + total_count += 1 + success_count += 1 + elif status == "Fail": + total_count += 1 + fail_count += 1 + fail_list[app_name] = d return success_count, fail_count, total_count, fail_list diff --git a/scripts/output_scripts/status.py b/scripts/output_scripts/status.py index 3e6265c..bc3defd 100755 --- a/scripts/output_scripts/status.py +++ b/scripts/output_scripts/status.py @@ -2,14 +2,22 @@ from argparse import ArgumentParser from pathlib import Path + 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(f"Failed for {name}") + # Iterate over each dictionary in the list + for json_data in json_data: + app_data = json_data.get(key, {}) + app_name = json_data.get("name", {}) + + for d in ["nanos", "nanosp", "nanox", "stax"]: + data = app_data.get(d, {}) + if isinstance(data, dict): # nested structure + if "Fail" in data.values(): + raise ValueError(f"Failed for {app_name}") + else: + if data == "Fail": + raise ValueError(f"Failed for {app_name}") + if __name__ == "__main__": parser = ArgumentParser()