-
Notifications
You must be signed in to change notification settings - Fork 4
/
.travis.yml
102 lines (89 loc) · 2.74 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
language: go
go:
- 1.6
- tip
before_install:
- go get github.com/golang/lint/golint
- go get golang.org/x/tools/cmd/vet
- go get github.com/fzipp/gocyclo
- go get github.com/mattn/goveralls
install:
# make sure stuff actually builds
- go build
script:
# define our own packages so that go does not
# try and build our vendored deps
- |
pkgs=()
while read -r line; do
pkgs+=("$line")
done <<< "$(go list ./... | grep -v 'vendor')"
# ensure everything is formatted all pretty like
- if gofmt -l -s . | grep -v 'vendor/'; then exit 1; fi
# vet out possible issues
- go vet ${pkgs[@]}
# run tests
- go test ${pkgs[@]} -v -race
after_success:
- |
echo "mode: count" > profile.cov
for dir in $(find . -maxdepth 10 -not -path 'vendor' -not -path './.git*' -not -path '*/_*' -type d);
do
if ls $dir/*.go &> /dev/null; then
go test -short -covermode=count -coverprofile=$dir/profile.tmp $dir
if [ -f $dir/profile.tmp ]
then
cat $dir/profile.tmp | tail -n +2 >> profile.cov
rm $dir/profile.tmp
fi
fi
done
go tool cover -func profile.cov
goveralls -coverprofile=profile.cov -service=travis-ci -repotoken=$COVERALLS -v
after_script:
# check possible styling errors
- for pkg in ${pkgs[@]}; do; golint $pkg; done
# check for potentially complex functions but don't fail build
- gocyclo -over 15 . | grep -v 'vendor/' || true
# refresh godocs in case there were api changes
- |
if [[ "$TRAVIS_PULL_REQUEST" == "false" ]] && [[ "$TRAVIS_BRANCH" == "master" ]]; then
go list ./... | xargs -n 1 -I{} curl http://godoc.org/-/refresh -d path={}
fi
before_deploy:
- PLATFORMS=(darwin/386 darwin/amd64 linux/386 linux/amd64 windows/386 windows/amd64)
- BINARY=snag
# build binary for all archs
- |
for PLATFORM in "${PLATFORMS[@]}"; do
echo "Building $PLATFORM"
GOOS=${PLATFORM%/*}
GOARCH=${PLATFORM#*/}
if [ "$GOOS" = "windows" ]; then
build_cmd="GOOS=$GOOS GOARCH=$GOARCH go build -o snag -ldflags '-w -s'"
else
build_cmd="CGO_ENABLED=0 GOOS=$GOOS GOARCH=$GOARCH go build -o snag -ldflags '-d -w -s'"
fi
if ! eval $build_cmd; then
echo "Failed building snag for $PLATFORM" && return 1
fi
if [ "$GOOS" = "windows" ]; then
zip snag-${GOOS}-${GOARCH}.zip snag
else
tar cvzf snag-${GOOS}-${GOARCH}.tgz snag
fi
done
deploy:
provider: releases
api_key: $GITHUB_AUTH_TOKEN
file:
- "snag-darwin-386.tgz"
- "snag-darwin-amd64.tgz"
- "snag-linux-386.tgz"
- "snag-linux-amd64.tgz"
- "snag-windows-386.zip"
- "snag-windows-amd64.zip"
skip_cleanup: true
on:
tags: true
condition: "$TRAVIS_GO_VERSION == *1.6*"