summaryrefslogtreecommitdiff
path: root/test-definitions-ci.py
diff options
context:
space:
mode:
Diffstat (limited to 'test-definitions-ci.py')
-rw-r--r--test-definitions-ci.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/test-definitions-ci.py b/test-definitions-ci.py
index 23a0efa..40b0572 100644
--- a/test-definitions-ci.py
+++ b/test-definitions-ci.py
@@ -52,6 +52,41 @@ def pep8_check(filepath, ignore_options=None):
})
publish_result(result_message_list)
+def metadata_check(filepath):
+ if filepath.lower().endswith("yaml"):
+ with open(filepath, "r") as f:
+ result_message_list = []
+ y = yaml.load(f.read())
+ if not 'metadata' in y.keys():
+ result_message_list.append("* METADATA [FAILED]: " + filepath)
+ result_message_list.append("\tmetadata section missing")
+ publish_result(result_message_list)
+ exit(1)
+ metadata_dict = y['metadata']
+ mandatory_keys = set([
+ 'name',
+ 'format',
+ 'description',
+ 'maintainer',
+ 'os',
+ 'scope',
+ 'devices'])
+ if not mandatory_keys.issubset(set(metadata_dict.keys())):
+ result_message_list.append("* METADATA [FAILED]: " + filepath)
+ result_message_list.append("\tmandatory keys missing: %s" % \
+ mandatory_keys.difference(set(metadata_dict.keys())))
+ result_message_list.append("\tactual keys present: %s" % \
+ metadata_dict.keys())
+ publish_result(result_message_list)
+ exit(1)
+ for key in mandatory_keys:
+ if len(metadata_dict[key]) == 0:
+ result_message_list.append("* METADATA [FAILED]: " + filepath)
+ result_message_list.append("\t%s has no content" % key)
+ publish_result(result_message_list)
+ exit(1)
+ result_message_list.append("* METADATA [PASSED]: " + filepath)
+ publish_result(result_message_list)
def validate_yaml(filename):
with open(filename, "r") as f:
@@ -93,6 +128,7 @@ def run_unit_tests(ignore_options):
for name in files:
if name.endswith("yaml"):
validate_yaml(root + "/" + name)
+ metadata_check(root + "/" + name)
if run_pep8 and name.endswith("py"):
pep8_check(root + "/" + name, ignore_options)
# disable checkbashisms for now