From bd8857357b7874284890aa08f8e5d59026432f9e Mon Sep 17 00:00:00 2001 From: Al Bailey Date: Mon, 27 Feb 2023 15:32:30 +0000 Subject: [PATCH] Run checkEventYaml as part of zuul linter job The checkEventYaml script verifies if all contents are properly populated for the events.yaml file. This change ensures that check is done by zuul, rather than during the build. yaml.load after version 5.1 requires a Loader argument. The yaml.load in fm-doc are now updated to use safe_load intead Test Plan: PASS: tox -e linters PASS: remove 'context' field from an alarm and observe that tox -e linters reports a failure. PASS: build-pkgs -p fm-doc Story: 2010531 Task: 47549 Signed-off-by: Al Bailey Change-Id: I369ffe4c74fcaf5fe4a916822fed18a78ead8ff8 --- fm-doc/fm_doc/check_missing_alarms.py | 2 +- fm-doc/fm_doc/parseEventYaml.py | 2 +- tox.ini | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/fm-doc/fm_doc/check_missing_alarms.py b/fm-doc/fm_doc/check_missing_alarms.py index 41e36816..f555b9f0 100644 --- a/fm-doc/fm_doc/check_missing_alarms.py +++ b/fm-doc/fm_doc/check_missing_alarms.py @@ -94,7 +94,7 @@ exitValue = 0 with open(sys.argv[1], 'r') as stream: try: - events = yaml.load(stream) + events = yaml.safe_load(stream) events_alarm_list = get_events_alarm_list(events) except yaml.YAMLError as exc: diff --git a/fm-doc/fm_doc/parseEventYaml.py b/fm-doc/fm_doc/parseEventYaml.py index 13f6dcb7..e82bdeed 100755 --- a/fm-doc/fm_doc/parseEventYaml.py +++ b/fm-doc/fm_doc/parseEventYaml.py @@ -186,7 +186,7 @@ if not os.path.isfile(sys.argv[1]): with open(sys.argv[1], 'r') as stream: try: - events = yaml.load(stream) + events = yaml.safe_load(stream) exitValue = 0 for key in events: diff --git a/tox.ini b/tox.ini index 47b67264..d008525a 100644 --- a/tox.ini +++ b/tox.ini @@ -50,6 +50,11 @@ commands = \( -name .tox -prune \) \ -o -type f -name '*.yaml' \ -print0 | xargs -0 yamllint -d '\{extends: relaxed, rules: \{line-length: \{max: 260\}\}\}'" + bash -c "cd {envdir}; \ + cp {toxinidir}/fm-api/source/fm_api/constants.py .; \ + cp {toxinidir}/fm-common/sources/fmAlarm.h .; \ + cp {toxinidir}/fm-doc/fm_doc/* .; \ + ./checkEventYaml" [testenv:pylint] basepython = python3