fix shellcheck failures in /hack/make-rules/update.sh,verify.sh

This commit is contained in:
toyoda 2019-04-11 14:53:57 +09:00
parent b3a73f761f
commit 9a5655c915
3 changed files with 21 additions and 25 deletions

View File

@ -24,8 +24,6 @@
./hack/lib/version.sh ./hack/lib/version.sh
./hack/make-rules/make-help.sh ./hack/make-rules/make-help.sh
./hack/make-rules/test.sh ./hack/make-rules/test.sh
./hack/make-rules/update.sh
./hack/make-rules/verify.sh
./hack/pin-dependency.sh ./hack/pin-dependency.sh
./hack/test-integration.sh ./hack/test-integration.sh
./hack/update-vendor.sh ./hack/update-vendor.sh

View File

@ -19,7 +19,7 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../.. KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
source "${KUBE_ROOT}/hack/lib/init.sh" source "${KUBE_ROOT}/hack/lib/init.sh"
# If called directly, exit. # If called directly, exit.
@ -32,10 +32,6 @@ fi
SILENT=${SILENT:-true} SILENT=${SILENT:-true}
ALL=${FORCE_ALL:-false} ALL=${FORCE_ALL:-false}
V=""
if [[ "${SILENT}" != "true" ]]; then
V="-v"
fi
trap 'exit 1' SIGINT trap 'exit 1' SIGINT
@ -59,10 +55,10 @@ BASH_TARGETS="
update-gofmt" update-gofmt"
for t in ${BASH_TARGETS}; do for t in ${BASH_TARGETS}; do
echo -e "${color_yellow}Running ${t}${color_norm}" echo -e "${color_yellow:?}Running ${t}${color_norm:?}"
if ${SILENT} ; then if ${SILENT} ; then
if ! bash "${KUBE_ROOT}/hack/${t}.sh" 1> /dev/null; then if ! bash "${KUBE_ROOT}/hack/${t}.sh" 1> /dev/null; then
echo -e "${color_red}Running ${t} FAILED${color_norm}" echo -e "${color_red:?}Running ${t} FAILED${color_norm}"
if ! ${ALL}; then if ! ${ALL}; then
exit 1 exit 1
fi fi
@ -77,4 +73,4 @@ for t in ${BASH_TARGETS}; do
fi fi
done done
echo -e "${color_green}Update scripts completed successfully${color_norm}" echo -e "${color_green:?}Update scripts completed successfully${color_norm}"

View File

@ -18,7 +18,7 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../.. KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
source "${KUBE_ROOT}/hack/lib/util.sh" source "${KUBE_ROOT}/hack/lib/util.sh"
# If KUBE_JUNIT_REPORT_DIR is unset, and ARTIFACTS is set, then have them match. # If KUBE_JUNIT_REPORT_DIR is unset, and ARTIFACTS is set, then have them match.
@ -80,13 +80,13 @@ QUICK_PATTERNS+=(
"verify-test-owners.sh" "verify-test-owners.sh"
) )
EXCLUDED_CHECKS=$(ls ${EXCLUDED_PATTERNS[@]/#/${KUBE_ROOT}\/hack\/} 2>/dev/null || true) while IFS='' read -r line; do EXCLUDED_CHECKS+=("$line"); done < <(ls "${EXCLUDED_PATTERNS[@]/#/${KUBE_ROOT}\/hack\/}" 2>/dev/null || true)
QUICK_CHECKS=$(ls ${QUICK_PATTERNS[@]/#/${KUBE_ROOT}\/hack\/} 2>/dev/null || true) while IFS='' read -r line; do QUICK_CHECKS+=("$line"); done < <(ls "${QUICK_PATTERNS[@]/#/${KUBE_ROOT}\/hack\/}" 2>/dev/null || true)
TARGET_LIST=() TARGET_LIST=()
IFS=" " read -r -a TARGET_LIST <<< "${WHAT:-}" IFS=" " read -r -a TARGET_LIST <<< "${WHAT:-}"
function is-excluded { function is-excluded {
for e in ${EXCLUDED_CHECKS[@]}; do for e in "${EXCLUDED_CHECKS[@]}"; do
if [[ $1 -ef "${e}" ]]; then if [[ $1 -ef "${e}" ]]; then
return return
fi fi
@ -95,7 +95,7 @@ function is-excluded {
} }
function is-quick { function is-quick {
for e in ${QUICK_CHECKS[@]}; do for e in "${QUICK_CHECKS[@]}"; do
if [[ $1 -ef "${e}" ]]; then if [[ $1 -ef "${e}" ]]; then
return return
fi fi
@ -138,9 +138,9 @@ FAILED_TESTS=()
function print-failed-tests { function print-failed-tests {
echo -e "========================" echo -e "========================"
echo -e "${color_red}FAILED TESTS${color_norm}" echo -e "${color_red:?}FAILED TESTS${color_norm:?}"
echo -e "========================" echo -e "========================"
for t in ${FAILED_TESTS[@]}; do for t in "${FAILED_TESTS[@]}"; do
echo -e "${color_red}${t}${color_norm}" echo -e "${color_red}${t}${color_norm}"
done done
} }
@ -150,10 +150,11 @@ function run-checks {
local -r runner=$2 local -r runner=$2
local t local t
for t in $(ls ${pattern}) for t in ${pattern}
do do
local check_name="$(basename "${t}")" local check_name
if [[ ! -z ${WHAT:-} ]]; then check_name="$(basename "${t}")"
if [[ -n ${WHAT:-} ]]; then
if ! is-explicitly-chosen "${check_name}"; then if ! is-explicitly-chosen "${check_name}"; then
continue continue
fi fi
@ -168,15 +169,16 @@ function run-checks {
fi fi
fi fi
echo -e "Verifying ${check_name}" echo -e "Verifying ${check_name}"
local start=$(date +%s) local start
start=$(date +%s)
run-cmd "${runner}" "${t}" && tr=$? || tr=$? run-cmd "${runner}" "${t}" && tr=$? || tr=$?
local elapsed=$(($(date +%s) - ${start})) local elapsed=$(($(date +%s) - start))
if [[ ${tr} -eq 0 ]]; then if [[ ${tr} -eq 0 ]]; then
echo -e "${color_green}SUCCESS${color_norm} ${check_name}\t${elapsed}s" echo -e "${color_green:?}SUCCESS${color_norm} ${check_name}\t${elapsed}s"
else else
echo -e "${color_red}FAILED${color_norm} ${check_name}\t${elapsed}s" echo -e "${color_red}FAILED${color_norm} ${check_name}\t${elapsed}s"
ret=1 ret=1
FAILED_TESTS+=(${t}) FAILED_TESTS+=("${t}")
fi fi
done done
} }
@ -190,7 +192,7 @@ function missing-target-checks {
do do
[[ -z "${v}" ]] && continue [[ -z "${v}" ]] && continue
FAILED_TESTS+=(${v}) FAILED_TESTS+=("${v}")
ret=1 ret=1
done done
} }