language: go
go_import_path: github.com/newrelic/go-agent
go:
    - "1.3"
    - "1.4"
    - "1.5"
    - "1.6"
    - "1.7"
    - "1.8"
    - "1.9"
    - "1.10"
    - "1.11"

# Skip the install step. Don't `go get` dependencies. Only build with the
# code in vendor/
install: true

# golint requires a supported version of Go, which in practice is currently 1.9+.
# See: https://github.com/golang/lint#installation
# For simplicity, run it on a single Go version: 1.11
# Also, only run gofmt on 1.11:  The format output changed from 1.10 to 1.11.
before_script:
  - GO_FILES=$(find . -iname '*.go' -type f | grep -v /vendor/)
  - DO_GOLINT=$(if [[ "$TRAVIS_GO_VERSION" = "1.11" ]]; then echo "0"; else echo "1"; fi)
  - DO_GOFMT=$(if [[ "$TRAVIS_GO_VERSION" = "1.11" ]]; then echo "0"; else echo "1"; fi)
  - if [[ "$DO_GOLINT" -eq "0" ]]; then go get -u golang.org/x/lint/golint; fi

script:
  - if [ "$DO_GOFMT" -eq 0 ] && [ -n "$(gofmt -s -l $GO_FILES)" ]; then exit 1; fi; # gofmt
  - go test -v -race ./... # go test
  - go vet ./... # go vet
  - if [ "$DO_GOLINT" -eq 0 ]; then golint -set_exit_status $(go list ./...); fi # golint
