forked from linkedin/Burrow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
68 lines (58 loc) · 2.59 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
dist: xenial
language: go
go:
- 1.11.x
- 1.12.x
- master
env:
- DEP_VERSION="0.5.1"
sudo: required
services:
- docker
before_install:
# Download the binary to bin folder in $GOPATH
- curl -L -s https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 -o $GOPATH/bin/dep
# Make the binary executable
- chmod +x $GOPATH/bin/dep
install:
- dep ensure
matrix:
# It's ok if our code fails on unstable development versions of Go.
allow_failures:
- go: master
# Don't wait for tip tests to finish. Mark the test run green if the
# tests pass on the stable versions of Go.
fast_finish: true
# Don't email me the results of the test runs.
notifications:
email: false
webhooks:
urls:
- https://webhooks.gitter.im/e/ec30ac1bb280c976f8be
on_success: change # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always
on_start: never # options: [always|never|change] default: always
# Anything in before_script that returns a nonzero exit code will
# flunk the build and immediately stop. It's sorta like having
# set -e enabled in bash.
before_script:
- GO_FILES=$(find . -iname '*.go' -type f | grep -v /vendor/) # All the .go files, excluding vendor/
- go get golang.org/x/lint/golint # Linter
- go get honnef.co/go/tools/cmd/staticcheck # Badass static analyzer/linter
- go get github.com/fzipp/gocyclo
- go get github.com/mattn/goveralls
# script always run to completion (set +e). All of these code checks are must haves
# in a modern Go project.
script:
- test -z "$(gofmt -s -l $GO_FILES)" # Fail if a .go file hasn't been formatted with gofmt
- go test --timeout 5s -v -race ./... # Run all the tests with the race detector enabled
- ./testAndCover.sh # Run the tests again to get coverage info
- go vet -composites=false ./... # go vet is the official Go static analyzer
- staticcheck ./... # "go vet on steroids" + linter
- gocyclo -over 15 $GO_FILES # forbid code with huge functions
- golint -set_exit_status $(go list ./...) # one last linter
# If the build succeeds, send coverage to coveralls
# goreleaser will run if the latest version tag matches the current commit
after_success:
- $GOPATH/bin/goveralls -coverprofile=profile.cov -service=travis-ci
- if [[ "$TRAVIS_SECURE_ENV_VARS" == true && "$TRAVIS_GO_VERSION" == 1.12* ]]; then docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"; curl -sL https://git.io/goreleaser | bash; fi