Skip to content

Commit

Permalink
chore(backend): include protoc-gen-go-grpc as tools dependency and ad…
Browse files Browse the repository at this point in the history
…d go mod tidy check in CI (#5112)

* chore(backend): include protoc-gen-go-grpc as tools dependency

* add go mod tidy check in presubmit

* add comment

* fix2

* add better error message

* fix
  • Loading branch information
Bobgy authored Feb 9, 2021
1 parent 7af1fcc commit 9b4e37b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ require (
google.golang.org/api v0.20.0
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013
google.golang.org/grpc v1.34.0
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.0.1 // indirect
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.0.1
google.golang.org/protobuf v1.25.0
gopkg.in/yaml.v2 v2.3.0
k8s.io/api v0.17.9
Expand Down
15 changes: 12 additions & 3 deletions test/presubmit-backend-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Fail the entire script when any command fails.
set -ex

# The current directory is /home/prow/go/src/github.com/kubeflow/pipelines
# TODO(Bobgy): we should use golang image instead, to skip installing go manually.
# 1. install go in /home/prow/go1.13.3
cd /home/prow
mkdir go1.13.3
cd go1.13.3
wget --quiet https://dl.google.com/go/go1.13.3.linux-amd64.tar.gz
tar -xf go1.13.3.linux-amd64.tar.gz
# 2. run test in project directory
GO_CMD=/home/prow/go1.13.3/go/bin/go
cd /home/prow/go/src/github.com/kubeflow/pipelines
/home/prow/go1.13.3/go/bin/go mod vendor
/home/prow/go1.13.3/go/bin/go test -v -cover ./backend/...
# 2. Check go modules are tidy
# Reference: https://github.com/golang/go/issues/27005#issuecomment-564892876
${GO_CMD} mod download
${GO_CMD} mod tidy
git diff --exit-code -- go.mod go.sum || (echo "go modules are not tidy, run 'go mod tidy'." && exit 1)
# 3. run test in project directory
${GO_CMD} test -v -cover ./backend/...
1 change: 1 addition & 0 deletions tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ package tools

import (
_ "github.com/google/addlicense"
_ "google.golang.org/grpc/cmd/protoc-gen-go-grpc"
_ "k8s.io/code-generator"
)

0 comments on commit 9b4e37b

Please sign in to comment.