X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Finfo-file-validate.sh;h=4b80672b5a76911c57b65a6f679edb513691052c;hb=e3364564e3f63cd337a5aafaadb483ba528ea4d2;hp=c3731f4de2622c3a7ec369f667e02d99bb9e88df;hpb=b83660faf15e9b6983d5d6baa031ecec710140b8;p=releng%2Fglobal-jjb.git diff --git a/shell/info-file-validate.sh b/shell/info-file-validate.sh index c3731f4d..4b80672b 100755 --- a/shell/info-file-validate.sh +++ b/shell/info-file-validate.sh @@ -10,18 +10,34 @@ ############################################################################## echo '--> info-file-validate.sh' set -e -o pipefail -set -x # Enable trace +PROJECT="${PROJECT:-None}" virtualenv --quiet "/tmp/v/info" # shellcheck source=/tmp/v/info/bin/activate disable=SC1091 source "/tmp/v/info/bin/activate" -pip install PyYAML jsonschema rfc3987 +pip install PyYAML jsonschema rfc3987 yamllint yq -# Cloning global-jjb to get access to needed scripts -git clone https://github.com/lfit/releng-global-jjb.git +# Download info-schema.yaml and yaml-verfy-schema.py +wget -q https://raw.githubusercontent.com/lfit/releng-global-jjb/master/schema/info-schema.yaml \ +https://raw.githubusercontent.com/lfit/releng-global-jjb/master/yaml-verify-schema.py -python releng-global-jjb/yaml-verify-schema.py \ - -s releng-global-jjb/info-schema \ +yamllint INFO.yaml + +python yaml-verify-schema.py \ + -s info-schema.yaml \ -y INFO.yaml -rm -rf releng-global-jjb + +# Verfiy that there is only one repository and that it matches $PROJECT +REPO_LIST="$(yq -r '.repositories[]' INFO.yaml)" + +while IFS= read -r project; do + if [[ "$project" == "$PROJECT" ]]; then + echo "$project is valid" + else + echo "ERROR: $project is invalid" + echo "INFO.yaml file may only list one repository" + echo "Repository must match $PROJECT" + exit 1 + fi +done <<< "$REPO_LIST"