Skip to content

Commit 86df443

Browse files
committed
make+looprpc: use Docker to compile and format protos
1 parent 67c8120 commit 86df443

File tree

13 files changed

+4196
-2271
lines changed

13 files changed

+4196
-2271
lines changed

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,9 @@ install:
7474
$(GOINSTALL) -tags="${tags}" $(LDFLAGS) $(PKG)/cmd/loopd
7575

7676
rpc:
77-
@$(call print, "Compiling RPC protos.")
78-
cd looprpc; ./gen_protos.sh
77+
@$(call print, "Compiling protos.")
78+
cd ./looprpc; ./gen_protos_docker.sh
79+
80+
rpc-check: rpc
81+
@$(call print, "Verifying protos.")
82+
if test -n "$$(git describe --dirty | grep dirty)"; then echo "Protos not properly formatted or not compiled with correct version!"; git status; git diff; exit 1; fi

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ require (
2121
github.com/stretchr/testify v1.7.0
2222
github.com/urfave/cli v1.20.0
2323
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7
24-
google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c
2524
google.golang.org/grpc v1.29.1
25+
google.golang.org/protobuf v1.23.0
2626
gopkg.in/macaroon-bakery.v2 v2.0.1
2727
gopkg.in/macaroon.v2 v2.1.0
2828
)

looprpc/.clang-format

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
Language: Proto
3+
BasedOnStyle: Google
4+
IndentWidth: 4
5+
AllowShortFunctionsOnASingleLine: None
6+
SpaceBeforeParens: Always
7+
CompactNamespaces: false

looprpc/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM golang:1.15.6-buster
2+
3+
RUN apt-get update && apt-get install -y \
4+
git \
5+
protobuf-compiler='3.6*' \
6+
clang-format='1:7.0*'
7+
8+
# We don't want any default values for these variables to make sure they're
9+
# explicitly provided by parsing the go.mod file. Otherwise we might forget to
10+
# update them here if we bump the versions.
11+
ARG PROTOC_GEN_VERSION
12+
ARG GRPC_GATEWAY_VERSION
13+
14+
RUN cd /tmp \
15+
&& export GO111MODULE=on \
16+
&& go get github.com/golang/protobuf/protoc-gen-go@${PROTOC_GEN_VERSION} \
17+
&& go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@${GRPC_GATEWAY_VERSION} \
18+
&& go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@${GRPC_GATEWAY_VERSION}
19+
20+
WORKDIR /build
21+
22+
CMD ["/bin/bash", "/build/looprpc/gen_protos.sh"]

0 commit comments

Comments
 (0)