2021-05-20 20:57:51 +00:00
|
|
|
#!/usr/bin/make -f
|
|
|
|
|
2023-05-30 12:48:19 +00:00
|
|
|
ANTLR_VERSION="4.13.0"
|
2023-10-23 15:05:03 +00:00
|
|
|
TMP_DIR := .cache
|
2024-08-21 13:42:58 +00:00
|
|
|
LINT_VERSION ?= 1.60.1
|
|
|
|
TRUECLOUDLAB_LINT_VERSION ?= 0.0.6
|
2023-10-23 15:05:03 +00:00
|
|
|
OUTPUT_LINT_DIR ?= $(shell pwd)/bin
|
|
|
|
LINT_DIR = $(OUTPUT_LINT_DIR)/golangci-lint-$(LINT_VERSION)-v$(TRUECLOUDLAB_LINT_VERSION)
|
2023-05-30 12:48:19 +00:00
|
|
|
|
2021-05-20 20:57:51 +00:00
|
|
|
# Run tests
|
2024-03-14 09:29:00 +00:00
|
|
|
test: GOFLAGS ?= "-cover -count=1"
|
2021-05-20 20:57:51 +00:00
|
|
|
test:
|
2024-03-14 09:29:00 +00:00
|
|
|
@GOFLAGS=$(GOFLAGS) go test ./...
|
2021-05-20 20:57:51 +00:00
|
|
|
|
|
|
|
# Pull go dependencies
|
|
|
|
dep:
|
|
|
|
@printf "⇒ Download requirements: "
|
|
|
|
@CGO_ENABLED=0 \
|
|
|
|
go mod download && echo OK
|
|
|
|
@printf "⇒ Tidy requirements: "
|
|
|
|
@CGO_ENABLED=0 \
|
|
|
|
go mod tidy -v && echo OK
|
|
|
|
|
2023-10-23 15:05:03 +00:00
|
|
|
# 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)
|
|
|
|
|
2021-05-20 20:57:51 +00:00
|
|
|
# Run linters
|
|
|
|
lint:
|
2023-10-23 15:05:03 +00:00
|
|
|
@if [ ! -d "$(LINT_DIR)" ]; then \
|
|
|
|
echo "Run make lint-install"; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
|
|
|
$(LINT_DIR)/golangci-lint run
|
2021-05-20 20:57:51 +00:00
|
|
|
|
|
|
|
# Run tests with race detection and produce coverage output
|
|
|
|
cover:
|
|
|
|
@go test -v -race ./... -coverprofile=coverage.txt -covermode=atomic
|
|
|
|
@go tool cover -html=coverage.txt -o coverage.html
|
|
|
|
|
|
|
|
# Reformat code
|
|
|
|
format:
|
|
|
|
@echo "⇒ Processing gofmt check"
|
|
|
|
@gofmt -s -w ./
|
|
|
|
@echo "⇒ Processing goimports check"
|
|
|
|
@goimports -w ./
|
|
|
|
|
2023-05-30 12:48:19 +00:00
|
|
|
policy:
|
|
|
|
@wget -q https://www.antlr.org/download/antlr-${ANTLR_VERSION}-complete.jar -O antlr4-tool.jar
|
|
|
|
@java -Xmx500M -cp "`pwd`/antlr4-tool.jar" "org.antlr.v4.Tool" -o `pwd`/netmap/parser/ -Dlanguage=Go -no-listener -visitor `pwd`/netmap/parser/Query.g4 `pwd`/netmap/parser/QueryLexer.g4
|
|
|
|
|
|
|
|
# Run `make %` in truecloudlab/frostfs-sdk-go container(Golang+Java)
|
|
|
|
docker/%:
|
|
|
|
@docker build -t truecloudlab/frostfs-sdk-go --platform linux/amd64 . > /dev/null
|
|
|
|
@docker run --rm -t \
|
|
|
|
-v `pwd`:/work \
|
|
|
|
-u "$$(id -u):$$(id -g)" \
|
|
|
|
--env HOME=/work \
|
|
|
|
truecloudlab/frostfs-sdk-go make $*
|
|
|
|
|
2023-06-06 06:27:28 +00:00
|
|
|
# Synchronize tree service
|
|
|
|
sync-tree:
|
|
|
|
@./syncTree.sh
|
|
|
|
|
2021-05-20 20:57:51 +00:00
|
|
|
# Show this help prompt
|
|
|
|
help:
|
|
|
|
@echo ' Usage:'
|
|
|
|
@echo ''
|
|
|
|
@echo ' make <target>'
|
|
|
|
@echo ''
|
|
|
|
@echo ' Targets:'
|
|
|
|
@echo ''
|
2023-03-03 09:29:33 +00:00
|
|
|
@awk '/^#/{ comment = substr($$0,3) } comment && /^[a-zA-Z][a-zA-Z0-9_-]+ ?:/{ print " ", $$1, comment }' $(MAKEFILE_LIST) | column -t -s ':' | grep -v 'IGNORE' | sort -u
|
2024-09-09 08:37:15 +00:00
|
|
|
|
|
|
|
# Activate pre-commit hooks
|
|
|
|
pre-commit:
|
|
|
|
pre-commit install --hook-type pre-commit
|
|
|
|
|
|
|
|
# Deactivate pre-commit hooks
|
|
|
|
unpre-commit:
|
|
|
|
pre-commit uninstall --hook-type pre-commit
|
|
|
|
|
|
|
|
# Run pre-commit hooks
|
|
|
|
pre-commit-run:
|
|
|
|
@pre-commit run --all-files --hook-stage manual
|