mirror of https://github.com/grpc/grpc-go.git
				
				
				
			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:
		
							parent
							
								
									911d69081b
								
							
						
					
					
						commit
						ba4eb68a02
					
				
							
								
								
									
										23
									
								
								.travis.yml
								
								
								
								
							
							
						
						
									
										23
									
								
								.travis.yml
								
								
								
								
							| 
						 | 
				
			
			@ -3,7 +3,9 @@ language: go
 | 
			
		|||
matrix:
 | 
			
		||||
  include:
 | 
			
		||||
  - 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
 | 
			
		||||
    env: RUN386=1
 | 
			
		||||
  - go: 1.11.x
 | 
			
		||||
| 
						 | 
				
			
			@ -18,18 +20,19 @@ matrix:
 | 
			
		|||
go_import_path: google.golang.org/grpc
 | 
			
		||||
 | 
			
		||||
before_install:
 | 
			
		||||
  - if [[ "$GO111MODULE" = "on" ]]; then mkdir "$HOME/go"; export GOPATH="$HOME/go"; 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" ]]; then VET_SKIP_PROTO=1; fi
 | 
			
		||||
  - if [[ "${GO111MODULE}" = "on" ]]; then mkdir "${HOME}/go"; export GOPATH="${HOME}/go"; 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" ]]; then VET_SKIP_PROTO=1; fi
 | 
			
		||||
 | 
			
		||||
install:
 | 
			
		||||
  - if [[ "$GAE" = 1 ]]; then source ./install_gae.sh; fi
 | 
			
		||||
  - if [[ "$VET" = 1 ]]; then ./vet.sh -install; fi
 | 
			
		||||
  - if [[ "${GO111MODULE}" = "on" ]]; then go mod download; else make testdeps; fi
 | 
			
		||||
  - if [[ "${GAE}" = 1 ]]; then source ./install_gae.sh; make testappenginedeps; fi
 | 
			
		||||
  - if [[ "${VET}" = 1 ]]; then ./vet.sh -install; fi
 | 
			
		||||
 | 
			
		||||
script:
 | 
			
		||||
  - 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
 | 
			
		||||
  - if [[ "$RACE" = 1 ]]; then make testrace; fi
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										65
									
								
								Makefile
								
								
								
								
							
							
						
						
									
										65
									
								
								Makefile
								
								
								
								
							| 
						 | 
				
			
			@ -1,23 +1,14 @@
 | 
			
		|||
all: vet test testrace
 | 
			
		||||
 | 
			
		||||
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/...
 | 
			
		||||
all: vet test testrace testappengine
 | 
			
		||||
 | 
			
		||||
build: deps
 | 
			
		||||
	go build google.golang.org/grpc/...
 | 
			
		||||
 | 
			
		||||
clean:
 | 
			
		||||
	go clean -i google.golang.org/grpc/...
 | 
			
		||||
 | 
			
		||||
deps:
 | 
			
		||||
	go get -d -v google.golang.org/grpc/...
 | 
			
		||||
 | 
			
		||||
proto:
 | 
			
		||||
	@ if ! which protoc > /dev/null; then \
 | 
			
		||||
		echo "error: protoc not installed" >&2; \
 | 
			
		||||
| 
						 | 
				
			
			@ -25,31 +16,45 @@ proto:
 | 
			
		|||
	fi
 | 
			
		||||
	go generate google.golang.org/grpc/...
 | 
			
		||||
 | 
			
		||||
vet:
 | 
			
		||||
	./vet.sh
 | 
			
		||||
 | 
			
		||||
test: testdeps
 | 
			
		||||
	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
 | 
			
		||||
	go test -race -cpu 1,4 -timeout 7m google.golang.org/grpc/...
 | 
			
		||||
 | 
			
		||||
testappengine: testgaedeps
 | 
			
		||||
	goapp test -cpu 1,4 -timeout 5m google.golang.org/grpc/...
 | 
			
		||||
updatedeps:
 | 
			
		||||
	go get -d -v -u -f google.golang.org/grpc/...
 | 
			
		||||
 | 
			
		||||
clean:
 | 
			
		||||
	go clean -i google.golang.org/grpc/...
 | 
			
		||||
updatetestdeps:
 | 
			
		||||
	go get -d -v -t -u -f google.golang.org/grpc/...
 | 
			
		||||
 | 
			
		||||
vet: vetdeps
 | 
			
		||||
	./vet.sh
 | 
			
		||||
 | 
			
		||||
vetdeps:
 | 
			
		||||
	./vet.sh -install
 | 
			
		||||
 | 
			
		||||
.PHONY: \
 | 
			
		||||
	all \
 | 
			
		||||
	deps \
 | 
			
		||||
	updatedeps \
 | 
			
		||||
	testdeps \
 | 
			
		||||
	testgaedeps \
 | 
			
		||||
	updatetestdeps \
 | 
			
		||||
	build \
 | 
			
		||||
	clean \
 | 
			
		||||
	deps \
 | 
			
		||||
	proto \
 | 
			
		||||
	vet \
 | 
			
		||||
	test \
 | 
			
		||||
	testappengine \
 | 
			
		||||
	testappenginedeps \
 | 
			
		||||
	testdeps \
 | 
			
		||||
	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"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [[ -d "$GOPATH/src" ]]; then
 | 
			
		||||
  die "\$GOPATH/src ($GOPATH/src) exists; this script will delete it."
 | 
			
		||||
