3 set -ex # Exit on error; debugging enabled.
4 set -o pipefail # Fail a pipe if any sub-command fails.
11 # TODO: Remove this check and the mangling below once "context" is imported
13 if git status --porcelain | read; then
14 die "Uncommitted or untracked files found; commit changes first"
17 PATH="$GOPATH/bin:$GOROOT/bin:$PATH"
19 # Check proto in manual runs or cron runs.
20 if [[ "$TRAVIS" != "true" || "$TRAVIS_EVENT_TYPE" = "cron" ]]; then
24 if [ "$1" = "-install" ]; then
26 google.golang.org/grpc/...
28 github.com/golang/lint/golint \
29 golang.org/x/tools/cmd/goimports \
30 honnef.co/go/tools/cmd/staticcheck \
31 github.com/golang/protobuf/protoc-gen-go \
32 golang.org/x/tools/cmd/stringer
33 if [[ "$check_proto" = "true" ]]; then
34 if [[ "$TRAVIS" = "true" ]]; then
35 PROTOBUF_VERSION=3.3.0
36 PROTOC_FILENAME=protoc-${PROTOBUF_VERSION}-linux-x86_64.zip
38 wget https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/${PROTOC_FILENAME}
39 unzip ${PROTOC_FILENAME}
42 elif ! which protoc > /dev/null; then
43 die "Please install protoc into your path"
47 elif [[ "$#" -ne 0 ]]; then
48 die "Unknown argument(s): $*"
51 git ls-files "*.go" | xargs grep -L "\(Copyright [0-9]\{4,\} gRPC authors\)\|DO NOT EDIT" 2>&1 | tee /dev/stderr | (! read)
52 gofmt -s -d -l . 2>&1 | tee /dev/stderr | (! read)
53 goimports -l . 2>&1 | tee /dev/stderr | (! read)
54 golint ./... 2>&1 | (grep -vE "(_mock|_string|\.pb)\.go:" || true) | tee /dev/stderr | (! read)
56 # Undo any edits made by this script.
62 # Rewrite golang.org/x/net/context -> context imports (see grpc/grpc-go#1484).
63 # TODO: Remove this mangling once "context" is imported directly (grpc/grpc-go#711).
64 git ls-files "*.go" | xargs sed -i 's:"golang.org/x/net/context":"context":'
66 # TODO: Stop filtering pb.go files once golang/protobuf#214 is fixed.
67 go tool vet -all . 2>&1 | grep -vF '.pb.go:' | tee /dev/stderr | (! read)
71 if [[ "$check_proto" = "true" ]]; then
72 PATH="/home/travis/bin:$PATH" make proto && \
73 git status --porcelain 2>&1 | (! read) || \
74 (git status; git --no-pager diff; exit 1)
77 # TODO(menghanl): fix errors in transport_test.
78 staticcheck -ignore google.golang.org/grpc/transport/transport_test.go:SA2002 ./...