diff options
Diffstat (limited to 'vendor/google.golang.org/grpc/vet.sh')
-rw-r--r-- | vendor/google.golang.org/grpc/vet.sh | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/vendor/google.golang.org/grpc/vet.sh b/vendor/google.golang.org/grpc/vet.sh new file mode 100644 index 0000000..94a5064 --- /dev/null +++ b/vendor/google.golang.org/grpc/vet.sh | |||
@@ -0,0 +1,141 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | if [[ `uname -a` = *"Darwin"* ]]; then | ||
4 | echo "It seems you are running on Mac. This script does not work on Mac. See https://github.com/grpc/grpc-go/issues/2047" | ||
5 | exit 1 | ||
6 | fi | ||
7 | |||
8 | set -ex # Exit on error; debugging enabled. | ||
9 | set -o pipefail # Fail a pipe if any sub-command fails. | ||
10 | |||
11 | die() { | ||
12 | echo "$@" >&2 | ||
13 | exit 1 | ||
14 | } | ||
15 | |||
16 | # Check to make sure it's safe to modify the user's git repo. | ||
17 | if git status --porcelain | read; then | ||
18 | die "Uncommitted or untracked files found; commit changes first" | ||
19 | fi | ||
20 | |||
21 | if [[ -d "${GOPATH}/src" ]]; then | ||
22 | die "\${GOPATH}/src (${GOPATH}/src) exists; this script will delete it." | ||
23 | fi | ||
24 | |||
25 | # Undo any edits made by this script. | ||
26 | cleanup() { | ||
27 | rm -rf "${GOPATH}/src" | ||
28 | git reset --hard HEAD | ||
29 | } | ||
30 | trap cleanup EXIT | ||
31 | |||
32 | fail_on_output() { | ||
33 | tee /dev/stderr | (! read) | ||
34 | } | ||
35 | |||
36 | PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}" | ||
37 | |||
38 | if [[ "$1" = "-install" ]]; then | ||
39 | # Check for module support | ||
40 | if go help mod >& /dev/null; then | ||
41 | go install \ | ||
42 | golang.org/x/lint/golint \ | ||
43 | golang.org/x/tools/cmd/goimports \ | ||
44 | honnef.co/go/tools/cmd/staticcheck \ | ||
45 | github.com/client9/misspell/cmd/misspell \ | ||
46 | github.com/golang/protobuf/protoc-gen-go | ||
47 | else | ||
48 | # Ye olde `go get` incantation. | ||
49 | # Note: this gets the latest version of all tools (vs. the pinned versions | ||
50 | # with Go modules). | ||
51 | go get -u \ | ||
52 | golang.org/x/lint/golint \ | ||
53 | golang.org/x/tools/cmd/goimports \ | ||
54 | honnef.co/go/tools/cmd/staticcheck \ | ||
55 | github.com/client9/misspell/cmd/misspell \ | ||
56 | github.com/golang/protobuf/protoc-gen-go | ||
57 | fi | ||
58 | if [[ -z "${VET_SKIP_PROTO}" ]]; then | ||
59 | if [[ "${TRAVIS}" = "true" ]]; then | ||
60 | PROTOBUF_VERSION=3.3.0 | ||
61 | PROTOC_FILENAME=protoc-${PROTOBUF_VERSION}-linux-x86_64.zip | ||
62 | pushd /home/travis | ||
63 | wget https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/${PROTOC_FILENAME} | ||
64 | unzip ${PROTOC_FILENAME} | ||
65 | bin/protoc --version | ||
66 | popd | ||
67 | elif ! which protoc > /dev/null; then | ||
68 | die "Please install protoc into your path" | ||
69 | fi | ||
70 | fi | ||
71 | exit 0 | ||
72 | elif [[ "$#" -ne 0 ]]; then | ||
73 | die "Unknown argument(s): $*" | ||
74 | fi | ||
75 | |||
76 | # - Ensure all source files contain a copyright message. | ||
77 | git ls-files "*.go" | xargs grep -L "\(Copyright [0-9]\{4,\} gRPC authors\)\|DO NOT EDIT" 2>&1 | fail_on_output | ||
78 | |||
79 | # - Make sure all tests in grpc and grpc/test use leakcheck via Teardown. | ||
80 | (! grep 'func Test[^(]' *_test.go) | ||
81 | (! grep 'func Test[^(]' test/*.go) | ||
82 | |||
83 | # - Do not import math/rand for real library code. Use internal/grpcrand for | ||
84 | # thread safety. | ||
85 | git ls-files "*.go" | xargs grep -l '"math/rand"' 2>&1 | (! grep -v '^examples\|^stress\|grpcrand') | ||
86 | |||
87 | # - Ensure all ptypes proto packages are renamed when importing. | ||
88 | git ls-files "*.go" | (! xargs grep "\(import \|^\s*\)\"github.com/golang/protobuf/ptypes/") | ||
89 | |||
90 | # - Check imports that are illegal in appengine (until Go 1.11). | ||
91 | # TODO: Remove when we drop Go 1.10 support | ||
92 | go list -f {{.Dir}} ./... | xargs go run test/go_vet/vet.go | ||
93 | |||
94 | # - gofmt, goimports, golint (with exceptions for generated code), go vet. | ||
95 | gofmt -s -d -l . 2>&1 | fail_on_output | ||
96 | goimports -l . 2>&1 | fail_on_output | ||
97 | golint ./... 2>&1 | (! grep -vE "(_mock|\.pb)\.go:") | ||
98 | go tool vet -all . | ||
99 | |||
100 | # - Check that generated proto files are up to date. | ||
101 | if [[ -z "${VET_SKIP_PROTO}" ]]; then | ||
102 | PATH="/home/travis/bin:${PATH}" make proto && \ | ||
103 | git status --porcelain 2>&1 | fail_on_output || \ | ||
104 | (git status; git --no-pager diff; exit 1) | ||
105 | fi | ||
106 | |||
107 | # - Check that our module is tidy. | ||
108 | if go help mod >& /dev/null; then | ||
109 | go mod tidy && \ | ||
110 | git status --porcelain 2>&1 | fail_on_output || \ | ||
111 | (git status; git --no-pager diff; exit 1) | ||
112 | fi | ||
113 | |||
114 | # - Collection of static analysis checks | ||
115 | ### HACK HACK HACK: Remove once staticcheck works with modules. | ||
116 | # Make a symlink in ${GOPATH}/src to its ${GOPATH}/pkg/mod equivalent for every package we use. | ||
117 | for x in $(find "${GOPATH}/pkg/mod" -name '*@*' | grep -v \/mod\/cache\/); do | ||
118 | pkg="$(echo ${x#"${GOPATH}/pkg/mod/"} | cut -f1 -d@)"; | ||
119 | # If multiple versions exist, just use the existing one. | ||
120 | if [[ -L "${GOPATH}/src/${pkg}" ]]; then continue; fi | ||
121 | mkdir -p "$(dirname "${GOPATH}/src/${pkg}")"; | ||
122 | ln -s $x "${GOPATH}/src/${pkg}"; | ||
123 | done | ||
124 | ### END HACK HACK HACK | ||
125 | |||
126 | # TODO(menghanl): fix errors in transport_test. | ||
127 | staticcheck -go 1.9 -ignore ' | ||
128 | balancer.go:SA1019 | ||
129 | balancer_test.go:SA1019 | ||
130 | clientconn_test.go:SA1019 | ||
131 | balancer/roundrobin/roundrobin_test.go:SA1019 | ||
132 | benchmark/benchmain/main.go:SA1019 | ||
133 | internal/transport/handler_server.go:SA1019 | ||
134 | internal/transport/handler_server_test.go:SA1019 | ||
135 | internal/transport/transport_test.go:SA2002 | ||
136 | stats/stats_test.go:SA1019 | ||
137 | test/channelz_test.go:SA1019 | ||
138 | test/end2end_test.go:SA1019 | ||
139 | test/healthcheck_test.go:SA1019 | ||
140 | ' ./... | ||
141 | misspell -error . | ||