Skip to content

Commit

Permalink
Refactor hack/verify-all.sh and run almost all checks.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ixdy committed Mar 9, 2016
1 parent 24b3223 commit 4242fd2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 64 deletions.
12 changes: 1 addition & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
81 changes: 40 additions & 41 deletions hack/verify-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,75 +23,74 @@ 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
done
return 1
}

function run-cmd() {
function run-cmd {
if ${SILENT}; then
"$@" &> /dev/null
else
"$@"
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
13 changes: 1 addition & 12 deletions shippable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4242fd2

Please sign in to comment.