summaryrefslogtreecommitdiffstats
path: root/jjb/global
diff options
context:
space:
mode:
authorKingPoo <haojingbo@huawei.com>2016-12-09 03:49:24 -0500
committerKingPoo <haojingbo@huawei.com>2016-12-24 06:35:36 -0500
commitcc6e26648833778050e4a59096edee69b538f92b (patch)
tree380dd829df5a61da4df96896f180b09ec17c80b2 /jjb/global
parent59f96c0b4fb704339bf45c8af943070f6adcf7b9 (diff)
Add YAMLLint for static check
JIRA: OCTO-160 Current CI commit gate is simple, just have flake8 check in part of projects, it's better to apply more check tools to more projects. Yaml files could be checked by YAMLLint when the project is configed in releng. YAMLLint does not only check for syntax validity, but for weirdnesses like key repetition and cosmetic problems such as lines length, trailing spaces, indentation, etc. Change-Id: Ie90afd4a07ad10cc723f31efd35e5605f765583c Signed-off-by: KingPoo <haojingbo@huawei.com>
Diffstat (limited to 'jjb/global')
-rw-r--r--jjb/global/releng-macros.yml33
1 files changed, 33 insertions, 0 deletions
diff --git a/jjb/global/releng-macros.yml b/jjb/global/releng-macros.yml
index cd92480d4..7647a35d3 100644
--- a/jjb/global/releng-macros.yml
+++ b/jjb/global/releng-macros.yml
@@ -355,3 +355,36 @@
name: check-bash-syntax
builders:
- shell: "find . -name '*.sh' | xargs bash -n"
+
+- builder:
+ name: lint-yaml-code
+ builders:
+ - shell: |
+ #!/bin/bash
+ set -o errexit
+ set -o pipefail
+ set -o xtrace
+ export PATH=$PATH:/usr/local/bin/
+
+ # generate and upload lint log
+ echo "Running yaml code on $PROJECT ..."
+
+ # Ensure we start with a clean environment
+ rm -f yaml-violation.log lint.log
+
+ # Get number of yaml violations. If none, this will be an
+ # empty string: ""
+ find . \
+ -path './releng_yamllint' -prune -o \
+ -path './.tox' -prune -o \
+ -type f -name "*.yml" -print \
+ -o -name "*.yaml" -print | \
+ xargs yamllint > yaml-violation.log || true
+
+ if [ -s "yaml-violation.log" ]; then
+ SHOWN=$(cat yaml-violation.log| grep -v "^$" |wc -l)
+ echo -e "First $SHOWN shown\n---" > lint.log
+ cat yaml-violation.log >> lint.log
+ sed -r -i '4,$s/^/ /g' lint.log
+ fi
+