Add mocks for probuf generation

This commit is contained in:
Chris Chapman 2022-09-29 21:17:30 -07:00
parent c4a73a2f60
commit 2c6ef41893
No known key found for this signature in database
GPG Key ID: CE72AB12033D3DEB
2 changed files with 22 additions and 10 deletions

View File

@ -14,6 +14,8 @@ PROTOC_GEN_GO_GRPC_VERSION="v1.2.0"
MOG_VERSION='v0.3.0' MOG_VERSION='v0.3.0'
PROTOC_GO_INJECT_TAG_VERSION='v1.3.0' PROTOC_GO_INJECT_TAG_VERSION='v1.3.0'
MOCKED_PB_DIRS= pbdns
GOTAGS ?= GOTAGS ?=
GOPATH=$(shell go env GOPATH) GOPATH=$(shell go env GOPATH)
GOARCH?=$(shell go env GOARCH) GOARCH?=$(shell go env GOARCH)
@ -401,9 +403,20 @@ else
endif endif
.PHONY: proto .PHONY: proto
proto: proto-tools proto: proto-tools proto-gen proto-mocks
.PHONY: proto-gen
proto-gen: proto-tools
@$(SHELL) $(CURDIR)/build-support/scripts/protobuf.sh @$(SHELL) $(CURDIR)/build-support/scripts/protobuf.sh
.PHONY: proto-mocks
proto-mocks:
for dir in $(MOCKED_PB_DIRS) ; do \
cd proto-public && \
rm -f $$dir/mock*.go && \
mockery --dir $$dir --inpackage --all --recursive --log-level trace ; \
done
.PHONY: proto-format .PHONY: proto-format
proto-format: proto-tools proto-format: proto-tools
@buf format -w @buf format -w

View File

@ -60,7 +60,9 @@ function proto_tools_install {
local buf_version local buf_version
local mog_version local mog_version
local protoc_go_inject_tag_version local protoc_go_inject_tag_version
local mockery_version
mockery_version="$(make --no-print-directory print-MOCKERY_VERSION)"
protoc_gen_go_version="$(grep github.com/golang/protobuf go.mod | awk '{print $2}')" protoc_gen_go_version="$(grep github.com/golang/protobuf go.mod | awk '{print $2}')"
protoc_gen_go_grpc_version="$(make --no-print-directory print-PROTOC_GEN_GO_GRPC_VERSION)" protoc_gen_go_grpc_version="$(make --no-print-directory print-PROTOC_GEN_GO_GRPC_VERSION)"
mog_version="$(make --no-print-directory print-MOG_VERSION)" mog_version="$(make --no-print-directory print-MOG_VERSION)"
@ -71,6 +73,12 @@ function proto_tools_install {
# echo "mog: ${mog_version}" # echo "mog: ${mog_version}"
# echo "tag: ${protoc_go_inject_tag_version}" # echo "tag: ${protoc_go_inject_tag_version}"
install_versioned_tool \
'mockery' \
'github.com/vektra/mockery/v2' \
"${mockery_version}" \
'github.com/vektra/mockery/v2'
install_versioned_tool \ install_versioned_tool \
'buf' \ 'buf' \
'github.com/bufbuild/buf' \ 'github.com/bufbuild/buf' \
@ -128,15 +136,6 @@ function lint_install {
} }
function tools_install { function tools_install {
local mockery_version
mockery_version="$(make --no-print-directory print-MOCKERY_VERSION)"
install_versioned_tool \
'mockery' \
'github.com/vektra/mockery/v2' \
"${mockery_version}" \
'github.com/vektra/mockery/v2'
lint_install lint_install
proto_tools_install proto_tools_install