From 4242fd2ee13d09f3739a010b43c05d884da79ca9 Mon Sep 17 00:00:00 2001 From: Jeff Grafton Date: Mon, 7 Mar 2016 18:12:20 -0800 Subject: [PATCH] Refactor hack/verify-all.sh and run almost all checks. The reasons why checks are skipped is now more explicit. Output is also improved a bit, giving both the check name and the runtime on the pass/fail line. This commit also makes `make verify`, Travis, and Shippable all use hack/verify-all.sh instead of calling scripts explicitly, as we had been doing on Jenkins. Everything should now be consistent. --- Makefile | 12 +------ hack/verify-all.sh | 81 +++++++++++++++++++++++----------------------- shippable.yml | 13 +------- 3 files changed, 42 insertions(+), 64 deletions(-) diff --git a/Makefile b/Makefile index d2ed676a092..7b056878855 100644 --- a/Makefile +++ b/Makefile @@ -55,17 +55,7 @@ all: # make verify # make verify BRANCH=branch_x verify: - hack/verify-gofmt.sh - hack/verify-boilerplate.sh - hack/verify-codecgen.sh - hack/verify-description.sh - hack/verify-generated-conversions.sh - hack/verify-generated-deep-copies.sh - hack/verify-generated-docs.sh - hack/verify-swagger-spec.sh - hack/verify-flags-underscore.py - hack/verify-godeps.sh $(BRANCH) - hack/verify-godep-licenses.sh $(BRANCH) + KUBE_VERIFY_GIT_BRANCH=$(BRANCH) hack/verify-all.sh -v .PHONY: verify # Build and run tests. diff --git a/hack/verify-all.sh b/hack/verify-all.sh index c5b32958bfa..936848151fc 100755 --- a/hack/verify-all.sh +++ b/hack/verify-all.sh @@ -23,11 +23,17 @@ source "${KUBE_ROOT}/cluster/lib/util.sh" SILENT=true +# Excluded checks are always skipped. +EXCLUDED_CHECKS=( + "verify-linkcheck.sh" # runs in separate Jenkins job once per day due to high network usage + "verify-generated-protobuf.sh" # TODO(smarterclayton) add when protobuf is part of direct generation + ) + function is-excluded { - for e in $EXCLUDE; do - if [[ $1 -ef ${BASH_SOURCE} ]]; then - return - fi + if [[ $1 -ef ${BASH_SOURCE} ]]; then + return + fi + for e in ${EXCLUDED_CHECKS[@]}; do if [[ $1 -ef "$KUBE_ROOT/hack/$e" ]]; then return fi @@ -35,7 +41,7 @@ function is-excluded { return 1 } -function run-cmd() { +function run-cmd { if ${SILENT}; then "$@" &> /dev/null else @@ -43,55 +49,48 @@ function run-cmd() { fi } +function run-checks { + local -r pattern=$1 + local -r runner=$2 + + for t in $(ls ${pattern}) + do + if is-excluded "${t}" ; then + echo "Skipping ${t}" + continue + fi + echo -e "Verifying ${t}" + local start=$(date +%s) + run-cmd "${runner}" "${t}" && tr=$? || tr=$? + local elapsed=$(($(date +%s) - ${start})) + if [[ ${tr} -eq 0 ]]; then + echo -e "${color_green}SUCCESS${color_norm} ${t}\t${elapsed}s" + else + echo -e "${color_red}FAILED${color_norm} ${t}\t${elapsed}s" + ret=1 + fi + done +} + while getopts ":v" opt; do - case $opt in + case ${opt} in v) SILENT=false ;; \?) - echo "Invalid flag: -$OPTARG" >&2 + echo "Invalid flag: -${OPTARG}" >&2 exit 1 ;; esac done -if $SILENT ; then +if ${SILENT} ; then echo "Running in the silent mode, run with -v if you want to see script logs." fi -# remove protobuf until it is part of direct generation -EXCLUDE="verify-godeps.sh verify-godep-licenses.sh verify-generated-protobuf.sh verify-linkcheck.sh" - ret=0 -for t in `ls $KUBE_ROOT/hack/verify-*.sh` -do - if is-excluded $t ; then - echo "Skipping $t" - continue - fi - echo -e "Verifying $t" - if run-cmd bash "$t"; then - echo -e "${color_green}SUCCESS${color_norm}" - else - echo -e "${color_red}FAILED${color_norm}" - ret=1 - fi -done - -for t in `ls $KUBE_ROOT/hack/verify-*.py` -do - if is-excluded $t ; then - echo "Skipping $t" - continue - fi - echo -e "Verifying $t" - if run-cmd python "$t"; then - echo -e "${color_green}SUCCESS${color_norm}" - else - echo -e "${color_red}FAILED${color_norm}" - ret=1 - fi -done -exit $ret +run-checks "${KUBE_ROOT}/hack/verify-*.sh" bash +run-checks "${KUBE_ROOT}/hack/verify-*.py" python +exit ${ret} # ex: ts=2 sw=2 et filetype=sh diff --git a/shippable.yml b/shippable.yml index 0c43b9810c7..e30902ac0b1 100644 --- a/shippable.yml +++ b/shippable.yml @@ -44,18 +44,7 @@ install: - ./hack/build-go.sh - godep go install ./... - ./hack/install-etcd.sh - - ./hack/verify-gofmt.sh - - ./hack/verify-boilerplate.sh - - ./hack/verify-description.sh - - ./hack/verify-flags-underscore.py - - ./hack/verify-godeps.sh ${BASE_BRANCH} - - ./hack/verify-godep-licenses.sh ${BASE_BRANCH} - - ./hack/travis/install-std-race.sh - - ./hack/verify-generated-conversions.sh - - ./hack/verify-generated-deep-copies.sh - - ./hack/verify-generated-docs.sh - - ./hack/verify-generated-swagger-docs.sh - - ./hack/verify-swagger-spec.sh + - make verify BRANCH=${BASE_BRANCH} script: # Disable coverage collection on pull requests