Zuul: Verify that local jobs are namespaced
Signed-off-by: Nils Philippsen <nils@redhat.com>
This commit is contained in:
parent
97be9cdc8d
commit
42170b4a93
3 changed files with 62 additions and 0 deletions
36
ci/zuul-jobs-verify-namespace.py
Executable file
36
ci/zuul-jobs-verify-namespace.py
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
import yaml
|
||||
|
||||
|
||||
errors_found = False
|
||||
|
||||
for zuul_yaml_file in sys.argv[1:]:
|
||||
print(f"Processing {zuul_yaml_file!r}...", flush=True)
|
||||
with open(zuul_yaml_file, "r") as yaml_stream:
|
||||
for doc_no, yaml_doc in enumerate(yaml.safe_load_all(yaml_stream), 1):
|
||||
print(f"Verifying YAML doc #{doc_no}...", flush=True)
|
||||
yaml_doc_errors_found = False
|
||||
try:
|
||||
for item in yaml_doc:
|
||||
if "job" in item:
|
||||
job = item["job"]
|
||||
if not job["name"].startswith("fi-ansible--"):
|
||||
yaml_doc_errors_found = errors_found = True
|
||||
print(
|
||||
f"Locally defined Zuul job {job['name']!r} must be named"
|
||||
" 'fi-ansible-...'"
|
||||
)
|
||||
except Exception:
|
||||
yaml_doc_errors_found = errors_found = True
|
||||
traceback.print_exc()
|
||||
|
||||
if yaml_doc_errors_found:
|
||||
print(f"Verification failed.", flush=True)
|
||||
else:
|
||||
print(f"Verification passed.", flush=True)
|
||||
|
||||
sys.exit(errors_found)
|
Loading…
Add table
Add a link
Reference in a new issue