Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
171 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
syntax = "proto3"; | ||
|
||
package berty.baz; | ||
|
||
option go_package = "berty.tech/go/internal/baz"; | ||
|
||
message Baz { | ||
bool is_baz = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
syntax = "proto3"; | ||
|
||
package berty.internal.foo; | ||
|
||
import "internal/foo.proto"; | ||
|
||
option go_package = "berty.tech/go/internal/bar"; | ||
|
||
message Bar { | ||
foo.Foo foo = 1; | ||
bool is_bar = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
syntax = "proto3"; | ||
|
||
package berty.internal.foo; | ||
|
||
import "github.com/gogo/protobuf/gogoproto/gogo.proto"; | ||
import "google/protobuf/timestamp.proto"; | ||
|
||
option go_package = "berty.tech/go/internal/foo"; | ||
option (gogoproto.sizer_all) = true; | ||
option (gogoproto.marshaler_all) = true; | ||
option (gogoproto.unmarshaler_all) = true; | ||
|
||
message Metadata { | ||
string id = 1 [(gogoproto.moretags) = "gorm:\"primary_key\"", (gogoproto.customname) = "ID"]; | ||
google.protobuf.Timestamp created_at = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = true]; | ||
google.protobuf.Timestamp updated_at = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = true]; | ||
} | ||
|
||
message Foo { | ||
Metadata metadata = 1 [(gogoproto.nullable) = false, (gogoproto.embed) = true]; | ||
bool is_foo = 2; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,49 @@ | ||
PROTOS_SRC := $(wildcard ../api/*.proto) $(wildcard ../api/internal/*.proto) | ||
PROTOS_GEN := $(patsubst %.proto,%.pb.go,$(PROTOS_SRC)) | ||
|
||
.PHONY: install | ||
install: | ||
install: generate | ||
go install ./cmd/... | ||
|
||
.PHONY: test | ||
test: unittest lint tidy | ||
|
||
.PHONY: unittest | ||
unittest: | ||
unittest: generate | ||
go test -v -cover -coverprofile=coverage.txt -covermode=atomic -race ./... | ||
|
||
.PHONY: lint | ||
lint: | ||
lint: generate | ||
golangci-lint run --verbose ./... | ||
|
||
.PHONY: tidy | ||
tidy: | ||
tidy: generate | ||
go mod tidy | ||
|
||
.PHONY: docker.build | ||
docker.build: | ||
docker.build: generate | ||
docker build -t bertytech/berty . | ||
|
||
.PHONY: generate | ||
generate: gen.sum | ||
gen.sum: $(PROTOS_SRC) Makefile | ||
md5sum -c $@ || ( \ | ||
set -e; \ | ||
go mod vendor; \ | ||
docker run \ | ||
--user=`id -u` \ | ||
--volume="$(PWD)/..:/go/src/berty.tech" \ | ||
--workdir="/go/src/berty.tech/go" \ | ||
--entrypoint="sh" \ | ||
--rm \ | ||
bertytech/protoc:16 \ | ||
-xec 'make generate_local' \ | ||
) | ||
touch $@ | ||
|
||
.PHONY: generate_local | ||
generate_local: | ||
@set -e; for proto in $(PROTOS_SRC); do ( set -xe; \ | ||
protoc -I /protobuf:vendor:../api: --gofast_out="plugins=grpc:$(GOPATH)/src" "$$proto" \ | ||
); done | ||
md5sum $(PROTOS_SRC) | sort -k2 > gen.sum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ce71d433e26b7f98222d8fa7705c5aee ../api/baz.proto | ||
af88d1e57ab838dd3e1883667e8eb536 ../api/internal/bar.proto | ||
943ccf5086a2cc88f02b603d04f5506d ../api/internal/foo.proto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Package gomodhack ensures that `go mod` detect some required dependencies. | ||
// This package should not be imported directly. | ||
package gomodhack | ||
|
||
import ( | ||
_ "github.com/gogo/protobuf/gogoproto" // required by protoc | ||
_ "github.com/gogo/protobuf/types" // required by protoc | ||
_ "github.com/golang/protobuf/proto" // required by protoc | ||
_ "github.com/golang/protobuf/ptypes/timestamp" // required by protoc | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
FROM moul/protoc-gen-gotemplate:latest as pgg | ||
|
||
# build image | ||
FROM golang:1.13-alpine as builder | ||
# install deps | ||
RUN apk --no-cache add make git go rsync libc-dev openssh docker npm | ||
# install compilers | ||
RUN go get -u \ | ||
github.com/gogo/protobuf/gogoproto \ | ||
github.com/gogo/protobuf/jsonpb \ | ||
github.com/gogo/protobuf/proto \ | ||
github.com/gogo/protobuf/protoc-gen-gofast \ | ||
github.com/gogo/protobuf/protoc-gen-gogo \ | ||
github.com/spf13/cobra \ | ||
github.com/vektah/gorunpkg \ | ||
golang.org/x/tools/cmd/goimports \ | ||
moul.io/protoc-gen-gotemplate | ||
RUN go get -d github.com/envoyproxy/protoc-gen-validate \ | ||
&& make -C $GOPATH/src/github.com/envoyproxy/protoc-gen-validate build | ||
|
||
# runtime | ||
FROM golang:1.13-alpine | ||
RUN apk --no-cache add git openssh make protobuf gcc libc-dev nodejs-npm sudo \ | ||
&& mkdir -p /.cache/go-build \ | ||
&& chmod -R 777 /.cache \ | ||
&& mkdir -p /node/ \ | ||
&& cd /node \ | ||
&& npm install -g \ | ||
npm@6.9.0 \ | ||
protobufjs \ | ||
prettier \ | ||
prettier-eslint \ | ||
prettier-eslint-cli \ | ||
pbhbs@0.1.0 \ | ||
&& echo 'syntax = "proto3";' | /usr/bin/pbjs - > /dev/null | ||
COPY --from=pgg /go/bin/* /go/bin/ | ||
COPY --from=builder /go/bin/* /go/bin/ | ||
COPY --from=pgg /protobuf /protobuf | ||
ENV GOPATH=/go \ | ||
PATH=/go/bin:/node/node_modules/.bin:${PATH} \ | ||
GOROOT=/usr/local/go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
IMAGE ?= bertytech/protoc | ||
VERSION ?= 16 | ||
|
||
build: | ||
docker build -t $(IMAGE):$(VERSION) . | ||
|
||
publish: build | ||
docker tag $(IMAGE):$(VERSION) $(IMAGE):latest | ||
docker push $(IMAGE):$(VERSION) | ||
docker push $(IMAGE):latest |