Travis/Makefile/vet cleanups (#2283)
- .travis.yml: - Download dependencies at install time - Run race and non-race in separate instances - Use braces around env var names - vet.sh: - Run `go mod tidy` to keep it tidy - Stop filtering transport errors from go/vet output - Use braces around env var names - Makefile: - Reorder alphabetically - Add "vetdeps" as a dependency of "vet" - Add "testappengine" to "all"
This commit is contained in:
23
.travis.yml
23
.travis.yml
@ -3,7 +3,9 @@ language: go
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- go: 1.11.x
|
- go: 1.11.x
|
||||||
env: VET=1 RACE=1 GO111MODULE=on
|
env: VET=1 GO111MODULE=on
|
||||||
|
- go: 1.11.x
|
||||||
|
env: RACE=1 GO111MODULE=on
|
||||||
- go: 1.11.x
|
- go: 1.11.x
|
||||||
env: RUN386=1
|
env: RUN386=1
|
||||||
- go: 1.11.x
|
- go: 1.11.x
|
||||||
@ -18,18 +20,19 @@ matrix:
|
|||||||
go_import_path: google.golang.org/grpc
|
go_import_path: google.golang.org/grpc
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- if [[ "$GO111MODULE" = "on" ]]; then mkdir "$HOME/go"; export GOPATH="$HOME/go"; fi
|
- if [[ "${GO111MODULE}" = "on" ]]; then mkdir "${HOME}/go"; export GOPATH="${HOME}/go"; fi
|
||||||
- if [[ -n "$RUN386" ]]; then export GOARCH=386; fi
|
- if [[ -n "${RUN386}" ]]; then export GOARCH=386; fi
|
||||||
- if [[ "$TRAVIS_EVENT_TYPE" = "cron" && -z "$RUN386" ]]; then RACE=1; fi
|
- if [[ "${TRAVIS_EVENT_TYPE}" = "cron" && -z "${RUN386}" ]]; then RACE=1; fi
|
||||||
- if [[ "$TRAVIS_EVENT_TYPE" != "cron" ]]; then VET_SKIP_PROTO=1; fi
|
- if [[ "${TRAVIS_EVENT_TYPE}" != "cron" ]]; then VET_SKIP_PROTO=1; fi
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- if [[ "$GAE" = 1 ]]; then source ./install_gae.sh; fi
|
- if [[ "${GO111MODULE}" = "on" ]]; then go mod download; else make testdeps; fi
|
||||||
- if [[ "$VET" = 1 ]]; then ./vet.sh -install; fi
|
- if [[ "${GAE}" = 1 ]]; then source ./install_gae.sh; make testappenginedeps; fi
|
||||||
|
- if [[ "${VET}" = 1 ]]; then ./vet.sh -install; fi
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- set -e
|
- set -e
|
||||||
- if [[ "$GAE" = 1 ]]; then make testappengine; exit 0; fi
|
- if [[ "${VET}" = 1 ]]; then ./vet.sh; fi
|
||||||
- if [[ "$VET" = 1 ]]; then ./vet.sh; fi
|
- if [[ "${GAE}" = 1 ]]; then make testappengine; exit 0; fi
|
||||||
|
- if [[ "${RACE}" = 1 ]]; then make testrace; exit 0; fi
|
||||||
- make test
|
- make test
|
||||||
- if [[ "$RACE" = 1 ]]; then make testrace; fi
|
|
||||||
|
65
Makefile
65
Makefile
@ -1,23 +1,14 @@
|
|||||||
all: vet test testrace
|
all: vet test testrace testappengine
|
||||||
|
|
||||||
deps:
|
|
||||||
go get -d -v google.golang.org/grpc/...
|
|
||||||
|
|
||||||
updatedeps:
|
|
||||||
go get -d -v -u -f google.golang.org/grpc/...
|
|
||||||
|
|
||||||
testdeps:
|
|
||||||
go get -d -v -t google.golang.org/grpc/...
|
|
||||||
|
|
||||||
testgaedeps:
|
|
||||||
goapp get -d -v -t -tags 'appengine appenginevm' google.golang.org/grpc/...
|
|
||||||
|
|
||||||
updatetestdeps:
|
|
||||||
go get -d -v -t -u -f google.golang.org/grpc/...
|
|
||||||
|
|
||||||
build: deps
|
build: deps
|
||||||
go build google.golang.org/grpc/...
|
go build google.golang.org/grpc/...
|
||||||
|
|
||||||
|
clean:
|
||||||
|
go clean -i google.golang.org/grpc/...
|
||||||
|
|
||||||
|
deps:
|
||||||
|
go get -d -v google.golang.org/grpc/...
|
||||||
|
|
||||||
proto:
|
proto:
|
||||||
@ if ! which protoc > /dev/null; then \
|
@ if ! which protoc > /dev/null; then \
|
||||||
echo "error: protoc not installed" >&2; \
|
echo "error: protoc not installed" >&2; \
|
||||||
@ -25,31 +16,45 @@ proto:
|
|||||||
fi
|
fi
|
||||||
go generate google.golang.org/grpc/...
|
go generate google.golang.org/grpc/...
|
||||||
|
|
||||||
vet:
|
|
||||||
./vet.sh
|
|
||||||
|
|
||||||
test: testdeps
|
test: testdeps
|
||||||
go test -cpu 1,4 -timeout 5m google.golang.org/grpc/...
|
go test -cpu 1,4 -timeout 5m google.golang.org/grpc/...
|
||||||
|
|
||||||
|
testappengine: testappenginedeps
|
||||||
|
goapp test -cpu 1,4 -timeout 5m google.golang.org/grpc/...
|
||||||
|
|
||||||
|
testappenginedeps:
|
||||||
|
goapp get -d -v -t -tags 'appengine appenginevm' google.golang.org/grpc/...
|
||||||
|
|
||||||
|
testdeps:
|
||||||
|
go get -d -v -t google.golang.org/grpc/...
|
||||||
|
|
||||||
testrace: testdeps
|
testrace: testdeps
|
||||||
go test -race -cpu 1,4 -timeout 7m google.golang.org/grpc/...
|
go test -race -cpu 1,4 -timeout 7m google.golang.org/grpc/...
|
||||||
|
|
||||||
testappengine: testgaedeps
|
updatedeps:
|
||||||
goapp test -cpu 1,4 -timeout 5m google.golang.org/grpc/...
|
go get -d -v -u -f google.golang.org/grpc/...
|
||||||
|
|
||||||
clean:
|
updatetestdeps:
|
||||||
go clean -i google.golang.org/grpc/...
|
go get -d -v -t -u -f google.golang.org/grpc/...
|
||||||
|
|
||||||
|
vet: vetdeps
|
||||||
|
./vet.sh
|
||||||
|
|
||||||
|
vetdeps:
|
||||||
|
./vet.sh -install
|
||||||
|
|
||||||
.PHONY: \
|
.PHONY: \
|
||||||
all \
|
all \
|
||||||
deps \
|
|
||||||
updatedeps \
|
|
||||||
testdeps \
|
|
||||||
testgaedeps \
|
|
||||||
updatetestdeps \
|
|
||||||
build \
|
build \
|
||||||
|
clean \
|
||||||
|
deps \
|
||||||
proto \
|
proto \
|
||||||
vet \
|
|
||||||
test \
|
test \
|
||||||
|
testappengine \
|
||||||
|
testappenginedeps \
|
||||||
|
testdeps \
|
||||||
testrace \
|
testrace \
|
||||||
clean
|
updatedeps \
|
||||||
|
updatetestdeps \
|
||||||
|
vet \
|
||||||
|
vetdeps
|
||||||
|
47
vet.sh
47
vet.sh
@ -18,23 +18,22 @@ if git status --porcelain | read; then
|
|||||||
die "Uncommitted or untracked files found; commit changes first"
|
die "Uncommitted or untracked files found; commit changes first"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d "$GOPATH/src" ]]; then
|
if [[ -d "${GOPATH}/src" ]]; then
|
||||||
die "\$GOPATH/src ($GOPATH/src) exists; this script will delete it."
|
die "\${GOPATH}/src (${GOPATH}/src) exists; this script will delete it."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Undo any edits made by this script.
|
# Undo any edits made by this script.
|
||||||
cleanup() {
|
cleanup() {
|
||||||
rm -rf "$GOPATH/src"
|
rm -rf "${GOPATH}/src"
|
||||||
git reset --hard HEAD
|
git reset --hard HEAD
|
||||||
}
|
}
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
PATH="$GOPATH/bin:$GOROOT/bin:$PATH"
|
PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}"
|
||||||
|
|
||||||
if [[ "$1" = "-install" ]]; then
|
if [[ "$1" = "-install" ]]; then
|
||||||
# Check for module support
|
# Check for module support
|
||||||
if go help mod >& /dev/null; then
|
if go help mod >& /dev/null; then
|
||||||
go mod download
|
|
||||||
go install \
|
go install \
|
||||||
github.com/golang/lint/golint \
|
github.com/golang/lint/golint \
|
||||||
golang.org/x/tools/cmd/goimports \
|
golang.org/x/tools/cmd/goimports \
|
||||||
@ -42,10 +41,9 @@ if [[ "$1" = "-install" ]]; then
|
|||||||
github.com/client9/misspell/cmd/misspell \
|
github.com/client9/misspell/cmd/misspell \
|
||||||
github.com/golang/protobuf/protoc-gen-go
|
github.com/golang/protobuf/protoc-gen-go
|
||||||
else
|
else
|
||||||
# Ye olde `go get` incantations.
|
# Ye olde `go get` incantation.
|
||||||
# Note: this gets the latest version of all tools and dependencies (vs. the
|
# Note: this gets the latest version of all tools (vs. the pinned versions
|
||||||
# pinned versions with Go modules).
|
# with Go modules).
|
||||||
go get -d google.golang.org/grpc/...
|
|
||||||
go get -u \
|
go get -u \
|
||||||
github.com/golang/lint/golint \
|
github.com/golang/lint/golint \
|
||||||
golang.org/x/tools/cmd/goimports \
|
golang.org/x/tools/cmd/goimports \
|
||||||
@ -53,8 +51,8 @@ if [[ "$1" = "-install" ]]; then
|
|||||||
github.com/client9/misspell/cmd/misspell \
|
github.com/client9/misspell/cmd/misspell \
|
||||||
github.com/golang/protobuf/protoc-gen-go
|
github.com/golang/protobuf/protoc-gen-go
|
||||||
fi
|
fi
|
||||||
if [[ -z "$VET_SKIP_PROTO" ]]; then
|
if [[ -z "${VET_SKIP_PROTO}" ]]; then
|
||||||
if [[ "$TRAVIS" = "true" ]]; then
|
if [[ "${TRAVIS}" = "true" ]]; then
|
||||||
PROTOBUF_VERSION=3.3.0
|
PROTOBUF_VERSION=3.3.0
|
||||||
PROTOC_FILENAME=protoc-${PROTOBUF_VERSION}-linux-x86_64.zip
|
PROTOC_FILENAME=protoc-${PROTOBUF_VERSION}-linux-x86_64.zip
|
||||||
pushd /home/travis
|
pushd /home/travis
|
||||||
@ -81,26 +79,31 @@ golint ./... 2>&1 | (grep -vE "(_mock|\.pb)\.go:" || true) | tee /dev/stderr | (
|
|||||||
# Rewrite golang.org/x/net/context -> context imports (see grpc/grpc-go#1484).
|
# Rewrite golang.org/x/net/context -> context imports (see grpc/grpc-go#1484).
|
||||||
# TODO: Remove this mangling once "context" is imported directly (grpc/grpc-go#711).
|
# TODO: Remove this mangling once "context" is imported directly (grpc/grpc-go#711).
|
||||||
git ls-files "*.go" | xargs sed -i 's:"golang.org/x/net/context":"context":'
|
git ls-files "*.go" | xargs sed -i 's:"golang.org/x/net/context":"context":'
|
||||||
set +o pipefail
|
set +o pipefail # vet exits with non-zero error if issues are found
|
||||||
# TODO: Stop filtering pb.go files once golang/protobuf#214 is fixed.
|
go tool vet -all . 2>&1 | grep -vE 'clientconn.go:.*cancel (function|var)' | tee /dev/stderr | (! read)
|
||||||
go tool vet -all . 2>&1 | grep -vE '(clientconn|transport\/transport_test).go:.*cancel (function|var)' | grep -vF '.pb.go:' | tee /dev/stderr | (! read)
|
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
git reset --hard HEAD
|
git reset --hard HEAD
|
||||||
|
|
||||||
if [[ -z "$VET_SKIP_PROTO" ]]; then
|
if [[ -z "${VET_SKIP_PROTO}" ]]; then
|
||||||
PATH="/home/travis/bin:$PATH" make proto && \
|
PATH="/home/travis/bin:${PATH}" make proto && \
|
||||||
|
git status --porcelain 2>&1 | (! read) || \
|
||||||
|
(git status; git --no-pager diff; exit 1)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if go help mod >& /dev/null; then
|
||||||
|
go mod tidy && \
|
||||||
git status --porcelain 2>&1 | (! read) || \
|
git status --porcelain 2>&1 | (! read) || \
|
||||||
(git status; git --no-pager diff; exit 1)
|
(git status; git --no-pager diff; exit 1)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
### HACK HACK HACK: Remove once staticcheck works with modules.
|
### HACK HACK HACK: Remove once staticcheck works with modules.
|
||||||
# Make a symlink in $GOPATH/src to its $GOPATH/pkg/mod equivalent for every package we use.
|
# Make a symlink in ${GOPATH}/src to its ${GOPATH}/pkg/mod equivalent for every package we use.
|
||||||
for x in $(find "$GOPATH/pkg/mod" -name '*@*' | grep -v \/mod\/cache\/); do
|
for x in $(find "${GOPATH}/pkg/mod" -name '*@*' | grep -v \/mod\/cache\/); do
|
||||||
pkg="$(echo ${x#"$GOPATH/pkg/mod/"} | cut -f1 -d@)";
|
pkg="$(echo ${x#"${GOPATH}/pkg/mod/"} | cut -f1 -d@)";
|
||||||
# If multiple versions exist, just use the existing one.
|
# If multiple versions exist, just use the existing one.
|
||||||
if [[ -L "$GOPATH/src/$pkg" ]]; then continue; fi
|
if [[ -L "${GOPATH}/src/${pkg}" ]]; then continue; fi
|
||||||
mkdir -p "$(dirname "$GOPATH/src/$pkg")";
|
mkdir -p "$(dirname "${GOPATH}/src/${pkg}")";
|
||||||
ln -s $x "$GOPATH/src/$pkg";
|
ln -s $x "${GOPATH}/src/${pkg}";
|
||||||
done
|
done
|
||||||
### END HACK HACK HACK
|
### END HACK HACK HACK
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user