Fix Travis to properly fail the build on go fmt and go vet.

When running go fmt/vet, they do not exit non-zero if they detect any issues,
they only print out information. This wraps go fmt/vet in a script that
captures the output to a temp file and checks if anything was written to it.
If any was, it prints it out then exits 1.
This commit is contained in:
Ken Robertson
2014-08-12 23:01:21 -07:00
parent 39e7050187
commit dacf0e033a
3 changed files with 28 additions and 2 deletions

View File

@@ -13,8 +13,8 @@ install:
- go get github.com/mattn/goveralls
script:
- go build
- go fmt ./...
- go vet ./...
- ./travis/gofmt.sh
- ./travis/govet.sh
- go test -i -race ./...
- go test -v -race ./...
- ./travis/coveralls-script.sh

13
travis/gofmt.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/sh
# run go fmt and exit non-zero if it detected anything
T=$(mktemp -t gofmt.XXXXX)
go fmt ./... > $T
if egrep -q '.*' "$T" ; then
echo "go fmt failed on the following files:"
cat "$T"
rm $T
exit 1
fi
rm $T
exit 0

13
travis/govet.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/sh
# run go vet and exit non-zero if it detected anything
T=$(mktemp -t govet.XXXXX)
go vet ./... > $T
if egrep -q '.*' "$T" ; then
echo "go vet failed on the following files:"
cat "$T"
rm $T
exit 1
fi
rm $T
exit 0