Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to PG* v0.4.2 #103

Merged
merged 13 commits into from
Sep 27, 2018
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ bazel-*

/gogofast
/gogofast.exe
/protoc-gen-validate

/tests/harness/cases/go
/tests/harness/cases/gogo
Expand All @@ -18,5 +19,5 @@ bazel-*
/tests/harness/cc/cc-harness
/tests/harness/cc/cc-harness.exe

/tests/kitchensink/go/
/tests/kitchensink/gogo/
/tests/harness/cases/**/*.cc
/tests/harness/cases/**/*.h
4 changes: 3 additions & 1 deletion BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@io_bazel_rules_go//go:def.bzl", "gazelle", "go_binary", "go_library")
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

gazelle(
name = "gazelle",
Expand All @@ -20,5 +21,6 @@ go_library(
deps = [
"//module:go_default_library",
"//vendor/github.com/lyft/protoc-gen-star:go_default_library",
"//vendor/github.com/lyft/protoc-gen-star/lang/go:go_default_library",
],
)
50 changes: 47 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,54 @@
FROM ubuntu:xenial


# apt packages
ENV INSTALL_DEPS \
bazel \
ca-certificates \
git \
make \
software-properties-common \
unzip \
wget
RUN apt-get update \
&& apt-get install -y -q --no-install-recommends curl openjdk-8-jdk \
&& echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list \
&& curl https://bazel.build/bazel-release.pub.gpg | apt-key add - \
&& apt-get update \
&& apt-get install -y -q --no-install-recommends ${INSTALL_DEPS} \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*


# protoc
ENV PROTOC_VER=3.6.1
ENV PROTOC_REL=protoc-"${PROTOC_VER}"-linux-x86_64.zip
RUN wget https://github.com/google/protobuf/releases/download/v"${PROTOC_VER}/${PROTOC_REL}" \
&& unzip ${PROTOC_REL} -d protoc \
&& mv protoc /usr/local \
&& ln -s /usr/local/protoc/bin/protoc /usr/local/bin


# go
ENV GOROOT /usr/local/go
ENV GOPATH /go
ENV PATH "${GOPATH}/bin:${PATH}"
ENV PATH $GOPATH/bin:$GOROOT/bin:$PATH
ENV GORELEASE go1.10.3.linux-amd64.tar.gz
RUN wget -q https://storage.googleapis.com/golang/$GORELEASE \
&& tar -C $(dirname $GOROOT) -xzf $GORELEASE \
&& rm $GORELEASE \
&& mkdir -p $GOPATH/{src,bin,pkg}

COPY ./scripts/build_container.sh /
RUN ./build_container.sh
# protoc-gen-go
ENV PGG_PKG "github.com/golang/protobuf/protoc-gen-go"
ENV PGG_PATH "${GOPATH}/src/${PGG_PKG}"
ENV PGG_VER=v1.2.0
RUN go get -d ${PGG_PKG} \
&& cd ${PGG_PATH} \
&& git checkout ${PGG_VER} \
&& go install \
&& cd - \
&& rm -rf ${PGG_PATH}

WORKDIR ${GOPATH}/src/github.com/lyft/protoc-gen-validate
COPY . .
Expand Down
33 changes: 14 additions & 19 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[[constraint]]
name = "github.com/golang/protobuf"
version = "1.1.0"
version = "1.2.0"

[[constraint]]
name = "github.com/lyft/protoc-gen-star"
version = "0.3.7"
version = "0.4.2"

[[constraint]]
branch = "master"
name = "golang.org/x/net"

[[constraint]]
name = "github.com/gogo/protobuf"
version = "1.0.0"
version = "1.1.1"
82 changes: 30 additions & 52 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,18 @@ bazel:
bazel build //tests/...

.PHONY: gazelle
gazelle:
gazelle: vendor
# runs gazelle against the codebase to generate Bazel BUILD files
bazel run //:gazelle
bazel run //:gazelle -- -go_prefix=github.com/lyft/protoc-gen-validate
buildozer 'replace deps //vendor/github.com/golang/protobuf/proto:go_default_library @com_github_golang_protobuf//proto:go_default_library' '//...:%go_library'
buildozer 'replace deps @com_github_golang_protobuf//ptypes:go_default_library_gen @com_github_golang_protobuf//ptypes:go_default_library' '//...:%go_library'
buildozer 'replace deps @io_bazel_rules_go//proto/wkt:duration_go_proto @com_github_golang_protobuf//ptypes/duration:go_default_library' '//...:%go_library'
buildozer 'replace deps @io_bazel_rules_go//proto/wkt:timestamp_go_proto @com_github_golang_protobuf//ptypes/timestamp:go_default_library' '//...:%go_library'
buildozer 'replace deps //vendor/github.com/gogo/protobuf/proto:go_default_library @com_github_gogo_protobuf//proto:go_default_library' '//...:%go_library'
buildozer 'replace deps //vendor/github.com/gogo/protobuf/types:go_default_library @com_github_gogo_protobuf//types:go_default_library' '//...:%go_library'

vendor:
dep ensure -v -update

.PHONY: lint
lint:
Expand All @@ -48,31 +57,11 @@ lint:
# golint -set_exit_status
go tool vet -all -shadow -shadowstrict *.go

.PHONY: quick
quick:
# runs all tests without the race detector or coverage percentage
go test

.PHONY: tests
tests:
# runs all tests against the package with race detection and coverage percentage
go test -race -cover
# tests validate proto generation
bazel build //validate:go_default_library \
&& diff bazel-out/k8-fastbuild/bin/validate/linux_amd64_stripped/go_default_library%/github.com/lyft/protoc-gen-validate/validate/validate.pb.go validate/validate.pb.go

.PHONY: cover
cover:
# runs all tests against the package, generating a coverage report and opening it in the browser
go test -race -covermode=atomic -coverprofile=cover.out
go tool cover -html cover.out -o cover.html
open cover.html

gogofast:
go build -o $@ vendor/github.com/gogo/protobuf/protoc-gen-gogofast/main.go

.PHONY: harness
harness: tests/harness/go/harness.pb.go tests/harness/gogo/harness.pb.go tests/harness/go/main/go-harness tests/harness/gogo/main/go-harness tests/harness/cc/cc-harness
harness: testcases tests/harness/go/harness.pb.go tests/harness/gogo/harness.pb.go tests/harness/go/main/go-harness tests/harness/gogo/main/go-harness tests/harness/cc/cc-harness
# runs the test harness, validating a series of test cases in all supported languages
go run ./tests/harness/executor/*.go

Expand All @@ -81,26 +70,6 @@ bazel-harness:
# runs the test harness via bazel
bazel run //tests/harness/executor:executor

.PHONY: kitchensink
kitchensink: gogofast
# generates the kitchensink test protos
rm -r tests/kitchensink/go || true
mkdir -p tests/kitchensink/go
rm -r tests/kitchensink/gogo || true
mkdir -p tests/kitchensink/gogo
cd tests/kitchensink && \
protoc \
-I . \
-I ../.. \
--go_out="${GO_IMPORT}:./go" \
--validate_out="lang=go:./go" \
--plugin=protoc-gen-gogofast=$(shell pwd)/gogofast \
--gogofast_out="${GOGO_IMPORT}:./gogo" \
--validate_out="lang=gogo:./gogo" \
`find . -name "*.proto"`
cd tests/kitchensink/go && go build .
cd tests/kitchensink/gogo && go build .

.PHONY: testcases
testcases: gogofast
# generate the test harness case protos
Expand Down Expand Up @@ -134,12 +103,6 @@ testcases: gogofast
--validate_out="lang=gogo:./gogo" \
./*.proto

.PHONY: update-vendor
update-vendor:
# updates the vendored dependencies using the Go Dep tool
dep ensure -update
$(MAKE) gazelle

tests/harness/go/harness.pb.go:
# generates the test harness protos
cd tests/harness && protoc -I . \
Expand All @@ -151,12 +114,10 @@ tests/harness/gogo/harness.pb.go: gogofast
--plugin=protoc-gen-gogofast=$(shell pwd)/gogofast \
--gogofast_out="${GOGO_IMPORT}:./gogo" harness.proto

.PHONY: tests/harness/go/main/go-harness
tests/harness/go/main/go-harness:
# generates the go-specific test harness
go build -o ./tests/harness/go/main/go-harness ./tests/harness/go/main

.PHONY: tests/harness/gogo/main/go-harness
tests/harness/gogo/main/go-harness:
# generates the gogo-specific test harness
go build -o ./tests/harness/gogo/main/go-harness ./tests/harness/gogo/main
Expand All @@ -169,4 +130,21 @@ tests/harness/cc/cc-harness: tests/harness/cc/harness.cc
chmod 0755 $@

.PHONY: ci
ci: lint build tests kitchensink testcases harness bazel-harness
ci: lint build testcases harness bazel-harness

.PHONY: clean
clean:
(which bazel && bazel clean) || true
rm -f \
gogofast \
tests/harness/cc/cc-harness \
tests/harness/go/main/go-harness \
tests/harness/gogo/main/go-harness \
tests/harness/gogo/harness.pb.go \
tests/harness/gogo/harness.pb.go \
tests/harness/go/harness.pb.go
rm -rf \
tests/harness/cases/go \
tests/harness/cases/other_package/go \
tests/harness/cases/gogo \
tests/harness/cases/other_package/gogo \
1 change: 0 additions & 1 deletion gogoproto/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ go_proto_library(
importpath = "github.com/lyft/protoc-gen-validate/gogoproto",
proto = ":gogoproto_proto",
visibility = ["//visibility:public"],
deps = ["@io_bazel_rules_go//proto/wkt:descriptor_go_proto"],
)
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package main

import (
"github.com/lyft/protoc-gen-star"
"github.com/lyft/protoc-gen-star/lang/go"
"github.com/lyft/protoc-gen-validate/module"
)

func main() {
pgs.
Init(pgs.DebugEnv("DEBUG_PGV")).
RegisterModule(module.Validator()).
RegisterPostProcessor(pgs.GoFmt()).
RegisterPostProcessor(pgsgo.GoFmt()).
Render()
}
3 changes: 2 additions & 1 deletion module/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ go_library(
deps = [
"//templates:go_default_library",
"//validate:go_default_library",
"//vendor/github.com/lyft/protoc-gen-star:go_default_library",
"//vendor/github.com/lyft/protoc-gen-star/lang/go:go_default_library",
"@com_github_golang_protobuf//proto:go_default_library",
"@com_github_golang_protobuf//ptypes:go_default_library",
"@com_github_golang_protobuf//ptypes/duration:go_default_library",
"@com_github_golang_protobuf//ptypes/timestamp:go_default_library",
"//vendor/github.com/lyft/protoc-gen-star:go_default_library",
],
)
Loading