From e3fed1ce6d589929dad790bbbc99b70c8bf48dd7 Mon Sep 17 00:00:00 2001 From: Anthony Yeh Date: Wed, 12 Jul 2017 15:02:52 -0700 Subject: [PATCH 1/2] Allow verify-sh to run in SILENT mode. Because of nounset, it was impossible to run without -v. --- hack/make-rules/verify.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/hack/make-rules/verify.sh b/hack/make-rules/verify.sh index 1560985a8d43..4e4b5e75a5a8 100755 --- a/hack/make-rules/verify.sh +++ b/hack/make-rules/verify.sh @@ -71,6 +71,7 @@ function run-checks { done } +SILENT=true while getopts ":v" opt; do case ${opt} in v) From db869a6b0ba0b8630424cbdfa12d3b1125688bcf Mon Sep 17 00:00:00 2001 From: Anthony Yeh Date: Wed, 12 Jul 2017 15:48:12 -0700 Subject: [PATCH 2/2] Add quick-verify make rule. This is useful for humans to run to catch obvious problems before pushing commits and waiting for CI to run verify checks. Quick mode only runs a whitelist of verify scripts that are reasonably fast. I set the initial bar arbitrarily at <10s each on my workstation. The whole set runs in <30s for me, assuming I had already run `make` and `hack/godep-restore.sh`. This is compared to the full `make verify` which takes [I don't know how long because I gave up after 45min]. --- build/root/Makefile | 15 ++++++++++++++ hack/make-rules/verify.sh | 42 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/build/root/Makefile b/build/root/Makefile index 401b8c44f45b..21e57d4aea50 100644 --- a/build/root/Makefile +++ b/build/root/Makefile @@ -126,6 +126,21 @@ verify: verify_generated_files KUBE_VERIFY_GIT_BRANCH=$(BRANCH) hack/make-rules/verify.sh -v endif +define QUICK_VERIFY_HELP_INFO +# Runs only the presubmission verifications that aren't slow. +# +# Example: +# make quick-verify +endef +.PHONY: quick-verify +ifeq ($(PRINT_HELP),y) +quick-verify: + @echo "$$QUICK_VERIFY_HELP_INFO" +else +quick-verify: verify_generated_files + hack/make-rules/verify.sh -v -Q +endif + define UPDATE_HELP_INFO # Runs all the generated updates. # diff --git a/hack/make-rules/verify.sh b/hack/make-rules/verify.sh index 4e4b5e75a5a8..d1710bdc4c9e 100755 --- a/hack/make-rules/verify.sh +++ b/hack/make-rules/verify.sh @@ -29,7 +29,25 @@ EXCLUDED_PATTERNS=( "verify-*-dockerized.sh" # Don't run any scripts that intended to be run dockerized ) +# Only run whitelisted fast checks in quick mode. +# These run in <10s each on enisoc's workstation, assuming that +# `make` and `hack/godep-restore.sh` had already been run. +QUICK_PATTERNS+=( + "verify-api-groups.sh" + "verify-bazel.sh" + "verify-boilerplate.sh" + "verify-godep-licenses.sh" + "verify-gofmt.sh" + "verify-pkg-names.sh" + "verify-readonly-packages.sh" + "verify-staging-client-go.sh" + "verify-staging-imports.sh" + "verify-test-images.sh" + "verify-test-owners.sh" +) + EXCLUDED_CHECKS=$(ls ${EXCLUDED_PATTERNS[@]/#/${KUBE_ROOT}\/hack\/} 2>/dev/null || true) +QUICK_CHECKS=$(ls ${QUICK_PATTERNS[@]/#/${KUBE_ROOT}\/hack\/} 2>/dev/null || true) function is-excluded { for e in ${EXCLUDED_CHECKS[@]}; do @@ -40,6 +58,15 @@ function is-excluded { return 1 } +function is-quick { + for e in ${QUICK_CHECKS[@]}; do + if [[ $1 -ef "$e" ]]; then + return + fi + done + return 1 +} + function run-cmd { if ${SILENT}; then "$@" &> /dev/null @@ -58,6 +85,10 @@ function run-checks { echo "Skipping ${t}" continue fi + if ${QUICK} && ! is-quick "${t}" ; then + echo "Skipping ${t} in quick mode" + continue + fi echo -e "Verifying ${t}" local start=$(date +%s) run-cmd "${runner}" "${t}" && tr=$? || tr=$? @@ -72,11 +103,16 @@ function run-checks { } SILENT=true -while getopts ":v" opt; do +QUICK=false + +while getopts ":vQ" opt; do case ${opt} in v) SILENT=false ;; + Q) + QUICK=true + ;; \?) echo "Invalid flag: -${OPTARG}" >&2 exit 1 @@ -88,6 +124,10 @@ if ${SILENT} ; then echo "Running in silent mode, run with -v if you want to see script logs." fi +if ${QUICK} ; then + echo "Running in quick mode (-Q flag). Only fast checks will run." +fi + ret=0 run-checks "${KUBE_ROOT}/hack/verify-*.sh" bash run-checks "${KUBE_ROOT}/hack/verify-*.py" python