Skip to content

Commit 468f615

Browse files
authored
Moved to buf; Added buf lint; Fixed ping service to match standards; … (#383)
* Moved to buf; Added buf lint; Fixed ping service to match standards; Moved auth to interceptors. Signed-off-by: Bartlomiej Plotka <[email protected]> * Fixed flakiness. Signed-off-by: Bartlomiej Plotka <[email protected]>
1 parent 6672a20 commit 468f615

Some content is hidden

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

41 files changed

+1373
-891
lines changed

.bingo/Variables.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ $(BINGO): $(BINGO_DIR)/bingo.mod
2323
@echo "(re)installing $(GOBIN)/bingo-v0.3.0"
2424
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=bingo.mod -o=$(GOBIN)/bingo-v0.3.0 "github.com/bwplotka/bingo"
2525

26+
BUF := $(GOBIN)/buf-v0.35.1
27+
$(BUF): $(BINGO_DIR)/buf.mod
28+
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
29+
@echo "(re)installing $(GOBIN)/buf-v0.35.1"
30+
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=buf.mod -o=$(GOBIN)/buf-v0.35.1 "github.com/bufbuild/buf/cmd/buf"
31+
2632
FAILLINT := $(GOBIN)/faillint-v1.5.0
2733
$(FAILLINT): $(BINGO_DIR)/faillint.mod
2834
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.

.bingo/buf.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
2+
3+
go 1.15
4+
5+
require github.com/bufbuild/buf v0.35.1 // cmd/buf

.bingo/variables.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ fi
1010

1111
BINGO="${GOBIN}/bingo-v0.3.0"
1212

13+
BUF="${GOBIN}/buf-v0.35.1"
14+
1315
FAILLINT="${GOBIN}/faillint-v1.5.0"
1416

1517
GOIMPORTS="${GOBIN}/goimports-v0.0.0-20200529172331-a64b76657301"

Makefile

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ MODULES ?= $(PROVIDER_MODULES) $(PWD)/
77

88
GOBIN ?= $(firstword $(subst :, ,${GOPATH}))/bin
99

10-
// TODO(bwplotka): Move to buf.
11-
PROTOC_VERSION ?= 3.12.3
12-
PROTOC ?= $(GOBIN)/protoc-$(PROTOC_VERSION)
1310
TMP_GOPATH ?= /tmp/gopath
1411

1512
GO111MODULE ?= on
@@ -43,11 +40,6 @@ fmt: $(GOIMPORTS)
4340
@echo "Running fmt for all modules: $(MODULES)"
4441
@$(GOIMPORTS) -local github.com/grpc-ecosystem/go-grpc-middleware/v2 -w $(MODULES)
4542

46-
.PHONY: proto
47-
proto: ## Generates Go files from Thanos proto files.
48-
proto: $(GOIMPORTS) $(PROTOC) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC) ./grpctesting/testpb/test.proto
49-
@GOIMPORTS_BIN="$(GOIMPORTS)" PROTOC_BIN="$(PROTOC)" PROTOC_GEN_GO_BIN="$(PROTOC_GEN_GO)" PROTOC_GEN_GO_GRPC_BIN="$(PROTOC_GEN_GO_GRPC)" scripts/genproto.sh
50-
5143
.PHONY: test
5244
test:
5345
@echo "Running tests for all modules: $(MODULES)"
@@ -76,7 +68,9 @@ deps:
7668
# --mem-profile-path string Path to memory profile output file
7769
# to debug big allocations during linting.
7870
lint: ## Runs various static analysis tools against our code.
79-
lint: fmt proto
71+
lint: $(BUF) fmt
72+
@echo ">> lint proto files"
73+
@$(BUF) lint
8074
@echo "Running lint for all modules: $(MODULES)"
8175
./scripts/git-tree.sh
8276
for dir in $(MODULES) ; do \
@@ -99,11 +93,21 @@ lint_module: $(FAILLINT) $(GOLANGCI_LINT) $(MISSPELL)
9993
@cd $(DIR) && $(GOLANGCI_LINT) run
10094
@./scripts/git-tree.sh
10195

102-
# TODO(bwplotka): Move to buf.
103-
$(PROTOC):
96+
97+
# For protoc naming matters.
98+
PROTOC_GEN_GO_CURRENT := $(TMP_GOPATH)/protoc-gen-go
99+
PROTOC_GEN_GO_GRPC_CURRENT := $(TMP_GOPATH)/protoc-gen-go-grpc
100+
PROTO_TEST_DIR := testing/testpb/v1
101+
102+
.PHONY: proto
103+
proto: ## Generate testing protobufs
104+
proto: $(BUF) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC) $(PROTO_TEST_DIR)/test.proto
104105
@mkdir -p $(TMP_GOPATH)
105-
@echo ">> fetching protoc@${PROTOC_VERSION}"
106-
@PROTOC_VERSION="$(PROTOC_VERSION)" TMP_GOPATH="$(TMP_GOPATH)" scripts/installprotoc.sh
107-
@echo ">> installing protoc@${PROTOC_VERSION}"
108-
@mv -- "$(TMP_GOPATH)/bin/protoc" "$(GOBIN)/protoc-$(PROTOC_VERSION)"
109-
@echo ">> produced $(GOBIN)/protoc-$(PROTOC_VERSION)"
106+
@cp $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_CURRENT)
107+
@cp $(PROTOC_GEN_GO_GRPC) $(PROTOC_GEN_GO_GRPC_CURRENT)
108+
@echo ">> generating $(PROTO_TEST_DIR)"
109+
@PATH=$(GOBIN):$(TMP_GOPATH) $(BUF) protoc \
110+
-I $(PROTO_TEST_DIR) \
111+
--go_out=$(PROTO_TEST_DIR)/../ \
112+
--go-grpc_out=$(PROTO_TEST_DIR)/../ \
113+
$(PROTO_TEST_DIR)/*.proto

buf.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: v1beta1
2+
build:
3+
roots:
4+
- .
5+
lint:
6+
use:
7+
- DEFAULT

go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
3030
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
3131
github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
3232
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
33+
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2 h1:FlFbCRLd5Jr4iYXZufAvgWN6Ao0JrI5chLINnUXDDr0=
3334
github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU=
3435
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
3536
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=

grpctesting/mutex_readerwriter.go

Lines changed: 0 additions & 31 deletions
This file was deleted.

grpctesting/pingservice.go

Lines changed: 0 additions & 82 deletions
This file was deleted.

grpctesting/testpb/test.manual_extractfields.pb.go

Lines changed: 0 additions & 10 deletions
This file was deleted.

grpctesting/testpb/test.manual_validator.pb.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)