@@ -2,26 +2,57 @@ language: go
22sudo : required
33
44go :
5- - 1.9 .x
5+ - 1.11 .x
66 - stable
77 - master
88
9+ matrix :
10+ # Failing on the development version of Go isn't too bad.
11+ allow_failures :
12+ - go : master
13+
14+ env :
15+ - GO111MODULE=on
16+
17+ # Override Travis's default 'go get' step, since we use Go modules
918install :
10- # We need goverage to run go tests with -coverprofile for multiple packages
11- - go get github.com/haya14busa/goverage
12- # Download test data
13- - pushd cs-demos && git lfs pull -I '*' && popd
19+ - go mod download
1420
1521before_script :
16- # We don't want to run the demo set test with race condition testing.
17- # The demo set is large and race tests take a lot longer
18- - race_tests=$(go test -list . | grep -v "TestDemoSet\|Benchmark" | head -n -1 | awk -vORS=\| '{ print $1 }' | sed 's/|$/\n/')
22+ # Install interface generator
23+ - GO111MODULE=off go get github.com/vburenin/ifacemaker
24+
25+ # Fetch refs for linter
26+ - git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
27+ - git fetch
28+
29+ # Install golangci-lint
30+ - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $GOPATH/bin v1.12.2
31+
32+ # Download test data
33+ - pushd cs-demos && git lfs pull -I '*' && popd
1934
2035script :
36+ - go build ./...
37+
38+ # Make sure generated code is up-to-date
39+ - go generate
40+ - diff_output=$(git diff)
41+ - if [[ "$diff_output" != "" ]]; then echo "Generated code is not up-to-date" && echo "$diff_output" && exit 1; fi
42+
43+ # Lint changed code
44+ - if [[ "$TRAVIS_COMMIT_RANGE" != "" ]]; then commit_range=${TRAVIS_COMMIT_RANGE/.../..} && git diff $commit_range > /dev/null && base_rev=$commit_range || true; fi
45+ - if [[ "$base_rev" = "" ]]; then base_rev='origin/master'; fi && echo "Linting changes between/since $base_rev"
46+ - golangci-lint run --new-from-rev $base_rev
47+
48+ # Get list of tests to run with race detection.
49+ # We don't want to run the entire demo set with it because it's large and race tests take a lot longer.
50+ - race_tests=$(go test -list . | grep -v "TestDemoSet\|Benchmark" | head -n -1 | awk -vORS=\| '{ print $1 }' | sed 's/|$/\n/')
2151 # Run race tests
2252 - go test -v -race -run "$race_tests" -timeout 15m
53+
2354 # We run all tests again to get full coverage, technically unncecessary tho
24- - goverage -v -timeout 30m -coverprofile=coverage.txt $(go list ./... | grep -v msg | awk -vORS=' ' ' { print $1 }')
55+ - go test -v -timeout 30m -coverprofile=coverage.txt -coverpkg= $(go list ./... | grep -v msg | awk -vORS=, ' { print $1 }' | sed 's/,$/\n/') ./...
2556
2657after_success :
2758 - bash <(curl -s https://codecov.io/bash)
0 commit comments