Skip to content

Commit

Permalink
Further validate CI - expected fail now
Browse files Browse the repository at this point in the history
  • Loading branch information
aBozowski committed May 26, 2022
1 parent d103893 commit 82daba0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
19 changes: 15 additions & 4 deletions examples/chef/chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,24 @@ def main(argv: Sequence[str]) -> None:
cached_manifest = json.loads(ci_manifest_file.read())
for device in ci_manifest:
if device != "zap_commit":
# TODO write the hash into folders and validate folders
try:
if cached_manifest[device] != ci_manifest[device]:
print("Cached files out of date. Please run chef with the flag --generate_zzz and commit")
print("MISMATCH INPUT - Cached files out of date. Please run chef with the flag --generate_zzz and commit /examples/chef/zzz_generated and /examples/chef/cimanifes.json")
exit(1)
else:
zzz_dir = os.path.join(chef_zzz_root, device)
device_md5_file = os.path.join(zzz_dir, "INPUTMD5.txt")
if not os.path.exists(device_md5_file):
print("MISSING RESULT - Cached files out of date. Please run chef with the flag --generate_zzz and commit /examples/chef/zzz_generated and /examples/chef/cimanifes.json")
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 - Cached files out of date. Please run chef with the flag --generate_zzz and commit /examples/chef/zzz_generated and /examples/chef/cimanifes.json")
exit(1)
except KeyError:
print("Cached files out of date. Please run chef with the flag --generate_zzz and commit /examples/chef/zzz_generated and /examples/chef/cimanifes.json")
print("MISSING DEVICE CACHE - Cached files out of date. Please run chef with the flag --generate_zzz and commit /examples/chef/zzz_generated and /examples/chef/cimanifes.json")
exit(1)
if device == "zap_commit" and False:
# Disabled for now, ci_manifest above created without include_zap_submod, fails in CI env.
Expand Down Expand Up @@ -263,7 +274,7 @@ def main(argv: Sequence[str]) -> None:
{_CHEF_SCRIPT_PATH}/devices/{device_name}.zap -o {device_out_dir}")
shell.run_cmd(f"touch {device_out_dir}/af-gen-event.h")
chef_util.generate_device_manifest(chef_devices_dir, include_zap_submod=True, write_manifest_file=True,
ci_manifest_file_name=ci_manifest_file_name, repo_base_path=_REPO_BASE_PATH)
ci_manifest_file_name=ci_manifest_file_name, repo_base_path=_REPO_BASE_PATH, chef_zzz_root=chef_zzz_root)
exit(0)

#
Expand Down
7 changes: 6 additions & 1 deletion examples/chef/chef_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def check_zap_master(repo_base_path: str) -> str:
return zap_commit


def generate_device_manifest(chef_devices_dir: str, include_zap_submod: bool = False, write_manifest_file: bool = False, ci_manifest_file_name: str = '', repo_base_path: str = '') -> dict:
def generate_device_manifest(chef_devices_dir: str, include_zap_submod: bool = False, write_manifest_file: bool = False, ci_manifest_file_name: str = '', repo_base_path: str = '', chef_zzz_root: str = '') -> dict:
"""Produces dictionary containing md5 of device dir zap files"""
ci_manifest = {}
for device_dir_item in os.listdir(chef_devices_dir):
Expand All @@ -53,6 +53,11 @@ def generate_device_manifest(chef_devices_dir: str, include_zap_submod: bool = F
device_file_md5 = hashlib.md5(device_file_data).hexdigest()
ci_manifest[device_name] = device_file_md5
print(f"Manifest for {device_name} : {device_file_md5}")
if write_manifest_file:
device_zzz_dir_root = os.path.join(chef_zzz_root, device_name)
device_zzz_md5_file = os.path.join(device_zzz_dir_root, 'INPUTMD5.txt')
with open(device_zzz_md5_file, "w+", encoding="utf-8") as md5file:
md5file.write(device_file_md5)
if include_zap_submod:
ci_manifest["zap_commit"] = check_zap_master(repo_base_path)
if write_manifest_file:
Expand Down

0 comments on commit 82daba0

Please sign in to comment.