Skip to content

Commit 3bd820a

Browse files
authored
Upgrade to PG* v0.4.2 (#103)
* PG* Update (sans BAZEL updates) * make protoc-gen-validate buildable * revert BUILD changes for tests/harness * checkpoint * checkpoint * BUILD changes * checkpoint * checkpoint * checkpoint * checkpoint * checkpoint * checkpoint * sort template functions
1 parent 64fcb82 commit 3bd820a

File tree

711 files changed

+30771
-27826
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

711 files changed

+30771
-27826
lines changed

.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ bazel-*
44

55
/gogofast
66
/gogofast.exe
7+
/protoc-gen-validate
78

89
/tests/harness/cases/go
910
/tests/harness/cases/gogo
@@ -18,5 +19,5 @@ bazel-*
1819
/tests/harness/cc/cc-harness
1920
/tests/harness/cc/cc-harness.exe
2021

21-
/tests/kitchensink/go/
22-
/tests/kitchensink/gogo/
22+
/tests/harness/cases/**/*.cc
23+
/tests/harness/cases/**/*.h

BUILD

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
load("@io_bazel_rules_go//go:def.bzl", "gazelle", "go_binary", "go_library")
1+
load("@bazel_gazelle//:def.bzl", "gazelle")
2+
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
23

34
gazelle(
45
name = "gazelle",
@@ -20,5 +21,6 @@ go_library(
2021
deps = [
2122
"//module:go_default_library",
2223
"//vendor/github.com/lyft/protoc-gen-star:go_default_library",
24+
"//vendor/github.com/lyft/protoc-gen-star/lang/go:go_default_library",
2325
],
2426
)

Dockerfile

+47-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,54 @@
11
FROM ubuntu:xenial
22

3+
4+
# apt packages
5+
ENV INSTALL_DEPS \
6+
bazel \
7+
ca-certificates \
8+
git \
9+
make \
10+
software-properties-common \
11+
unzip \
12+
wget
13+
RUN apt-get update \
14+
&& apt-get install -y -q --no-install-recommends curl openjdk-8-jdk \
15+
&& echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list \
16+
&& curl https://bazel.build/bazel-release.pub.gpg | apt-key add - \
17+
&& apt-get update \
18+
&& apt-get install -y -q --no-install-recommends ${INSTALL_DEPS} \
19+
&& apt-get clean \
20+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
21+
22+
23+
# protoc
24+
ENV PROTOC_VER=3.6.1
25+
ENV PROTOC_REL=protoc-"${PROTOC_VER}"-linux-x86_64.zip
26+
RUN wget https://github.com/google/protobuf/releases/download/v"${PROTOC_VER}/${PROTOC_REL}" \
27+
&& unzip ${PROTOC_REL} -d protoc \
28+
&& mv protoc /usr/local \
29+
&& ln -s /usr/local/protoc/bin/protoc /usr/local/bin
30+
31+
32+
# go
33+
ENV GOROOT /usr/local/go
334
ENV GOPATH /go
4-
ENV PATH "${GOPATH}/bin:${PATH}"
35+
ENV PATH $GOPATH/bin:$GOROOT/bin:$PATH
36+
ENV GORELEASE go1.10.3.linux-amd64.tar.gz
37+
RUN wget -q https://storage.googleapis.com/golang/$GORELEASE \
38+
&& tar -C $(dirname $GOROOT) -xzf $GORELEASE \
39+
&& rm $GORELEASE \
40+
&& mkdir -p $GOPATH/{src,bin,pkg}
541

6-
COPY ./scripts/build_container.sh /
7-
RUN ./build_container.sh
42+
# protoc-gen-go
43+
ENV PGG_PKG "github.com/golang/protobuf/protoc-gen-go"
44+
ENV PGG_PATH "${GOPATH}/src/${PGG_PKG}"
45+
ENV PGG_VER=v1.2.0
46+
RUN go get -d ${PGG_PKG} \
47+
&& cd ${PGG_PATH} \
48+
&& git checkout ${PGG_VER} \
49+
&& go install \
50+
&& cd - \
51+
&& rm -rf ${PGG_PATH}
852

953
WORKDIR ${GOPATH}/src/github.com/lyft/protoc-gen-validate
1054
COPY . .

Gopkg.lock

+14-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
[[constraint]]
22
name = "github.com/golang/protobuf"
3-
version = "1.1.0"
3+
version = "1.2.0"
44

55
[[constraint]]
66
name = "github.com/lyft/protoc-gen-star"
7-
version = "0.3.7"
7+
version = "0.4.2"
88

99
[[constraint]]
1010
branch = "master"
1111
name = "golang.org/x/net"
1212

1313
[[constraint]]
1414
name = "github.com/gogo/protobuf"
15-
version = "1.0.0"
15+
version = "1.1.1"

Makefile

+30-52
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,18 @@ bazel:
3636
bazel build //tests/...
3737

3838
.PHONY: gazelle
39-
gazelle:
39+
gazelle: vendor
4040
# runs gazelle against the codebase to generate Bazel BUILD files
41-
bazel run //:gazelle
41+
bazel run //:gazelle -- -go_prefix=github.com/lyft/protoc-gen-validate
42+
buildozer 'replace deps //vendor/github.com/golang/protobuf/proto:go_default_library @com_github_golang_protobuf//proto:go_default_library' '//...:%go_library'
43+
buildozer 'replace deps @com_github_golang_protobuf//ptypes:go_default_library_gen @com_github_golang_protobuf//ptypes:go_default_library' '//...:%go_library'
44+
buildozer 'replace deps @io_bazel_rules_go//proto/wkt:duration_go_proto @com_github_golang_protobuf//ptypes/duration:go_default_library' '//...:%go_library'
45+
buildozer 'replace deps @io_bazel_rules_go//proto/wkt:timestamp_go_proto @com_github_golang_protobuf//ptypes/timestamp:go_default_library' '//...:%go_library'
46+
buildozer 'replace deps //vendor/github.com/gogo/protobuf/proto:go_default_library @com_github_gogo_protobuf//proto:go_default_library' '//...:%go_library'
47+
buildozer 'replace deps //vendor/github.com/gogo/protobuf/types:go_default_library @com_github_gogo_protobuf//types:go_default_library' '//...:%go_library'
48+
49+
vendor:
50+
dep ensure -v -update
4251

4352
.PHONY: lint
4453
lint:
@@ -48,31 +57,11 @@ lint:
4857
# golint -set_exit_status
4958
go tool vet -all -shadow -shadowstrict *.go
5059

51-
.PHONY: quick
52-
quick:
53-
# runs all tests without the race detector or coverage percentage
54-
go test
55-
56-
.PHONY: tests
57-
tests:
58-
# runs all tests against the package with race detection and coverage percentage
59-
go test -race -cover
60-
# tests validate proto generation
61-
bazel build //validate:go_default_library \
62-
&& 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
63-
64-
.PHONY: cover
65-
cover:
66-
# runs all tests against the package, generating a coverage report and opening it in the browser
67-
go test -race -covermode=atomic -coverprofile=cover.out
68-
go tool cover -html cover.out -o cover.html
69-
open cover.html
70-
7160
gogofast:
7261
go build -o $@ vendor/github.com/gogo/protobuf/protoc-gen-gogofast/main.go
7362

7463
.PHONY: harness
75-
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
64+
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
7665
# runs the test harness, validating a series of test cases in all supported languages
7766
go run ./tests/harness/executor/*.go
7867

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

84-
.PHONY: kitchensink
85-
kitchensink: gogofast
86-
# generates the kitchensink test protos
87-
rm -r tests/kitchensink/go || true
88-
mkdir -p tests/kitchensink/go
89-
rm -r tests/kitchensink/gogo || true
90-
mkdir -p tests/kitchensink/gogo
91-
cd tests/kitchensink && \
92-
protoc \
93-
-I . \
94-
-I ../.. \
95-
--go_out="${GO_IMPORT}:./go" \
96-
--validate_out="lang=go:./go" \
97-
--plugin=protoc-gen-gogofast=$(shell pwd)/gogofast \
98-
--gogofast_out="${GOGO_IMPORT}:./gogo" \
99-
--validate_out="lang=gogo:./gogo" \
100-
`find . -name "*.proto"`
101-
cd tests/kitchensink/go && go build .
102-
cd tests/kitchensink/gogo && go build .
103-
10473
.PHONY: testcases
10574
testcases: gogofast
10675
# generate the test harness case protos
@@ -134,12 +103,6 @@ testcases: gogofast
134103
--validate_out="lang=gogo:./gogo" \
135104
./*.proto
136105

137-
.PHONY: update-vendor
138-
update-vendor:
139-
# updates the vendored dependencies using the Go Dep tool
140-
dep ensure -update
141-
$(MAKE) gazelle
142-
143106
tests/harness/go/harness.pb.go:
144107
# generates the test harness protos
145108
cd tests/harness && protoc -I . \
@@ -151,12 +114,10 @@ tests/harness/gogo/harness.pb.go: gogofast
151114
--plugin=protoc-gen-gogofast=$(shell pwd)/gogofast \
152115
--gogofast_out="${GOGO_IMPORT}:./gogo" harness.proto
153116

154-
.PHONY: tests/harness/go/main/go-harness
155117
tests/harness/go/main/go-harness:
156118
# generates the go-specific test harness
157119
go build -o ./tests/harness/go/main/go-harness ./tests/harness/go/main
158120

159-
.PHONY: tests/harness/gogo/main/go-harness
160121
tests/harness/gogo/main/go-harness:
161122
# generates the gogo-specific test harness
162123
go build -o ./tests/harness/gogo/main/go-harness ./tests/harness/gogo/main
@@ -169,4 +130,21 @@ tests/harness/cc/cc-harness: tests/harness/cc/harness.cc
169130
chmod 0755 $@
170131

171132
.PHONY: ci
172-
ci: lint build tests kitchensink testcases harness bazel-harness
133+
ci: lint build testcases harness bazel-harness
134+
135+
.PHONY: clean
136+
clean:
137+
(which bazel && bazel clean) || true
138+
rm -f \
139+
gogofast \
140+
tests/harness/cc/cc-harness \
141+
tests/harness/go/main/go-harness \
142+
tests/harness/gogo/main/go-harness \
143+
tests/harness/gogo/harness.pb.go \
144+
tests/harness/gogo/harness.pb.go \
145+
tests/harness/go/harness.pb.go
146+
rm -rf \
147+
tests/harness/cases/go \
148+
tests/harness/cases/other_package/go \
149+
tests/harness/cases/gogo \
150+
tests/harness/cases/other_package/gogo \

gogoproto/BUILD.bazel

-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@ go_proto_library(
2020
importpath = "github.com/lyft/protoc-gen-validate/gogoproto",
2121
proto = ":gogoproto_proto",
2222
visibility = ["//visibility:public"],
23-
deps = ["@io_bazel_rules_go//proto/wkt:descriptor_go_proto"],
2423
)

main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ package main
22

33
import (
44
"github.com/lyft/protoc-gen-star"
5+
"github.com/lyft/protoc-gen-star/lang/go"
56
"github.com/lyft/protoc-gen-validate/module"
67
)
78

89
func main() {
910
pgs.
1011
Init(pgs.DebugEnv("DEBUG_PGV")).
1112
RegisterModule(module.Validator()).
12-
RegisterPostProcessor(pgs.GoFmt()).
13+
RegisterPostProcessor(pgsgo.GoFmt()).
1314
Render()
1415
}

module/BUILD

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ go_library(
1111
deps = [
1212
"//templates:go_default_library",
1313
"//validate:go_default_library",
14+
"//vendor/github.com/lyft/protoc-gen-star:go_default_library",
15+
"//vendor/github.com/lyft/protoc-gen-star/lang/go:go_default_library",
1416
"@com_github_golang_protobuf//proto:go_default_library",
1517
"@com_github_golang_protobuf//ptypes:go_default_library",
1618
"@com_github_golang_protobuf//ptypes/duration:go_default_library",
1719
"@com_github_golang_protobuf//ptypes/timestamp:go_default_library",
18-
"//vendor/github.com/lyft/protoc-gen-star:go_default_library",
1920
],
2021
)

0 commit comments

Comments
 (0)