os:
- linux
- windows
language: go
go:
- 1.15.x
- 1.14.x
addons:
  apt:
    packages:
    - rpm
env:
- GO111MODULE=off
go_import_path: github.com/nats-io/nats-streaming-server
install:
- go get -t ./...
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
    go get -u honnef.co/go/tools/cmd/staticcheck;
    go get -u github.com/client9/misspell/cmd/misspell;
    go get -u github.com/go-sql-driver/mysql;
  fi
services:
- mysql
before_script:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
    GO_LIST=$(go list ./... | grep -v "/spb");
    go install;
    $(exit $(go fmt $GO_LIST | wc -l));
    go vet $GO_LIST;
    find . -type f -name "*.go" | grep -v "/vendor/" | grep -v "/spb/" | xargs misspell -error -locale US;
    staticcheck $GO_LIST;
  fi
script:
- set -e
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
    mysql -u root -e "CREATE USER 'nss'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON *.* TO 'nss'@'localhost'; CREATE DATABASE test_nats_streaming;";
    go test -i ./...;
    if [[ "$TRAVIS_GO_VERSION" =~ 1.14 ]]; then ./scripts/cov.sh TRAVIS; else go test -v -failfast -p=1 ./...; fi;
  fi
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
    go install;
    go test -v -p=1 ./... -count=1 -sql=false -failfast;
  fi
- set +e

deploy:
  provider: script
  cleanup: true
  script: curl -sL http://git.io/goreleaser | bash
  on:
    tags: true
    condition: ("$TRAVIS_OS_NAME" = "linux") && ("$TRAVIS_GO_VERSION" =~ "1.14")
