github.com/dbernstein1/tyk@v2.9.0-beta9-dl-apic+incompatible/bin/ci-test.sh (about) 1 #!/bin/bash 2 3 TEST_TIMEOUT=3m 4 5 # print a command and execute it 6 show() { 7 echo "$@" >&2 8 eval "$@" 9 } 10 11 fatal() { 12 echo "$@" >&2 13 exit 1 14 } 15 16 race="" 17 if [[ ${LATEST_GO} ]]; then 18 FMT_FILES=$(gofmt -l . | grep -v vendor) 19 if [[ -n $FMT_FILES ]]; then 20 fatal "Run 'gofmt -w' on these files:\n$FMT_FILES" 21 fi 22 23 echo "gofmt check is ok!" 24 25 IMP_FILES="$(goimports -l . | grep -v vendor)" 26 if [[ -n $IMP_FILES ]]; then 27 fatal "Run 'goimports -w' on these files:\n$IMP_FILES" 28 fi 29 30 echo "goimports check is ok!" 31 32 # Run with race if latest 33 race="-race" 34 fi 35 36 PKGS="$(go list -tags "coprocess python grpc" ./...)" 37 38 go get -t 39 40 # build Go-plugin used in tests 41 go build ${race} -o ./test/goplugins/goplugins.so -buildmode=plugin ./test/goplugins || fatal "building Go-plugin failed" 42 43 for pkg in $PKGS; do 44 tags="" 45 46 # TODO: Remove skipRace variable after solving race conditions in tests. 47 skipRace=false 48 if [[ ${pkg} == *"coprocess/grpc" ]]; then 49 tags="-tags 'coprocess grpc'" 50 skipRace=true 51 elif [[ ${pkg} == *"coprocess/python" ]]; then 52 tags="-tags 'coprocess python'" 53 elif [[ ${pkg} == *"coprocess" ]]; then 54 tags="-tags 'coprocess'" 55 skipRace=true 56 elif [[ ${pkg} == *"goplugin" ]]; then 57 tags="-tags 'goplugin'" 58 fi 59 60 race="" 61 62 # Some tests should not be run with -race. Therefore, test them with penultimate Go version. 63 # And, test with -race in latest Go version. 64 if [[ ${LATEST_GO} && ${skipRace} = false ]]; then 65 race="-race" 66 fi 67 68 show go test -v ${race} -timeout ${TEST_TIMEOUT} -coverprofile=test.cov $pkg ${tags} || fatal "Test Failed" 69 show go vet ${tags} $pkg || fatal "go vet errored" 70 done