|
| 1 | +.PHONY: lint fix clean vulncheck ci deps deps-update run help |
| 2 | + |
| 3 | +# Variables |
| 4 | +BINARY_NAME=kmir |
| 5 | +GO=go |
| 6 | +GOFLAGS=-v |
| 7 | +LINTER=golangci-lint |
| 8 | + |
| 9 | +help: ## Show this help message |
| 10 | + @echo 'Usage: make [target]' |
| 11 | + @echo '' |
| 12 | + @echo 'Available targets:' |
| 13 | + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST) |
| 14 | + |
| 15 | +build: ## Build the binary |
| 16 | + @echo "Building $(BINARY_NAME)..." |
| 17 | + $(GO) build $(GOFLAGS) -o $(BINARY_NAME) . |
| 18 | + |
| 19 | +test: ## Run tests |
| 20 | + @echo "Running tests..." |
| 21 | + $(GO) test -v -race -coverprofile=coverage.out -covermode=atomic ./... |
| 22 | + |
| 23 | +test-short: ## Run short tests only |
| 24 | + @echo "Running short tests..." |
| 25 | + $(GO) test -v -short ./... |
| 26 | + |
| 27 | +lint: ## Run linters |
| 28 | + @echo "Running linters..." |
| 29 | + $(LINTER) run --timeout 5m ./...; \ |
| 30 | + |
| 31 | +fix: ## Auto-fix linting issues |
| 32 | + @echo "Fixing linting issues..." |
| 33 | + $(LINTER) run --fix --timeout 5m ./...; \ |
| 34 | + |
| 35 | +coverage: ## Generate coverage report |
| 36 | + @echo "Generating coverage report..." |
| 37 | + $(GO) test -coverprofile=coverage.out -covermode=atomic ./... |
| 38 | + $(GO) tool cover -html=coverage.out -o coverage.html |
| 39 | + @echo "Coverage report generated: coverage.html" |
| 40 | + |
| 41 | +coverage-func: ## Show coverage by function |
| 42 | + @echo "Coverage by function:" |
| 43 | + $(GO) test -coverprofile=coverage.out -covermode=atomic ./... |
| 44 | + $(GO) tool cover -func=coverage.out |
| 45 | + |
| 46 | +clean: ## Clean build artifacts |
| 47 | + @echo "Cleaning..." |
| 48 | + rm -f $(BINARY_NAME) |
| 49 | + rm -f coverage.out coverage.html |
| 50 | + rm -f *.test |
| 51 | + |
| 52 | +vulncheck: ## Check for security vulnerabilities |
| 53 | + @echo "Checking for vulnerabilities..." |
| 54 | + $(GO) tool govulncheck ./... |
| 55 | + |
| 56 | +ci: lint vulncheck test ## Run CI checks (lint + vulncheck + test) |
| 57 | + |
| 58 | +deps: ## Download dependencies |
| 59 | + @echo "Downloading dependencies..." |
| 60 | + $(GO) mod download |
| 61 | + $(GO) mod tidy |
| 62 | + |
| 63 | +deps-update: ## Update dependencies |
| 64 | + @echo "Updating dependencies..." |
| 65 | + $(GO) get -u ./... |
| 66 | + $(GO) mod tidy |
| 67 | + |
| 68 | +run: build ## Build and run the binary |
| 69 | + @echo "Running $(BINARY_NAME)..." |
| 70 | + ./$(BINARY_NAME) |
0 commit comments