From d1a39b9ac6425fc63c35f4788c0429a56dd7cac0 Mon Sep 17 00:00:00 2001 From: Doug Fawley Date: Thu, 10 Aug 2017 14:09:09 -0700 Subject: [PATCH] Add install-protobuf.sh and make .travis.yml always test proto for testing this PR --- .travis.yml | 4 ++-- Makefile | 2 +- codes/code_string.go | 4 ++-- install-protobuf.sh | 23 +++++++++++++++++++++++ 4 files changed, 28 insertions(+), 5 deletions(-) create mode 100755 install-protobuf.sh diff --git a/.travis.yml b/.travis.yml index 178899f0e5d3..563f296ff391 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,10 +10,10 @@ go_import_path: google.golang.org/grpc before_install: - if [[ $TRAVIS_GO_VERSION = 1.8* ]]; then go get -u github.com/golang/lint/golint honnef.co/go/tools/cmd/staticcheck; fi - go get -u golang.org/x/tools/cmd/goimports github.com/axw/gocov/gocov github.com/mattn/goveralls golang.org/x/tools/cmd/cover - - if [[ "$TRAVIS_EVENT_TYPE" = cron ]]; then PROTOBUF_VERSION=3.3.0 ./install-protobuf.sh && PATH=/home/travis/bin:$PATH protoc --version; fi + - PROTOBUF_VERSION=3.3.0 ./install-protobuf.sh script: - - 'if [[ "$TRAVIS_EVENT_TYPE" = cron ]]; then PATH=/home/travis/bin:$PATH make proto && ! git status --porcelain | tee /dev/stderr | read || (git status; git diff; exit 1); fi' + - 'PATH=/home/travis/bin:$PATH make proto && ! git status --porcelain | tee /dev/stderr | read || (git status; git diff; exit 1)' - 'set -o pipefail && git ls-files "*.go" | xargs grep -L "\(Copyright [0-9]\{4,\} gRPC authors\)\|DO NOT EDIT" 2>&1 | tee /dev/stderr | (! read)' - 'set -o pipefail && gofmt -s -d -l . 2>&1 | tee /dev/stderr | (! read)' - 'set -o pipefail && goimports -l . 2>&1 | tee /dev/stderr | (! read)' diff --git a/Makefile b/Makefile index ca9558c2a245..7b6033623b63 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ proto: echo "error: protoc not installed" >&2; \ exit 1; \ fi - go get -u -v github.com/golang/protobuf/protoc-gen-go + go get -u -v github.com/golang/protobuf/protoc-gen-go golang.org/x/tools/cmd/stringer go generate google.golang.org/grpc/... test: testdeps diff --git a/codes/code_string.go b/codes/code_string.go index e6762d084558..259837060abf 100644 --- a/codes/code_string.go +++ b/codes/code_string.go @@ -1,4 +1,4 @@ -// generated by stringer -type=Code; DO NOT EDIT +// Code generated by "stringer -type=Code"; DO NOT EDIT. package codes @@ -9,7 +9,7 @@ const _Code_name = "OKCanceledUnknownInvalidArgumentDeadlineExceededNotFoundAlre var _Code_index = [...]uint8{0, 2, 10, 17, 32, 48, 56, 69, 85, 102, 120, 127, 137, 150, 158, 169, 177, 192} func (i Code) String() string { - if i+1 >= Code(len(_Code_index)) { + if i >= Code(len(_Code_index)-1) { return fmt.Sprintf("Code(%d)", i) } return _Code_name[_Code_index[i]:_Code_index[i+1]] diff --git a/install-protobuf.sh b/install-protobuf.sh new file mode 100755 index 000000000000..e962f7f613a0 --- /dev/null +++ b/install-protobuf.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -ex + +die() { + echo "$@" >&2 + exit 1 +} + +case "$PROTOBUF_VERSION" in +3*) + basename=protoc-$PROTOBUF_VERSION + ;; +*) + die "unknown protobuf version: $PROTOBUF_VERSION" + ;; +esac + +cd /home/travis + +wget https://github.com/google/protobuf/releases/download/v$PROTOBUF_VERSION/$basename-linux-x86_64.zip +unzip $basename-linux-x86_64.zip +bin/protoc --version