Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add quick-verify make rule. #48842

Merged
merged 2 commits into from Jul 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions build/root/Makefile
Expand Up @@ -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.
#
Expand Down
43 changes: 42 additions & 1 deletion hack/make-rules/verify.sh
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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=$?
Expand All @@ -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
Expand All @@ -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
Expand Down