X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Finfo-file-validate.sh;h=40d96b6daa87e364fb59c0c14a3ef01ca6d194fb;hb=9268e4ab2c79a5605c59865ac5dd96231de75518;hp=f0c47cbba5bc5702b2dc66773fcc6982f5ae1d6c;hpb=286f9e16245a8ce6aa4de5b7b9eb4804224a2cbc;p=releng%2Fglobal-jjb.git diff --git a/shell/info-file-validate.sh b/shell/info-file-validate.sh index f0c47cbb..40d96b6d 100755 --- a/shell/info-file-validate.sh +++ b/shell/info-file-validate.sh @@ -10,12 +10,12 @@ ############################################################################## 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 yamllint +# shellcheck disable=SC1090 +source ~/lf-env.sh +lf-activate-venv zipp==1.1.0 PyYAML jsonschema rfc3987 yamllint yq +pip freeze # Download info-schema.yaml and yaml-verfy-schema.py wget -q https://raw.githubusercontent.com/lfit/releng-global-jjb/master/schema/info-schema.yaml \ @@ -26,3 +26,18 @@ yamllint INFO.yaml python yaml-verify-schema.py \ -s info-schema.yaml \ -y INFO.yaml + + +# 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"