您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

64 行
1.6 KiB

  1. #!/bin/bash
  2. # TODO(deklerk) Add integration tests when it's secure to do so. b/64723143
  3. # Fail on any error
  4. set -eo pipefail
  5. # Display commands being run
  6. set -x
  7. # cd to project dir on Kokoro instance
  8. cd git/gocloud
  9. go version
  10. # Set $GOPATH
  11. export GOPATH="$HOME/go"
  12. export GOCLOUD_HOME=$GOPATH/src/cloud.google.com/go/
  13. export PATH="$GOPATH/bin:$PATH"
  14. # Move code into $GOPATH and get dependencies
  15. mkdir -p $GOCLOUD_HOME
  16. git clone . $GOCLOUD_HOME
  17. cd $GOCLOUD_HOME
  18. try3() { eval "$*" || eval "$*" || eval "$*"; }
  19. download_deps() {
  20. if [[ `go version` == *"go1.11"* ]] || [[ `go version` == *"go1.12"* ]]; then
  21. export GO111MODULE=on
  22. # All packages, including +build tools, are fetched.
  23. try3 go mod download
  24. else
  25. # Because we don't provide -tags tools, the +build tools
  26. # dependencies aren't fetched.
  27. try3 go get -v -t ./...
  28. go get github.com/jstemmer/go-junit-report
  29. fi
  30. }
  31. download_deps
  32. go install github.com/jstemmer/go-junit-report
  33. ./internal/kokoro/vet.sh
  34. mkdir $KOKORO_ARTIFACTS_DIR/tests
  35. # Takes the kokoro output log (raw stdout) and creates a machine-parseable xml
  36. # file (xUnit). Then it exits with whatever exit code the last command had.
  37. create_junit_xml() {
  38. last_status_code=$?
  39. cat $KOKORO_ARTIFACTS_DIR/$KOKORO_GERRIT_CHANGE_NUMBER.txt \
  40. | go-junit-report > $KOKORO_ARTIFACTS_DIR/tests/sponge_log.xml
  41. exit $last_status_code
  42. }
  43. trap create_junit_xml EXIT ERR
  44. # Run tests and tee output to log file, to be pushed to GCS as artifact.
  45. go test -race -v -timeout 15m -short ./... 2>&1 \
  46. | tee $KOKORO_ARTIFACTS_DIR/$KOKORO_GERRIT_CHANGE_NUMBER.txt