if [[ -d "${GOPATH}/src" ]]; then
 | 
			
		||||
  die "\${GOPATH}/src (${GOPATH}/src) exists; this script will delete it."
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Undo any edits made by this script.
 | 
			
		||||
cleanup() {
 | 
			
		||||
  rm -rf "$GOPATH/src"
 | 
			
		||||
  rm -rf "${GOPATH}/src"
 | 
			
		||||
  git reset --hard HEAD
 | 
			
		||||
}
 | 
			
		||||
trap cleanup EXIT
 | 
			
		||||
 | 
			
		||||
PATH="$GOPATH/bin:$GOROOT/bin:$PATH"
 | 
			
		||||
PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}"
 | 
			
		||||
 | 
			
		||||
if [[ "$1" = "-install" ]]; then
 | 
			
		||||
  # Check for module support
 | 
			
		||||
  if go help mod >& /dev/null; then
 | 
			
		||||
    go mod download
 | 
			
		||||
    go install \
 | 
			
		||||
      github.com/golang/lint/golint \
 | 
			
		||||
      golang.org/x/tools/cmd/goimports \
 | 
			
		||||
| 
						 | 
				
			
			@ -42,10 +41,9 @@ if [[ "$1" = "-install" ]]; then
 | 
			
		|||
      github.com/client9/misspell/cmd/misspell \
 | 
			
		||||
      github.com/golang/protobuf/protoc-gen-go
 | 
			
		||||
  else
 | 
			
		||||
    # Ye olde `go get` incantations.
 | 
			
		||||
    # Note: this gets the latest version of all tools and dependencies (vs. the
 | 
			
		||||
    # pinned versions with Go modules).
 | 
			
		||||
    go get -d google.golang.org/grpc/...
 | 
			
		||||
    # Ye olde `go get` incantation.
 | 
			
		||||
    # Note: this gets the latest version of all tools (vs. the pinned versions
 | 
			
		||||
    # with Go modules).
 | 
			
		||||
    go get -u \
 | 
			
		||||
      github.com/golang/lint/golint \
 | 
			
		||||
      golang.org/x/tools/cmd/goimports \
 | 
			
		||||
| 
						 | 
				
			
			@ -53,8 +51,8 @@ if [[ "$1" = "-install" ]]; then
 | 
			
		|||
      github.com/client9/misspell/cmd/misspell \
 | 
			
		||||
      github.com/golang/protobuf/protoc-gen-go
 | 
			
		||||
  fi
 | 
			
		||||
  if [[ -z "$VET_SKIP_PROTO" ]]; then
 | 
			
		||||
    if [[ "$TRAVIS" = "true" ]]; then
 | 
			
		||||
  if [[ -z "${VET_SKIP_PROTO}" ]]; then
 | 
			
		||||
    if [[ "${TRAVIS}" = "true" ]]; then
 | 
			
		||||
      PROTOBUF_VERSION=3.3.0
 | 
			
		||||
      PROTOC_FILENAME=protoc-${PROTOBUF_VERSION}-linux-x86_64.zip
 | 
			
		||||
      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).
 | 
			
		||||
# 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":'
 | 
			
		||||
set +o pipefail
 | 
			
		||||
# TODO: Stop filtering pb.go files once golang/protobuf#214 is fixed.
 | 
			
		||||
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 # vet exits with non-zero error if issues are found
 | 
			
		||||
go tool vet -all . 2>&1 | grep -vE 'clientconn.go:.*cancel (function|var)' | tee /dev/stderr | (! read)
 | 
			
		||||
set -o pipefail
 | 
			
		||||
git reset --hard HEAD
 | 
			
		||||
 | 
			
		||||
if [[ -z "$VET_SKIP_PROTO" ]]; then
 | 
			
		||||
  PATH="/home/travis/bin:$PATH" make proto && \
 | 
			
		||||
if [[ -z "${VET_SKIP_PROTO}" ]]; then
 | 
			
		||||
  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; git --no-pager diff; exit 1)
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
### 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.
 | 
			
		||||
for x in $(find "$GOPATH/pkg/mod" -name '*@*' | grep -v \/mod\/cache\/); do
 | 
			
		||||
  pkg="$(echo ${x#"$GOPATH/pkg/mod/"} | cut -f1 -d@)";
 | 
			
		||||
# 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
 | 
			
		||||
  pkg="$(echo ${x#"${GOPATH}/pkg/mod/"} | cut -f1 -d@)";
 | 
			
		||||
  # If multiple versions exist, just use the existing one.
 | 
			
		||||
  if [[ -L "$GOPATH/src/$pkg" ]]; then continue; fi
 | 
			
		||||
  mkdir -p "$(dirname "$GOPATH/src/$pkg")";
 | 
			
		||||
  ln -s $x "$GOPATH/src/$pkg";
 | 
			
		||||
  if [[ -L "${GOPATH}/src/${pkg}" ]]; then continue; fi
 | 
			
		||||
  mkdir -p "$(dirname "${GOPATH}/src/${pkg}")";
 | 
			
		||||
  ln -s $x "${GOPATH}/src/${pkg}";
 | 
			
		||||
done
 | 
			
		||||
### END HACK HACK HACK
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue