-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_tests.sh
executable file
·37 lines (34 loc) · 1.02 KB
/
run_tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
echo 'exec echo ${GIT_TOKEN}' > /tmp/askpass.sh && chmod +x /tmp/askpass.sh
export GIT_ASKPASS=/tmp/askpass.sh
export CGO_ENABLED=1
# Function to check if a directory contains a go.mod file
has_go_mod() {
[ -e "go.mod" ]
}
# get the go version from the go version command 1.18/1.19/1.20/1.21
go_version=`go version | cut -c 14-17`
# Recursive function to run tests in all directories
run_tests_recursive() {
for d in */; do
cd "$d"
if has_go_mod $d; then
mod_version=`sed -En 's/^go[[:space:]]+([[:digit:].]+)$/\1/p' go.mod`;
printf '%s\n' "$d module go version - $go_version"
if [ "$go_version" = "$mod_version" ]; then
printf '%s\n' "----------- Testing module - $d -------------------"
make run-test
if [ $? -eq 0 ]; then
echo "$d tests ran successfully"
else
exit 1
fi
else
printf '%s\n' "------- skipping module - $d ---------------"
fi
else
run_tests_recursive "$d"
fi
cd ..
done
}
run_tests_recursive