Merge pull request #48842 from enisoc/quick-verify

Automatic merge from submit-queue

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].
This commit is contained in:
Kubernetes Submit Queue 2017-07-14 14:38:28 -07:00 committed by GitHub
commit 048b0600f9
2 changed files with 57 additions and 1 deletions

View File

@ -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.
#

View File

@ -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=$?
@ -71,11 +102,17 @@ function run-checks {
done
}
while getopts ":v" opt; do
SILENT=true
QUICK=false
while getopts ":vQ" opt; do
case ${opt} in
v)
SILENT=false
;;
Q)
QUICK=true
;;
\?)
echo "Invalid flag: -${OPTARG}" >&2
exit 1
@ -87,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