git.frostfs.info/TrueCloudLab/frostfs-sdk-go@v0.0.0-20241022124111-5361f0ecebd3/Makefile (about)

     1  #!/usr/bin/make -f
     2  
     3  ANTLR_VERSION=4.13.1
     4  TMP_DIR := .cache
     5  LINT_VERSION ?= 1.60.1
     6  TRUECLOUDLAB_LINT_VERSION ?= 0.0.6
     7  OUTPUT_LINT_DIR ?= $(shell pwd)/bin
     8  LINT_DIR = $(OUTPUT_LINT_DIR)/golangci-lint-$(LINT_VERSION)-v$(TRUECLOUDLAB_LINT_VERSION)
     9  
    10  # Run tests
    11  test: GOFLAGS ?= "-cover -count=1"
    12  test:
    13  	@GOFLAGS=$(GOFLAGS) go test ./...
    14  
    15  # Pull go dependencies
    16  dep:
    17  	@printf "⇒ Download requirements: "
    18  	@CGO_ENABLED=0 \
    19  	go mod download && echo OK
    20  	@printf "⇒ Tidy requirements: "
    21  	@CGO_ENABLED=0 \
    22  	go mod tidy -v && echo OK
    23  
    24  # Install linters
    25  lint-install:
    26  	@mkdir -p $(TMP_DIR)
    27  	@rm -rf $(TMP_DIR)/linters
    28  	@git -c advice.detachedHead=false clone --branch v$(TRUECLOUDLAB_LINT_VERSION) https://git.frostfs.info/TrueCloudLab/linters.git $(TMP_DIR)/linters
    29  	@@make -C $(TMP_DIR)/linters lib CGO_ENABLED=1 OUT_DIR=$(OUTPUT_LINT_DIR)
    30  	@rm -rf $(TMP_DIR)/linters
    31  	@rmdir $(TMP_DIR) 2>/dev/null || true
    32  	@CGO_ENABLED=1 GOBIN=$(LINT_DIR) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v$(LINT_VERSION)
    33  
    34  # Run linters
    35  lint:
    36  	@if [ ! -d "$(LINT_DIR)" ]; then \
    37  		echo "Run make lint-install"; \
    38  		exit 1; \
    39  	fi
    40  	$(LINT_DIR)/golangci-lint run
    41  
    42  # Run tests with race detection and produce coverage output
    43  cover:
    44  	@go test -v -race ./... -coverprofile=coverage.txt -covermode=atomic
    45  	@go tool cover -html=coverage.txt -o coverage.html
    46  
    47  # Reformat code
    48  format:
    49  	@echo "⇒ Processing gofmt check"
    50  	@gofmt -s -w ./
    51  	@echo "⇒ Processing goimports check"
    52  	@goimports -w ./
    53  
    54  policy:
    55  	@wget -q https://www.antlr.org/download/antlr-${ANTLR_VERSION}-complete.jar -O antlr4-tool.jar
    56  	@java -Xmx500M -cp antlr4-tool.jar org.antlr.v4.Tool -Dlanguage=Go \
    57  	-no-listener -visitor netmap/parser/Query.g4 netmap/parser/QueryLexer.g4
    58  
    59  # Run `make %` in truecloudlab/frostfs-sdk-go container(Golang+Java)
    60  docker/%:
    61  	@docker build -t truecloudlab/frostfs-sdk-go --platform linux/amd64 . > /dev/null
    62  	@docker run --rm -t \
    63  	-v `pwd`:/work \
    64  	-u "$$(id -u):$$(id -g)" \
    65  	--env HOME=/work \
    66  	truecloudlab/frostfs-sdk-go make $*
    67  
    68  # Synchronize tree service
    69  sync-tree:
    70  	@./syncTree.sh
    71  
    72  # Show this help prompt
    73  help:
    74  	@echo '  Usage:'
    75  	@echo ''
    76  	@echo '    make <target>'
    77  	@echo ''
    78  	@echo '  Targets:'
    79  	@echo ''
    80  	@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
    81  
    82  # Activate pre-commit hooks
    83  pre-commit:
    84  	pre-commit install --hook-type pre-commit
    85  
    86  # Deactivate pre-commit hooks
    87  unpre-commit:
    88  	pre-commit uninstall --hook-type pre-commit
    89  
    90  # Run pre-commit hooks
    91  pre-commit-run:
    92  	@pre-commit run --all-files --hook-stage manual