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.
pull/6/head
Jeff Grafton 2016-03-07 18:12:20 -08:00
parent 24b3223141
commit 4242fd2ee1
3 changed files with 42 additions and 64 deletions

View File

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

View File

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

View File

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