Skip to content

Commit

Permalink
Moved to buf; Added buf lint; Fixed ping service to match standards; …
Browse files Browse the repository at this point in the history
…Moved auth to interceptors.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
  • Loading branch information
bwplotka committed Jan 22, 2021
1 parent c1f1e53 commit c03359b
Show file tree
Hide file tree
Showing 41 changed files with 1,343 additions and 888 deletions.
6 changes: 6 additions & 0 deletions .bingo/Variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ $(BINGO): $(BINGO_DIR)/bingo.mod
@echo "(re)installing $(GOBIN)/bingo-v0.3.0"
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=bingo.mod -o=$(GOBIN)/bingo-v0.3.0 "github.com/bwplotka/bingo"

BUF := $(GOBIN)/buf-v0.35.1
$(BUF): $(BINGO_DIR)/buf.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/buf-v0.35.1"
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=buf.mod -o=$(GOBIN)/buf-v0.35.1 "github.com/bufbuild/buf/cmd/buf"

FAILLINT := $(GOBIN)/faillint-v1.5.0
$(FAILLINT): $(BINGO_DIR)/faillint.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
Expand Down
5 changes: 5 additions & 0 deletions .bingo/buf.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.15

require github.com/bufbuild/buf v0.35.1 // cmd/buf
2 changes: 2 additions & 0 deletions .bingo/variables.env
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ fi

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

BUF="${GOBIN}/buf-v0.35.1"

FAILLINT="${GOBIN}/faillint-v1.5.0"

GOIMPORTS="${GOBIN}/goimports-v0.0.0-20200529172331-a64b76657301"
Expand Down
36 changes: 20 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ MODULES ?= $(PROVIDER_MODULES) $(PWD)/

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

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

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

.PHONY: proto
proto: ## Generates Go files from Thanos proto files.
proto: $(GOIMPORTS) $(PROTOC) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC) ./grpctesting/testpb/test.proto
@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

.PHONY: test
test:
@echo "Running tests for all modules: $(MODULES)"
Expand Down Expand Up @@ -76,7 +68,9 @@ deps:
# --mem-profile-path string Path to memory profile output file
# to debug big allocations during linting.
lint: ## Runs various static analysis tools against our code.
lint: fmt proto
lint: $(BUF) fmt
@echo ">> lint proto files"
@$(BUF) lint
@echo "Running lint for all modules: $(MODULES)"
./scripts/git-tree.sh
for dir in $(MODULES) ; do \
Expand All @@ -99,11 +93,21 @@ lint_module: $(FAILLINT) $(GOLANGCI_LINT) $(MISSPELL)
@cd $(DIR) && $(GOLANGCI_LINT) run
@./scripts/git-tree.sh

# TODO(bwplotka): Move to buf.
$(PROTOC):

# For protoc naming matters.
PROTOC_GEN_GO_CURRENT := $(TMP_GOPATH)/protoc-gen-go
PROTOC_GEN_GO_GRPC_CURRENT := $(TMP_GOPATH)/protoc-gen-go-grpc
PROTO_TEST_DIR := testing/testpb/v1

.PHONY: proto
proto: ## Generate testing protobufs
proto: $(BUF) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC) $(PROTO_TEST_DIR)/test.proto
@mkdir -p $(TMP_GOPATH)
@echo ">> fetching protoc@${PROTOC_VERSION}"
@PROTOC_VERSION="$(PROTOC_VERSION)" TMP_GOPATH="$(TMP_GOPATH)" scripts/installprotoc.sh
@echo ">> installing protoc@${PROTOC_VERSION}"
@mv -- "$(TMP_GOPATH)/bin/protoc" "$(GOBIN)/protoc-$(PROTOC_VERSION)"
@echo ">> produced $(GOBIN)/protoc-$(PROTOC_VERSION)"
@cp $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_CURRENT)
@cp $(PROTOC_GEN_GO_GRPC) $(PROTOC_GEN_GO_GRPC_CURRENT)
@echo ">> generating $(PROTO_TEST_DIR)"
@PATH=$(GOBIN):$(TMP_GOPATH) $(BUF) protoc \
-I $(PROTO_TEST_DIR) \
--go_out=$(PROTO_TEST_DIR)/../ \
--go-grpc_out=$(PROTO_TEST_DIR)/../ \
$(PROTO_TEST_DIR)/*.proto
7 changes: 7 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: v1beta1
build:
roots:
- .
lint:
use:
- DEFAULT
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2 h1:FlFbCRLd5Jr4iYXZufAvgWN6Ao0JrI5chLINnUXDDr0=
github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down
31 changes: 0 additions & 31 deletions grpctesting/mutex_readerwriter.go

This file was deleted.

82 changes: 0 additions & 82 deletions grpctesting/pingservice.go

This file was deleted.

10 changes: 0 additions & 10 deletions grpctesting/testpb/test.manual_extractfields.pb.go

This file was deleted.

12 changes: 0 additions & 12 deletions grpctesting/testpb/test.manual_validator.pb.go

This file was deleted.

Loading

0 comments on commit c03359b

Please sign in to comment.