[#1] Set linters up

Signed-off-by: Alex Vanin <a.vanin@yadro.com>
This commit is contained in:
Alexey Vanin 2025-03-13 12:52:39 +03:00
parent 4514a32e8d
commit 2c10d9920f
3 changed files with 13 additions and 6 deletions

View file

@ -73,7 +73,6 @@ linters:
- gocognit
- contextcheck
- importas
- truecloudlab-linters
- perfsprint
- testifylint
- protogetter

View file

@ -1,3 +1,5 @@
include mk/*
GOBIN ?= $(shell go env GOPATH)/bin
PROTOC_VERSION ?= 25.6
@ -34,7 +36,13 @@ protoc: protoc-bin
done
# Run Unit Test with go test
.PHONY: test
test: GOFLAGS ?= "-count=1"
test:
@echo "> Running go test"
@GOFLAGS="$(GOFLAGS)" go test ./...
@GOFLAGS="$(GOFLAGS)" go test ./...
# Clean all installed files
.PHONY: clean
clean:
rm -rf ./bin/*

View file

@ -1,6 +1,6 @@
GO_VERSION ?= 1.22
LINT_VERSION ?= 1.56.1
TRUECLOUDLAB_LINT_VERSION ?= 0.0.5
LINT_VERSION ?= 1.62.0
TRUECLOUDLAB_LINT_VERSION ?= 0.0.8
BIN ?= bin
OUTPUT_LINT_DIR ?= $(abspath $(BIN))/linters
LINT_DIR ?= $(OUTPUT_LINT_DIR)/golangci-lint-$(LINT_VERSION)-v$(TRUECLOUDLAB_LINT_VERSION)
@ -11,14 +11,14 @@ TMP_DIR := .cache
# Install linters
$(LINT_DIR):
@rm -rf $(OUTPUT_LINT_DIR)
@mkdir $(OUTPUT_LINT_DIR)
@mkdir -p $(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
@@make -C $(TMP_DIR)/linters lib CGO_ENABLED=1 OUT_DIR=$(OUTPUT_LINT_DIR)
@rm -rf $(TMP_DIR)/linters
@rmdir $(TMP_DIR) 2>/dev/null || true
@CGO_ENABLED=1 GOBIN=$(LINT_DIR) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v$(LINT_VERSION)
@CGO_ENABLED=1 GOBIN=$(LINT_DIR) go install -trimpath github.com/golangci/golangci-lint/cmd/golangci-lint@v$(LINT_VERSION)
# Run linters
lint: $(LINT_DIR)