Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
aBozowski committed May 27, 2022
1 parent 88b852a commit 2ef6d3e
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions examples/chef/chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def generate_device_manifest(
Args:
include_zap_submod: Include ZAP commit in manifest
write_manifest_file: Serialize manifest
write_manifest_file: Serialize manifest in file and tree
Returns:
Dict containing MD5 of device dir zap files.
"""
Expand Down Expand Up @@ -258,32 +258,34 @@ def main(argv: Sequence[str]) -> None:
ci_manifest = generate_device_manifest(_DEVICE_FOLDER)
with open(_CI_MANIFEST_FILE_NAME, "r", encoding="utf-8") as ci_manifest_file:
cached_manifest = json.loads(ci_manifest_file.read())
for device in ci_manifest:
if device != "zap_commit":
try:
if cached_manifest[device] != ci_manifest[device]:
print("MISMATCH INPUT - "+fix_instructions)
exit(1)
else:
zzz_dir = os.path.join(_CHEF_ZZZ_ROOT, device)
device_md5_file = os.path.join(zzz_dir, _CI_DEVICE_MANIFEST_NAME)
if not os.path.exists(device_md5_file):
print("MISSING RESULT - "+fix_instructions)
exit(1)
else:
with open(device_md5_file, "r", encoding="utf-8") as md5_file:
md5 = md5_file.read()
if ci_manifest[device] != md5:
print("MISMATCH OUTPUT - "+fix_instrucitons)
exit(1)
except KeyError:
print("MISSING DEVICE CACHE - "+fix_instructions)
exit(1)
if device == "zap_commit" and False:
# Disabled for now, ci_manifest above created without include_zap_submod, fails in CI env.
for device in ci_manifest:
if device != "zap_commit":
try:
if cached_manifest[device] != ci_manifest[device]:
print("BAD ZAP VERSION - "+fix_instructions)
print("MISMATCH INPUT - "+fix_instructions)
exit(1)
else:
zzz_dir = os.path.join(_CHEF_ZZZ_ROOT, device)
device_md5_file = os.path.join(zzz_dir, _CI_DEVICE_MANIFEST_NAME)
if not os.path.exists(device_md5_file):
print("MISSING RESULT - "+fix_instructions)
exit(1)
else:
with open(device_md5_file, "r", encoding="utf-8") as md5_file:
md5 = md5_file.read()
if ci_manifest[device] != md5:
print("MISMATCH OUTPUT - "+fix_instrucitons)
exit(1)
except KeyError:
print("MISSING DEVICE CACHE - "+fix_instructions)
exit(1)
# Disabled; should check:
# Current branch when writing manifest
# Master in CI
if device == "zap_commit" and False:
if cached_manifest[device] != ci_manifest[device]:
print("BAD ZAP VERSION - "+fix_instructions)
exit(1)
print("Cached ZAP output is up to date!")
exit(0)

Expand Down

0 comments on commit 2ef6d3e

Please sign in to comment.