-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.travis.yml
61 lines (54 loc) · 1.38 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
os: linux
dist: xenial
language: go
jobs:
include:
- go: "master"
env: "GOIMPORTS_CHECK=0"
- go: "1.15.5"
env: "GOIMPORTS_CHECK=1"
cache:
directories:
- $HOME/.cache/go-build
- $HOME/gopath/pkg/mod
env:
global:
- GO111MODULE=on
- GORACE="halt_on_error=1"
before_script:
- set -eo pipefail
- |
if test $GOIMPORTS_CHECK -eq 1
then
go get -u golang.org/x/tools/cmd/goimports
fi
script:
# We could merge the two commands below for efficiency, but it would give less comprehensive errors
# Check files syntax and basic formatting
- |
function checkEmpty() {
if [ -n "$1" ]
then
echo -e "\nFiles with syntax or formatting errors ($ERR_FILES)\n"
return 1
fi
}
# If a syntax error occurs, the following command fails
- ERR_FILES=`find . -name "*.go" -execdir gofmt -l -s '{}' \+`
# Then check formatting errors
- checkEmpty "$ERR_FILES"
# Check advanced files formatting, including imports
- |
if test $GOIMPORTS_CHECK -eq 1
then
ERR_FILES=`find . -name "*.go" -execdir goimports -l '{}' \+`
checkEmpty "$ERR_FILES"
fi
# Run the test suite
- go test -v ./...
# whitelist long living branches to avoid testing feature branches twice (as branch and as pull request)
branches:
only:
- master
- /^v[0-9]+\.[0-9]+\.x$/
- /^v[0-9]+\.[0-9]+\.[0-9]+$/