Add validate-json tox target

This is a simple JSON validation script based on demjson python library,
we do some shell script trickeries to exit properly if there is a
failure for tox (should probably patch demjson to properly exit
instead).

Change-Id: I930908336deef7daeaab5b55ba2031c64698d880
Implements: blueprint json-validation-gate
This commit is contained in:
Chmouel Boudjnah 2014-10-03 09:26:36 +00:00
parent a6310d7692
commit ac0b2a797f
3 changed files with 31 additions and 0 deletions

1
test-requirements.txt Normal file
View File

@ -0,0 +1 @@
demjson

19
tools/validate-json.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
set -e
TMPFILE=$(mktemp)
ret=0
function clean {
rm -f ${TMPFILE}
}
trap clean EXIT
for f in $(find docker/ -type f -name '*.json');do
jsonlint -s ${f} >${TMPFILE}
egrep -q 'has errors$' ${TMPFILE} && { cat ${TMPFILE}; ret=1 ;}
done
cat ${TMPFILE}
exit ${ret}

11
tox.ini Normal file
View File

@ -0,0 +1,11 @@
[tox]
skipsdist = True
envlist = validate-json
minversion = 1.6
[testenv]
deps = -r{toxinidir}/test-requirements.txt
[testenv:validate-json]
commands =
{toxinidir}/tools/validate-json.sh