From: Aric Gardner Date: Thu, 29 Aug 2019 18:54:03 +0000 (-0400) Subject: INFO validate job improvements X-Git-Tag: v0.43.0~10^2 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=471ce0c4f693f556a6714c7e0996f24f00d155af;p=releng%2Fglobal-jjb.git INFO validate job improvements removed +x trace as job is too verbose verify now checks that repositories matches $PROJECT Catches projects that replace / with - in their INFO file Also ensures that repositories only has one entry. We are not supporting multiple projects with a single INFO.yaml file. ISSUE: RELENG-2344 Signed-off-by: Aric Gardner Change-Id: Id847b7c10ef0515fd6f6a4b7d6809ebd37a9b51d --- diff --git a/releasenotes/notes/info-validate-yamllint-22c539ac9bd878e0.yaml b/releasenotes/notes/info-validate-yamllint-22c539ac9bd878e0.yaml new file mode 100644 index 00000000..7e8f6e0d --- /dev/null +++ b/releasenotes/notes/info-validate-yamllint-22c539ac9bd878e0.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + INFO validate job checks that repositories matches $PROJECT + Catches projects that replace / with - in their INFO file + Also ensures that repositories only has one entry. + We are not supporting multiple projects with a single INFO.yaml file. diff --git a/shell/info-file-validate.sh b/shell/info-file-validate.sh index f0c47cbb..4b80672b 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 +pip install PyYAML jsonschema rfc3987 yamllint yq # 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"