-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathci-test.sh
executable file
·62 lines (49 loc) · 1.69 KB
/
ci-test.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
set -e
export GO111MODULE=on
# print a command and execute it
show() {
echo "$@" >&2
eval "$@"
}
fatal() {
echo "$@" >&2
exit 1
}
TEST_TIMEOUT=20m
show go vet . || fatal "go vet errored"
GO_FILES=$(find * -name '*.go' -not -path 'vendor/*' -not -name 'bindata.go')
echo "Formatting checks..."
FMT_FILES="$(gofmt -s -l ${GO_FILES})"
if [[ -n ${FMT_FILES} ]]; then
fatal "Run 'gofmt -s -w' on these files:\n$FMT_FILES"
fi
echo "gofmt check is ok!"
IMP_FILES="$(goimports -l ${GO_FILES})"
if [[ -n ${IMP_FILES} ]]; then
fatal "Run 'goimports -w' on these files:\n$IMP_FILES"
fi
echo "goimports check is ok!"
for pkg in $(go list github.com/TykTechnologies/tyk-pump/...);
do
race="-race"
echo "Testing... $pkg"
if [[ ${pkg} == *"pumps" ]]; then
# run pumps tests without race detector until we add correct testing
race=""
# run tests twice for tyk-pump/pumps with different MONGO_DRIVER values
MONGO_DRIVERS=("mgo" "mongo-go")
for mongo_driver in "${MONGO_DRIVERS[@]}"; do
echo "Running tests with MONGO_DRIVER=$mongo_driver"
export MONGO_DRIVER=$mongo_driver
coveragefile=`echo "$pkg" | awk -F/ '{print $NF}'`
show go test -timeout ${TEST_TIMEOUT} ${race} --coverprofile=${coveragefile}.cov -v ${pkg}
done
else
coveragefile=`echo "$pkg" | awk -F/ '{print $NF}'`
show go test -timeout ${TEST_TIMEOUT} ${race} --coverprofile=${coveragefile}.cov -v ${pkg}
fi
echo "Running tests with GOEXPERIMENT=boringcrypto"
export GOEXPERIMENT=boringcrypto
show go test -tags=boringcrypto -timeout ${TEST_TIMEOUT} ${race} --coverprofile=${coveragefile}.cov -v ${pkg}
done