From 90504d44a372f048aaa3f62f4fc2c10f44188874 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Wed, 8 Nov 2023 15:43:54 +0300 Subject: [PATCH 1/2] [#792] makefile: Fix protoc and staticcheck versions Signed-off-by: Dmitrii Stepanov --- .golangci.yml | 2 +- Makefile | 61 +++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index ef99fc152..5c7e9d918 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -39,7 +39,7 @@ linters-settings: alias: objectSDK custom: truecloudlab-linters: - path: bin/external_linters.so + path: bin/linters/external_linters.so original-url: git.frostfs.info/TrueCloudLab/linters.git settings: noliteral: diff --git a/Makefile b/Makefile index 14e32e40f..3fcb5027c 100755 --- a/Makefile +++ b/Makefile @@ -10,6 +10,14 @@ HUB_TAG ?= "$(shell echo ${VERSION} | sed 's/^v//')" GO_VERSION ?= 1.21 LINT_VERSION ?= 1.54.0 TRUECLOUDLAB_LINT_VERSION ?= 0.0.2 +PROTOC_VERSION ?= 25.0 +PROTOC_GEN_GO_VERSION ?= $(shell go list -f '{{.Version}}' -m google.golang.org/protobuf) +PROTOGEN_FROSTFS_VERSION ?= $(shell go list -f '{{.Version}}' -m git.frostfs.info/TrueCloudLab/frostfs-api-go/v2) +PROTOC_OS_VERSION=osx-x86_64 +ifeq ($(shell uname), Linux) + PROTOC_OS_VERSION=linux-x86_64 +endif +STATICCHECK_VERSION ?= 2023.1.6 ARCH = amd64 BIN = bin @@ -26,9 +34,15 @@ PKG_VERSION ?= $(shell echo $(VERSION) | sed "s/^v//" | \ sed -E "s/(.*)-(g[a-fA-F0-9]{6,8})(.*)/\1\3~\2/" | \ sed "s/-/~/")-${OS_RELEASE} -OUTPUT_LINT_DIR ?= $(shell pwd)/bin +OUTPUT_LINT_DIR ?= $(abspath $(BIN))/linters LINT_DIR = $(OUTPUT_LINT_DIR)/golangci-lint-$(LINT_VERSION)-v$(TRUECLOUDLAB_LINT_VERSION) TMP_DIR := .cache +PROTOBUF_DIR ?= $(abspath $(BIN))/protobuf +PROTOC_DIR ?= $(PROTOBUF_DIR)/protoc-v$(PROTOC_VERSION) +PROTOC_GEN_GO_DIR ?= $(PROTOBUF_DIR)/protoc-gen-go-$(PROTOC_GEN_GO_VERSION) +PROTOGEN_FROSTFS_DIR ?= $(PROTOBUF_DIR)/protogen-$(PROTOGEN_FROSTFS_VERSION) +STATICCHECK_DIR ?= $(abspath $(BIN))/staticcheck +STATICCHECK_VERSION_DIR ?= $(STATICCHECK_DIR)/$(STATICCHECK_VERSION) .PHONY: help all images dep clean fmts fumpt imports test lint docker/lint prepare-release debpackage pre-commit unpre-commit @@ -78,22 +92,32 @@ export-metrics: dep # Regenerate proto files: protoc: - @GOPRIVATE=github.com/TrueCloudLab go mod vendor - # Install specific version for protobuf lib - @go list -f '{{.Path}}/...@{{.Version}}' -m github.com/golang/protobuf | xargs go install -v - @GOBIN=$(abspath $(BIN)) go install -mod=mod -v git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/protogen - # Protoc generate - @for f in `find . -type f -name '*.proto' -not -path './vendor/*'`; do \ + @if [ ! -d "$(PROTOC_DIR)" ] || [ ! -d "$(PROTOC_GEN_GO_DIR)" ] || [ ! -d "$(PROTOGEN_FROSTFS_DIR)" ]; then \ + make protoc-install; \ + fi + @for f in `find . -type f -name '*.proto' -not -path './bin/*'`; do \ echo "⇒ Processing $$f "; \ - protoc \ - --proto_path=.:./vendor:/usr/local/include \ - --plugin=protoc-gen-go-frostfs=$(BIN)/protogen \ + $(PROTOC_DIR)/bin/protoc \ + --proto_path=.:$(PROTOC_DIR)/include:/usr/local/include \ + --plugin=protoc-gen-go=$(PROTOC_GEN_GO_DIR)/protoc-gen-go \ + --plugin=protoc-gen-go-frostfs=$(PROTOGEN_FROSTFS_DIR)/protogen \ --go-frostfs_out=. --go-frostfs_opt=paths=source_relative \ --go_out=. --go_opt=paths=source_relative \ --go-grpc_opt=require_unimplemented_servers=false \ --go-grpc_out=. --go-grpc_opt=paths=source_relative $$f; \ done - rm -rf vendor + +protoc-install: + @rm -rf $(PROTOBUF_DIR) + @mkdir $(PROTOBUF_DIR) + @echo "⇒ Installing protoc... " + @wget -q -O $(PROTOBUF_DIR)/protoc-$(PROTOC_VERSION).zip 'https://github.com/protocolbuffers/protobuf/releases/download/v$(PROTOC_VERSION)/protoc-$(PROTOC_VERSION)-$(PROTOC_OS_VERSION).zip' + @unzip -q -o $(PROTOBUF_DIR)/protoc-$(PROTOC_VERSION).zip -d $(PROTOC_DIR) + @rm $(PROTOBUF_DIR)/protoc-$(PROTOC_VERSION).zip + @echo "⇒ Installing protoc-gen-go..." + @GOBIN=$(PROTOC_GEN_GO_DIR) go install -v google.golang.org/protobuf/...@$(PROTOC_GEN_GO_VERSION) + @echo "⇒ Instaling protogen FrostFS plugin..." + @GOBIN=$(PROTOGEN_FROSTFS_DIR) go install -mod=mod -v git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/protogen@$(PROTOGEN_FROSTFS_VERSION) # Build FrostFS component's docker image image-%: @@ -143,6 +167,8 @@ pre-commit-run: # Install linters lint-install: + @rm -rf $(OUTPUT_LINT_DIR) + @mkdir $(OUTPUT_LINT_DIR) @mkdir -p $(TMP_DIR) @rm -rf $(TMP_DIR)/linters @git -c advice.detachedHead=false clone --branch v$(TRUECLOUDLAB_LINT_VERSION) https://git.frostfs.info/TrueCloudLab/linters.git $(TMP_DIR)/linters @@ -154,18 +180,22 @@ lint-install: # Run linters lint: @if [ ! -d "$(LINT_DIR)" ]; then \ - echo "Run make lint-install"; \ - exit 1; \ + make lint-install; \ fi $(LINT_DIR)/golangci-lint run # Install staticcheck staticcheck-install: - @go install honnef.co/go/tools/cmd/staticcheck@latest + @rm -rf $(STATICCHECK_DIR) + @mkdir $(STATICCHECK_DIR) + @GOBIN=$(STATICCHECK_VERSION_DIR) go install honnef.co/go/tools/cmd/staticcheck@$(STATICCHECK_VERSION) # Run staticcheck staticcheck-run: - @staticcheck ./... + @if [ ! -d "$(STATICCHECK_VERSION_DIR)" ]; then \ + make staticcheck-install; \ + fi + @$(STATICCHECK_VERSION_DIR)/staticcheck ./... # Run linters in Docker docker/lint: @@ -189,7 +219,6 @@ version: # Delete built artifacts clean: - rm -rf vendor rm -rf .cache rm -rf $(BIN) rm -rf $(RELEASE) -- 2.45.2 From b4ebde61f64ebab0597357c391805484740937f8 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Wed, 8 Nov 2023 15:45:03 +0300 Subject: [PATCH 2/2] [#792] proto: Regenerate with fixed version Signed-off-by: Dmitrii Stepanov --- pkg/services/control/ir/service.pb.go | Bin 44317 -> 44317 bytes pkg/services/control/ir/service_grpc.pb.go | Bin 9163 -> 9163 bytes pkg/services/control/ir/types.pb.go | Bin 7799 -> 7799 bytes pkg/services/control/service.pb.go | Bin 194092 -> 194092 bytes pkg/services/control/service_grpc.pb.go | Bin 31613 -> 31613 bytes pkg/services/control/types.pb.go | Bin 29563 -> 29563 bytes pkg/services/tree/service.pb.go | Bin 124265 -> 124265 bytes pkg/services/tree/service_grpc.pb.go | Bin 19139 -> 19139 bytes pkg/services/tree/types.pb.go | Bin 9911 -> 9911 bytes 9 files changed, 0 insertions(+), 0 deletions(-) diff --git a/pkg/services/control/ir/service.pb.go b/pkg/services/control/ir/service.pb.go index 56d52be4cea02be4088b63df72a42400232e06a4..1b81a56191ecbd7ab344fec2f1536f89c5bea6c3 100644 GIT binary patch delta 43 tcmbPxi)rpHrU}7v#)f(ZT>AP7oCQVsCHct;P*7%~XJo2pu(5E>8UQ1u4D|p2 delta 43 tcmbPxi)rpHrU}7vMrL{jT>AP7oCQVsCHct;P*7%~XJn#hvaxW@8UQ3U4Ez89 diff --git a/pkg/services/control/ir/service_grpc.pb.go b/pkg/services/control/ir/service_grpc.pb.go index 004c82446cb205f0ebaf92d29cba085a9b3f56f7..724149c441106253c7d6083f543f941dfeda5f47 100644 GIT binary patch delta 14 VcmX@@e%gIP9kZ#P!Nx`}WdJSj1!w>O delta 14 VcmX@@e%gIP9kYp^$;L)6WdJSw1#18R diff --git a/pkg/services/control/ir/types.pb.go b/pkg/services/control/ir/types.pb.go index 0ff8f45e9bf4641ddfb2c6023d35441c8a8b6961..cc39ad572cad58a879fea8549bfb1411bed98984 100644 GIT binary patch delta 41 rcmexv^WA1bu$-}>o&lG>z5-`KQGQ8&vH}#8ndljr>KSY-WRn8`2*L|B delta 41 rcmexv^WA1bu$+;Zo&lG>z5-`KQGQ8&vH}#8ndljr=$ULRWRn8`2~rC@ diff --git a/pkg/services/control/service.pb.go b/pkg/services/control/service.pb.go index 547ea7e7e2d6fdd8eda86f2bcdb6e2bb2e026e6f..346a43664023680604fca2d370c5be16e7562346 100644 GIT binary patch delta 49 zcmZ4UhI`E$?g_zi#)f(ZT>AP7oCQVsCHct;P*7%~XJo2p&{)`7$hftTY4=wEgTN1v delta 49 zcmZ4UhI`E$?g_ziMrL{jT>AP7oCQVsCHct;P*7%~XJn#h(pcD9$hftTY4=wEgnAE` diff --git a/pkg/services/control/service_grpc.pb.go b/pkg/services/control/service_grpc.pb.go index b5881ccb2abb5024d0a9f79f1df45030156f3101..c3976c54aac5a708be939f5a4083731bf0aaa004 100644 GIT binary patch delta 16 YcmezSjq&d{#tC)Irg{b&8~;=R081JOH2?qr delta 16 YcmezSjq&d{#tC)ICVD0t8~;=R081wbH~;_u diff --git a/pkg/services/control/types.pb.go b/pkg/services/control/types.pb.go index 33700c5b9d03f4aa8c12b30195509d59d30531cb..f031f8043d87f83ea9725eec9071283be691823e 100644 GIT binary patch delta 43 tcmezUjPds~#tFf4#)f(ZT>AP7oCQVsCHct;P*7%~XJo2pu(6P<7yv{c4D0{^ delta 43 tcmezUjPds~#tFf4MrL{jT>AP7oCQVsCHct;P*7%~XJn#hvayh>7yv}C4D$d0 diff --git a/pkg/services/tree/service.pb.go b/pkg/services/tree/service.pb.go index 63f3e714a2578d648309f46e53a12d3eda9f61f0..5346613895989cf6ba53fcaee985b5308a50177c 100644 GIT binary patch delta 28 kcmaEPiv8s&_6hY&#)cCc#n?>rj7;?m8s~1E%XsDq0H;0+U;qFB delta 28 kcmaEPiv8s&_6hY&MrIQm#n_DXj12WG8|QAF%XsDq0H>G>XaE2J diff --git a/pkg/services/tree/service_grpc.pb.go b/pkg/services/tree/service_grpc.pb.go index 2c0828951aea66870e38f68316b12ef987686967..63f96e11a561bc8a96b26272e90478e59539536b 100644 GIT binary patch delta 19 bcmX>+mGSUY#tF;WO!SOQ^$a$y74rfBOJoMs delta 19 bcmX>+mGSUY#tF;WjP;BR^(;5874rfBOKS$% diff --git a/pkg/services/tree/types.pb.go b/pkg/services/tree/types.pb.go index b4d6981ef92d8434e0d3ffa6370d8cb860db9ce4..f6b19c20ff988c8a7d00894c97acebe46efc4341 100644 GIT binary patch delta 41 rcmdn)yWMv}mz=Soo&lG>z5-`KQGQ8&vH}#8ndljr>KSZY!LJ4Y0&5Fa delta 41 rcmdn)yWMv}mzz5-`KQGQ8&vH}#88S5Dt>RE1F!LJ4Y0`&`C -- 2.45.2