Skip to content

Commit afd2642

Browse files
authored
Create verify-all.sh
1 parent 281b689 commit afd2642

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

hack/verify-all.sh

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/bin/bash
2+
3+
# Copyright 2014 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")/..
22+
source "${SCRIPT_ROOT}/hack/kube-env.sh"
23+
24+
SILENT=true
25+
FAILED_TEST=()
26+
27+
function is-excluded {
28+
for e in $EXCLUDE; do
29+
if [[ $1 -ef ${BASH_SOURCE} ]]; then
30+
return
31+
fi
32+
if [[ $1 -ef "$SCRIPT_ROOT/hack/$e" ]]; then
33+
return
34+
fi
35+
done
36+
return 1
37+
}
38+
39+
while getopts ":v" opt; do
40+
case $opt in
41+
v)
42+
SILENT=false
43+
;;
44+
\?)
45+
echo "Invalid flag: -$OPTARG" >&2
46+
exit 1
47+
;;
48+
esac
49+
done
50+
51+
if $SILENT ; then
52+
echo "Running in the silent mode, run with -v if you want to see script logs."
53+
fi
54+
55+
EXCLUDE="verify-all.sh"
56+
57+
SCRIPTS=$(find "${SCRIPT_ROOT}"/hack -name "verify-*.sh")
58+
59+
ret=0
60+
for t in $SCRIPTS;
61+
do
62+
if is-excluded "${t}" ; then
63+
echo "Skipping $t"
64+
continue
65+
fi
66+
if $SILENT ; then
67+
echo -e "Verifying $t"
68+
if bash "$t" &> /dev/null; then
69+
echo -e "${color_green}SUCCESS${color_norm}"
70+
else
71+
echo -e "${color_red}FAILED: $t ${color_norm}"
72+
FAILED_TEST+=("$t")
73+
ret=1
74+
fi
75+
else
76+
if bash "$t"; then
77+
echo -e "${color_green}SUCCESS: $t ${color_norm}"
78+
else
79+
echo -e "${color_red}Test FAILED: $t ${color_norm}"
80+
FAILED_TEST+=("$t")
81+
ret=1
82+
fi
83+
fi
84+
done
85+
86+
if [ ${#FAILED_TEST[@]} -ne 0 ]; then
87+
echo -e "\n${color_red}Summary of failed tests:${color_norm}"
88+
for test in "${FAILED_TEST[@]}"; do
89+
echo -e "${color_red}- $test${color_norm}"
90+
done
91+
else
92+
echo -e "\n${color_green}All tests passed successfully.${color_norm}"
93+
fi
94+
95+
exit $ret
96+
97+
# ex: ts=2 sw=2 et filetype=sh

0 commit comments

Comments
 (0)