Skip to content

Commit

Permalink
validate should break now
Browse files Browse the repository at this point in the history
  • Loading branch information
aBozowski committed Jun 2, 2022
1 parent c8762f6 commit 27ea5b5
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions examples/chef/chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,34 +295,30 @@ def main(argv: Sequence[str]) -> None:
git add examples/chef/ci_manifest.json
git add examples/chef/zzz_generated
Ensure you are running with the latest version of ZAP from master!""")
ci_manifest = generate_device_manifest(include_zap_submod=True)
with open(_CI_MANIFEST_FILE_NAME, "r", encoding="utf-8") as ci_manifest_file:
cached_manifest = json.loads(ci_manifest_file.read())
cached_device_manifest = cached_manifest["devices"]
ci_manifest = generate_device_manifest()
current_zap = ci_manifest["zap_commit"]
for device, device_md5 in ci_manifest["devices"].items():
zzz_dir = os.path.join(_CHEF_ZZZ_ROOT, device)
device_zap_sha_file = os.path.join(zzz_dir, _CI_ZAP_MANIFEST_NAME)
device_md5_file = os.path.join(zzz_dir, _CI_DEVICE_MANIFEST_NAME)
if device not in cached_device_manifest:
flush_print(f"MANIFEST MISSING {device}: {fix_instructions}")
elif cached_device_manifest[device] != device_md5:
flush_print(f"MANIFEST MISMATCH {device}: {fix_instructions}")
if not os.path.exists(device_zap_sha_file):
flush_print(f"ZAP MISSING {device}: {fix_instructions}")
exit(1)
elif not os.path.exists(device_md5_file):
flush_print(f"OUTPUT MISSING {device}: {fix_instructions}")
else:
with open(device_zap_sha_file, "r", encoding="utf-8") as zap_file:
output_cached_zap_sha = zap_file.read()
if output_cached_zap_sha != current_zap:
flush_print(f"ZAP MISMATCH {device}: {fix_instructions}")
exit(1)
if not os.path.exists(device_md5_file):
flush_print(f"ZAP MD5 MISSING {device}: {fix_instructions}")
exit(1)
else:
with open(device_md5_file, "r", encoding="utf-8") as md5_file:
output_cached_md5 = md5_file.read()
if output_cached_md5 != device_md5:
flush_print(f"OUTPUT MISMATCH {device}: {fix_instrucitons}")
flush_print(f"ZAP MD5 MISMATCH {device}: {fix_instrucitons}")
exit(1)
current_zap = ci_manifest["zap_commit"]
cached_zap = cached_manifest["zap_commit"]
flush_print(f"current zap commit {current_zap}")
flush_print(f"cached zap commit {cached_zap}")
if current_zap != cached_zap:
flush_print(f"BAD ZAP VERSION: {fix_instructions}")
exit(1)
flush_print("Cached ZAP output is up to date!")
exit(0)

Expand Down Expand Up @@ -372,8 +368,7 @@ def main(argv: Sequence[str]) -> None:
{_REPO_BASE_PATH}/scripts/tools/zap/generate.py \
{_CHEF_SCRIPT_PATH}/devices/{device_name}.zap -o {device_out_dir}"""))
shell.run_cmd(f"touch {device_out_dir}/af-gen-event.h")
generate_device_manifest(include_zap_submod=True,
write_manifest_file=True)
generate_device_manifest(write_manifest_file=True)
exit(0)

#
Expand Down

0 comments on commit 27ea5b5

Please sign in to comment.