#!/usr/bin/make -f SHELL = bash TRUECLOUDLAB_LINT_VERSION ?= 0.0.3 TMP_DIR := .cache OUTPUT_LINT_DIR ?= $(shell pwd)/bin LINT_VERSION ?= 1.59.1 LINT_DIR = $(OUTPUT_LINT_DIR)/golangci-lint-$(LINT_VERSION)-v$(TRUECLOUDLAB_LINT_VERSION) # Run all code formatters fmts: fmt imports # Reformat code fmt: @echo "⇒ Processing gofmt check" @gofumpt -s -w . # Reformat imports imports: @echo "⇒ Processing goimports check" @goimports -w . # Run Unit Test with go test test: @echo "⇒ Running go test" @go test ./... -count=1 # Activate pre-commit hooks pre-commit: pre-commit install -t pre-commit -t commit-msg # Deactivate pre-commit hooks unpre-commit: pre-commit uninstall -t pre-commit -t commit-msg pre-commit-run: @pre-commit run -a --hook-stage manual # Install linters lint-install: @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) # Run linters lint: @if [ ! -d "$(LINT_DIR)" ]; then \ echo "Run make lint-install"; \ exit 1; \ fi @$(LINT_DIR)/golangci-lint run # Install staticcheck staticcheck-install: @go install honnef.co/go/tools/cmd/staticcheck@latest # Run staticcheck staticcheck-run: @staticcheck ./...