From 5e3360ccb4e70ceae7d1b3dc6ec4f49718deedff Mon Sep 17 00:00:00 2001 From: James Munnelly Date: Tue, 26 Jun 2018 13:16:14 +0100 Subject: [PATCH] Update dep verify step to also ensure vendor is up to date --- Makefile | 3 ++- hack/update-deps.sh | 16 ++++++++++++++ hack/verify-deps.sh | 54 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100755 hack/update-deps.sh create mode 100755 hack/verify-deps.sh diff --git a/Makefile b/Makefile index 36201e052..036d75a95 100644 --- a/Makefile +++ b/Makefile @@ -83,7 +83,8 @@ deploy_verify: # Go targets ################# dep_verify: - dep status + @echo Running dep + $(HACK_DIR)/verify-deps.sh go_verify: go_fmt go_test diff --git a/hack/update-deps.sh b/hack/update-deps.sh new file mode 100755 index 000000000..291d49aa9 --- /dev/null +++ b/hack/update-deps.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -o errexit +set -o nounset +set -o pipefail + +SCRIPT_ROOT=$(dirname "${BASH_SOURCE}") +REPO_ROOT="${SCRIPT_ROOT}/.." +pushd "${REPO_ROOT}" +echo "+++ Running dep ensure" +dep ensure -v "$@" +echo "+++ Cleaning up erroneous vendored testdata symlinks" +rm -Rf vendor/github.com/prometheus/procfs/fixtures \ + vendor/github.com/hashicorp/go-rootcerts/test-fixtures \ + vendor/github.com/json-iterator/go/skip_tests +popd diff --git a/hack/verify-deps.sh b/hack/verify-deps.sh new file mode 100755 index 000000000..ad9945b95 --- /dev/null +++ b/hack/verify-deps.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# Copyright 2017 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o nounset +set -o pipefail + +SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")/.. + +pushd "${SCRIPT_ROOT}" +echo "+++ Checking Gopkg.lock is up-to-date" +dep status +popd + +echo "+++ Checking vendor/ is up-to-date" +DIFFROOT="${SCRIPT_ROOT}/vendor" +TMP_DIFFROOT="${SCRIPT_ROOT}/_tmp/vendor" +_tmp="${SCRIPT_ROOT}/_tmp" + +cleanup() { + rm -rf "${_tmp}" +} +trap "cleanup" EXIT SIGINT + +cleanup + +mkdir -p "${TMP_DIFFROOT}" +cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}" + +"${SCRIPT_ROOT}/hack/update-deps.sh" -vendor-only +echo "diffing ${DIFFROOT} against freshly generated vendor dir" +ret=0 +diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$? +cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}" +if [[ $ret -eq 0 ]] +then + echo "${DIFFROOT} up to date." +else + echo "${DIFFROOT} is out of date. Please run hack/update-deps.sh" + exit 1 +fi