| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# Fail on any error |
| 4 |
set -eo |
| 5 |
|
| 6 |
# Display commands being run |
| 7 |
set -x |
| 8 |
|
| 9 |
# cd to project dir on Kokoro instance |
| 10 |
cd github/gax-go |
| 11 |
|
| 12 |
go version |
| 13 |
|
| 14 |
# Set $GOPATH |
| 15 |
export GOPATH="$HOME/go" |
| 16 |
export PATH="$GOPATH/bin:$PATH" |
| 17 |
export GO111MODULE=on |
| 18 |
|
| 19 |
try3() { eval "$*" || eval "$*" || eval "$*"; } |
| 20 |
|
| 21 |
# All packages, including +build tools, are fetched. |
| 22 |
try3 go mod download |
| 23 |
./internal/kokoro/vet.sh |
| 24 |
|
| 25 |
go get github.com/jstemmer/go-junit-report |
| 26 |
|
| 27 |
set +e |
| 28 |
|
| 29 |
go test -race -v . 2>&1 | tee sponge_log.log |
| 30 |
cat sponge_log.log | go-junit-report -set-exit-code > sponge_log.xml |
| 31 |
exit_code=$? |
| 32 |
|
| 33 |
cd v2 |
| 34 |
set -e |
| 35 |
try3 go mod download |
| 36 |
set +e |
| 37 |
|
| 38 |
go test -race -v . 2>&1 | tee sponge_log.log |
| 39 |
cat sponge_log.log | go-junit-report -set-exit-code > sponge_log.xml |
| 40 |
exit_code=$(($exit_code+$?)) |
| 41 |
|
| 42 |
# Send logs to Flaky Bot for continuous builds. |
| 43 |
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then |
| 44 |
cd .. |
| 45 |
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot |
| 46 |
$KOKORO_GFILE_DIR/linux_amd64/flakybot |
| 47 |
fi |
| 48 |
|
| 49 |
exit $exit_code |