github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/scripts/verify.bash (about) 1 #!/bin/bash 2 # Copyright 2014 Canonical Ltd. 3 # Licensed under the AGPLv3, see LICENCE file for details. 4 5 # This is called from pre-push.bash to do some verification checks on 6 # the Go code. The script will exit non-zero if any of these tests 7 # fail. However if environment variable IGNORE_VET_WARNINGS is a non-zero 8 # length string, go vet warnings will not exit non-zero. 9 10 set -e 11 12 VERSION=`go version | awk '{print $3}'` 13 echo "go version $VERSION" 14 15 echo "checking: go fmt ..." 16 BADFMT=`find * -name '*.go' -not -name '.#*' | xargs gofmt -l` 17 if [ -n "$BADFMT" ]; then 18 BADFMT=`echo "$BADFMT" | sed "s/^/ /"` 19 echo -e "gofmt is sad:\n\n$BADFMT" 20 exit 1 21 fi 22 23 24 echo "checking: go vet ..." 25 26 # Define additional Printf style functions to check. These add to the 27 # default list of standard library functions that go vet already has. 28 logging_prints="\ 29 Tracef 30 Debugf 31 Infof 32 Warningf 33 Errorf 34 Criticalf 35 " 36 37 error_prints="\ 38 AlreadyExistsf 39 BadRequestf 40 MethodNotAllowedf 41 NotAssignedf 42 NotFoundf 43 NotImplementedf 44 NotProvisionedf 45 NotSupportedf 46 NotValidf 47 Unauthorizedf 48 UserNotFoundf 49 " 50 51 # Under Go 1.6, the vet docs say that -printfuncs takes each print 52 # function in "name:N" format. This has changed in Go 1.7 and doesn't 53 # actually seem to make a difference under 1.6 either don't bother. 54 all_prints=`echo $logging_prints $error_prints | tr " " ,` 55 56 go tool vet \ 57 -all \ 58 -composites=false \ 59 -copylocks=false \ 60 -printfuncs=$all_prints \ 61 . || [ -n "$IGNORE_VET_WARNINGS" ] 62 63 64 echo "checking: go build ..." 65 go build github.com/juju/juju/... 66 67 echo "checking: tests are wired up ..." 68 ./scripts/checktesting.bash