mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
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:
@@ -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
13
travis/gofmt.sh
Executable 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
13
travis/govet.sh
Executable 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
|
||||
Reference in New Issue
Block a user