Skip to content

Commit 3ba87f9

Browse files
committed
tests: Enable recursive file search for YAML validation
This patch follows changes introduced in kernelci-core repository: 3b0658890d53cb5c49a3016ae66f97f62c2e4afd Related: kernelci/kernelci-core#2860 Signed-off-by: Paweł Wieczorek <[email protected]>
1 parent 734014d commit 3ba87f9

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

tests/validate_yaml.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Validate all yaml files in the config/ directory
44
"""
55

6+
import glob
67
import os
78
import yaml
89
import sys
@@ -161,17 +162,15 @@ def merge_files(dir="config"):
161162
Merge all yaml files in the config/ directory
162163
"""
163164
merged_data = {}
164-
for file in os.listdir(dir):
165-
if file.endswith(".yaml"):
166-
print(f"Merging {file}")
167-
fpath = os.path.join(dir, file)
168-
with open(fpath, "r") as stream:
169-
try:
170-
data = yaml.safe_load(stream)
171-
merged_data = recursive_merge(merged_data, data)
172-
except yaml.YAMLError as exc:
173-
print(f"Error in {file}: {exc}")
174-
sys.exit(1)
165+
for file in glob.iglob(os.path.join(dir, "**", "*.yaml"), recursive=True):
166+
print(f"Merging {file}")
167+
with open(file, "r") as stream:
168+
try:
169+
data = yaml.safe_load(stream)
170+
merged_data = recursive_merge(merged_data, data)
171+
except yaml.YAMLError as exc:
172+
print(f"Error in {file}: {exc}")
173+
sys.exit(1)
175174
return merged_data
176175

177176

0 commit comments

Comments
 (0)