forked from markus-wa/demoinfocs-golang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
69 lines (54 loc) · 2.34 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
69
language: go
sudo: required
go:
- 1.11.x
- stable
- master
matrix:
# Failing on the development version of Go isn't too bad.
allow_failures:
- go: master
env:
- GO111MODULE=on
# Override Travis's default 'go get' step, since we use Go modules
install:
- go mod download
before_script:
# Install interface generator
- GO111MODULE=off go get github.com/vburenin/ifacemaker
# Fetch refs for linter
- git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
- git fetch
# Install golangci-lint
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $GOPATH/bin v1.16.0
# Download test data
- pushd cs-demos && git lfs pull -I '*' && popd
script:
- go build ./...
# Make sure generated code is up-to-date
- go generate
- diff_output=$(git diff)
- if [[ "$diff_output" != "" ]]; then echo "Generated code is not up-to-date" && echo "$diff_output" && exit 1; fi
# Lint changed code
- if [[ "$TRAVIS_COMMIT_RANGE" != "" ]]; then commit_range=${TRAVIS_COMMIT_RANGE/.../..} && git diff $commit_range > /dev/null && base_rev=$commit_range || true; fi
- if [[ "$base_rev" = "" ]]; then base_rev='origin/master'; fi && echo "Linting changes between/since $base_rev"
- golangci-lint run --new-from-rev $base_rev
# Get list of tests to run with race detection.
# We don't want to run the entire demo set with it because it's large and race tests take a lot longer.
- race_tests=$(go test -list . | grep -v "TestDemoSet\|Benchmark" | head -n -1 | awk -vORS=\| '{ print $1 }' | sed 's/|$/\n/')
# Run race tests
- go test -v -race -run "$race_tests" -timeout 15m
# We run all tests again to get full coverage, technically unnecessary tho
- coverpkg_ignore='/(msg|fake)'
# coverpkg for multiple mains is broken in 1.12, so we need to exclude the examples from coverage
# https://github.com/golang/go/issues/30374
- if ! [[ "$TRAVIS_GO_VERSION" =~ ^1\.11 ]]; then coverpkg_ignore="${coverpkg_ignore}|/examples"; fi
- go test -v -timeout 30m -coverprofile=coverage.txt -coverpkg=$(go list ./... | grep -v -E ${coverpkg_ignore} | awk -vORS=, '{ print $1 }' | sed 's/,$/\n/') ./...
after_success:
- bash <(curl -s https://codecov.io/bash)
notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/511da3cf50cdf951116d
on_success: change
on_failure: always