From f9c99fb29d3dbee6323662fbd504f95efb499e74 Mon Sep 17 00:00:00 2001 From: Timothée Ravier Date: Feb 16 2023 10:45:09 +0000 Subject: [PATCH 1/2] ci: Ignore ci directory & Zuul config in validation script --- diff --git a/ci/validate b/ci/validate index 1e9b6c9..abe1d97 100755 --- a/ci/validate +++ b/ci/validate @@ -22,10 +22,12 @@ def validate_shell(rootfd, name): for root, dirs, files, rootfd in os.fwalk('.'): # Skip .git, repo, cache, tmp, logs, fedora-comps - for d in ['.git', 'repo', 'cache', 'tmp', 'logs', 'fedora-comps']: + for d in ['.git', 'repo', 'cache', 'tmp', 'logs', 'fedora-comps', 'ci']: if d in dirs: dirs.remove(d) for name in files: + if name == ".zuul.yaml": + continue if name.endswith(('.yaml', '.yml')): print("Validating:", name) with open(os.open(name, dir_fd=rootfd, flags=os.O_RDONLY)) as f: From 3ff6ec9a7e9d69474442a34361afe1c444d8d879 Mon Sep 17 00:00:00 2001 From: Timothée Ravier Date: Feb 16 2023 10:48:29 +0000 Subject: [PATCH 2/2] ci: Validate (best effort) YAML manifests indentation Best effort validation to catch common mistakes. --- diff --git a/ci/validate b/ci/validate index abe1d97..23a213c 100755 --- a/ci/validate +++ b/ci/validate @@ -32,7 +32,10 @@ for root, dirs, files, rootfd in os.fwalk('.'): print("Validating:", name) with open(os.open(name, dir_fd=rootfd, flags=os.O_RDONLY)) as f: yaml.safe_load(f) - validated +=1 + result = subprocess.run(['grep', '-RniEv', '^( )*[a-z#/-]|^$|^#', name], encoding='UTF-8') + if result.returncode == 0: + raise Exception("Found likely invalid indentation in YAML file: {}".format(name)) + validated +=1 continue elif name.endswith('.sh'): print("Validating:", name)