@@ -18,13 +18,14 @@ set -o errexit
18
18
set -o nounset
19
19
set -o pipefail
20
20
21
- KUBE_ROOT=$( dirname " ${BASH_SOURCE} " ) /..
21
+ # cd to the repo root
22
+ REPO_ROOT=$( git rev-parse --show-toplevel)
23
+ cd " ${REPO_ROOT} "
22
24
23
25
# Some useful colors.
24
26
if [[ -z " ${color_start-} " ]]; then
25
27
declare -r color_start=" \033["
26
28
declare -r color_red=" ${color_start} 0;31m"
27
- declare -r color_yellow=" ${color_start} 0;33m"
28
29
declare -r color_green=" ${color_start} 0;32m"
29
30
declare -r color_norm=" ${color_start} 0m"
30
31
fi
@@ -38,7 +39,7 @@ EXCLUDED_PATTERNS=(
38
39
" verify-golangci-lint.sh"
39
40
)
40
41
41
- EXCLUDED_CHECKS=$( ls ${EXCLUDED_PATTERNS[@]/#/ ${KUBE_ROOT } \/ hack\/ } 2> /dev/null || true)
42
+ EXCLUDED_CHECKS=$( ls ${EXCLUDED_PATTERNS[@]/#/ ${REPO_ROOT } \/ hack\/ } 2> /dev/null || true)
42
43
43
44
function is-excluded {
44
45
for e in ${EXCLUDED_CHECKS[@]} ; do
@@ -57,14 +58,14 @@ function run-cmd {
57
58
fi
58
59
}
59
60
60
- # Collect Failed tests in this Array , initialize it to nil
61
+ # Collect failed tests in this array; initialize it to nil
61
62
FAILED_TESTS=()
62
63
63
64
function print-failed-tests {
64
65
echo -e " ========================"
65
66
echo -e " ${color_red} FAILED TESTS${color_norm} "
66
67
echo -e " ========================"
67
- for t in ${FAILED_TESTS[@]} ; do
68
+ for t in " ${FAILED_TESTS[@]} " ; do
68
69
echo -e " ${color_red}${t}${color_norm} "
69
70
done
70
71
}
@@ -74,23 +75,30 @@ function run-checks {
74
75
local -r runner=$2
75
76
76
77
local t
78
+ local check_name
79
+ local start
80
+
77
81
for t in $( ls ${pattern} )
78
82
do
79
- local check_name=" $( basename " ${t} " ) "
83
+ check_name=" $( basename " ${t} " ) "
80
84
if is-excluded " ${t} " ; then
81
85
echo " Skipping ${check_name} "
82
86
continue
83
87
fi
88
+
84
89
echo -e " Verifying ${check_name} "
85
- local start=$( date +%s)
90
+
91
+ start=$( date +%s)
86
92
run-cmd " ${runner} " " ${t} " && tr=$? || tr=$?
87
- local elapsed=$(( $(date +% s) - ${start} ))
93
+ local elapsed=$(( $(date +% s) - start))
94
+
88
95
if [[ ${tr} -eq 0 ]]; then
89
96
echo -e " ${color_green} SUCCESS${color_norm} ${check_name} \t${elapsed} s"
90
97
else
91
98
echo -e " ${color_red} FAILED${color_norm} ${check_name} \t${elapsed} s"
92
99
ret=1
93
- FAILED_TESTS+=(${t} )
100
+
101
+ FAILED_TESTS+=(" ${t} " )
94
102
fi
95
103
done
96
104
}
@@ -114,11 +122,12 @@ if ${SILENT} ; then
114
122
fi
115
123
116
124
ret=0
117
- run-checks " ${KUBE_ROOT } /hack/verify-*.sh" bash
125
+ run-checks " ${REPO_ROOT } /hack/verify-*.sh" bash
118
126
119
127
if [[ ${ret} -eq 1 ]]; then
120
- print-failed-tests
128
+ print-failed-tests
121
129
fi
130
+
122
131
exit ${ret}
123
132
124
133
# ex: ts=2 sw=2 et filetype=sh
0 commit comments