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 <al.bailey@windriver.com>
Change-Id: I369ffe4c74fcaf5fe4a916822fed18a78ead8ff8
This commit is contained in:
Al Bailey 2023-02-27 15:32:30 +00:00
parent c7e47234e9
commit bd8857357b
3 changed files with 7 additions and 2 deletions

View File

@ -94,7 +94,7 @@ exitValue = 0
with open(sys.argv[1], 'r') as stream: with open(sys.argv[1], 'r') as stream:
try: try:
events = yaml.load(stream) events = yaml.safe_load(stream)
events_alarm_list = get_events_alarm_list(events) events_alarm_list = get_events_alarm_list(events)
except yaml.YAMLError as exc: except yaml.YAMLError as exc:

View File

@ -186,7 +186,7 @@ if not os.path.isfile(sys.argv[1]):
with open(sys.argv[1], 'r') as stream: with open(sys.argv[1], 'r') as stream:
try: try:
events = yaml.load(stream) events = yaml.safe_load(stream)
exitValue = 0 exitValue = 0
for key in events: for key in events:

View File

@ -50,6 +50,11 @@ commands =
\( -name .tox -prune \) \ \( -name .tox -prune \) \
-o -type f -name '*.yaml' \ -o -type f -name '*.yaml' \
-print0 | xargs -0 yamllint -d '\{extends: relaxed, rules: \{line-length: \{max: 260\}\}\}'" -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] [testenv:pylint]
basepython = python3 basepython = python3