dib-lint: use yamllint to parse YAML files

This gives us better linting of YAML files that just opening them.
This would have detected the duplicate keys in
I34e27d821fbefe274e7b007f37b0bd34db2e1d26.

The .yamllint is taken from zuul-jobs where it is also used as a
fairly sane set of default rules.

A few minor newline fixes are added.

Change-Id: I96d6644ae24f7deb84fa50fefbda0f0d33e0e009
This commit is contained in:
Ian Wienand 2020-05-26 11:45:36 +10:00
parent 6e549c33ac
commit 6ee2995214
6 changed files with 26 additions and 14 deletions

20
.yamllint Normal file
View File

@ -0,0 +1,20 @@
extends: default
ignore: |
.tox
rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
document-start: disable
empty-lines:
max: 1
max-end: 2
indentation:
level: error
indent-sequences: consistent
line-length: disable
truthy: false

View File

@ -276,17 +276,7 @@ fi
echo "Checking YAML parsing..."
for i in $(find $ELEMENTS_DIR -type f -name '*.yaml'); do
echo "Parsing $i"
py_check="
import yaml
import sys
try:
objs = yaml.safe_load(open('$i'))
except yaml.parser.ParserError:
sys.exit(1)
"
if ! python -c "$py_check"; then
error "$i is not a valid YAML file"
fi
yamllint -s -f parsable $i
done
echo "Checking pkg-map files..."
for i in $(find $ELEMENTS_DIR -type f \

View File

@ -12,3 +12,5 @@ testrepository>=0.0.18 # Apache-2.0/BSD
testtools>=2.2.0 # MIT
coverage!=4.4,>=4.0 # Apache-2.0
yamllint>=1.23.0