|
| 1 | +# Makefile for feature-installer |
| 2 | + |
| 3 | +.PHONY: help build test lint fmt vet clean install deps check |
| 4 | + |
| 5 | +# Default target |
| 6 | +help: ## Show this help message |
| 7 | + @echo 'Usage: make [target]' |
| 8 | + @echo '' |
| 9 | + @echo 'Targets:' |
| 10 | + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST) |
| 11 | + |
| 12 | +# Build the binary |
| 13 | +build: ## Build the binary |
| 14 | + go build -v -o feature-installer . |
| 15 | + |
| 16 | +# Run tests |
| 17 | +test: ## Run all tests |
| 18 | + go test -v -race ./... |
| 19 | + |
| 20 | +# Run tests with coverage |
| 21 | +test-coverage: ## Run tests with coverage report |
| 22 | + go test -v -race -coverprofile=coverage.out ./... |
| 23 | + go tool cover -html=coverage.out -o coverage.html |
| 24 | + @echo "Coverage report generated: coverage.html" |
| 25 | + |
| 26 | +# Format code |
| 27 | +fmt: ## Format Go code |
| 28 | + go fmt ./... |
| 29 | + gofmt -s -w . |
| 30 | + |
| 31 | +# Run go vet |
| 32 | +vet: ## Run go vet |
| 33 | + go vet ./... |
| 34 | + |
| 35 | +# Run linting (if golangci-lint is available) |
| 36 | +lint: ## Run golangci-lint (requires golangci-lint to be installed) |
| 37 | + @which golangci-lint > /dev/null || (echo "golangci-lint not found. Install from https://golangci-lint.run/usage/install/" && exit 1) |
| 38 | + golangci-lint run |
| 39 | + |
| 40 | +# Install dependencies |
| 41 | +deps: ## Download and verify dependencies |
| 42 | + go mod download |
| 43 | + go mod verify |
| 44 | + go mod tidy |
| 45 | + |
| 46 | +# Run all checks (format, vet, test) |
| 47 | +check: fmt vet test ## Run formatting, vetting, and tests |
| 48 | + |
| 49 | +# Clean build artifacts |
| 50 | +clean: ## Clean build artifacts |
| 51 | + rm -f feature-installer |
| 52 | + rm -f coverage.out coverage.html |
| 53 | + go clean -cache |
| 54 | + go clean -testcache |
| 55 | + |
| 56 | +# Install the binary |
| 57 | +install: ## Install the binary to $GOPATH/bin |
| 58 | + go install . |
| 59 | + |
| 60 | +# Run the CI checks locally |
| 61 | +ci-local: deps fmt vet test ## Run the same checks as CI |
| 62 | + |
| 63 | +# Build for multiple platforms |
| 64 | +build-all: ## Build for multiple platforms |
| 65 | + GOOS=linux GOARCH=amd64 go build -o feature-installer-linux-amd64 . |
| 66 | + GOOS=linux GOARCH=arm64 go build -o feature-installer-linux-arm64 . |
| 67 | + GOOS=darwin GOARCH=amd64 go build -o feature-installer-darwin-amd64 . |
| 68 | + GOOS=darwin GOARCH=arm64 go build -o feature-installer-darwin-arm64 . |
| 69 | + GOOS=windows GOARCH=amd64 go build -o feature-installer-windows-amd64.exe . |
| 70 | + |
| 71 | +# Development target - watch for changes and run tests |
| 72 | +dev: ## Run tests in watch mode (requires entr: brew install entr) |
| 73 | + find . -name "*.go" | entr -c make test |
0 commit comments