|
| 1 | +# Makefile for data-pipeline-v3 |
| 2 | +# Provides convenient commands for development workflow |
| 3 | +PROJ_NAME := cli |
| 4 | +PROJ_DESC := CLI tools for Zylisp |
| 5 | +BIN_DIR = ./bin |
| 6 | +MAINS = cmd/%/main.go |
| 7 | +CMDS = $(wildcard cmd/*/main.go) |
| 8 | +BINS = $(patsubst $(MAINS),bin/%,$(CMDS)) |
| 9 | + |
| 10 | +.PHONY: help build clean test test-integration test-verbose test-single lint format format-check publish-local check-types install deps version release just-publish publish micro+ minor+ major+ setup gen-data run-local stop logs status |
| 11 | + |
| 12 | +# Default target |
| 13 | +.DEFAULT_GOAL := help |
| 14 | + |
| 15 | +# Colors for output |
| 16 | +BLUE := \033[1;34m |
| 17 | +GREEN := \033[1;32m |
| 18 | +YELLOW := \033[1;33m |
| 19 | +RED := \033[1;31m |
| 20 | +RESET := \033[0m |
| 21 | + |
| 22 | + |
| 23 | +help: ## Show this help message |
| 24 | + @echo "$(BLUE)$(PROJ_DESC) - Available Commands$(RESET)" |
| 25 | + @echo "" |
| 26 | + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "$(GREEN)%-20s$(RESET) %s\n", $$1, $$2}' |
| 27 | + @echo "" |
| 28 | + @echo "$(YELLOW)Prerequisites:$(RESET)" |
| 29 | + @echo " - Go 1.21+" |
| 30 | + @echo " - Make" |
| 31 | + @echo "" |
| 32 | + |
| 33 | +deps: ## Install/update dependencies |
| 34 | + @echo "$(BLUE)Installing dependencies...$(RESET)" |
| 35 | + @go mod download |
| 36 | + @go mod tidy |
| 37 | + @echo "$(GREEN)✅ Dependencies installed$(RESET)" |
| 38 | + |
| 39 | +clean: ## Clean build artifacts |
| 40 | + @echo "$(BLUE)Cleaning build artifacts...$(RESET)" |
| 41 | + @rm -rf ./bin |
| 42 | + @rm -f coverage.out |
| 43 | + @echo "$(GREEN)✅ Clean completed$(RESET)" |
| 44 | + |
| 45 | +$(BIN_DIR): |
| 46 | + mkdir -p $(BIN_DIR) |
| 47 | + |
| 48 | +bin/%: $(BIN_DIR) cmd/%/main.go |
| 49 | + @echo "$(BLUE)Building $@ from cmd/$*/...$(RESET)" |
| 50 | + @go build -o ./$@ ./cmd/$*/ |
| 51 | + @echo "$(GREEN)✅ Built $@$(RESET)" |
| 52 | + |
| 53 | +build: $(BINS) ## Full build (builds all binaries in cmd/) |
| 54 | + @echo "$(GREEN)✅ Build completed$(RESET)" |
| 55 | + |
| 56 | +test: ## Run all tests |
| 57 | + @echo "$(BLUE)Running tests...$(RESET)" |
| 58 | + @go test -race -coverprofile=coverage.out -covermode=atomic ./... |
| 59 | + @echo "$(GREEN)✅ Tests completed$(RESET)" |
| 60 | + @go tool cover -func=coverage.out | tail -1 |
| 61 | + |
| 62 | +test-verbose: ## Run tests with verbose output |
| 63 | + @echo "$(BLUE)Running tests with verbose output...$(RESET)" |
| 64 | + @go test -v -race ./... |
| 65 | + @echo "$(GREEN)✅ Verbose tests completed$(RESET)" |
| 66 | + |
| 67 | +test-single: ## Run a single test (usage: make test-single TEST=TestName) |
| 68 | +ifndef TEST |
| 69 | + @echo "$(RED)Error: Please specify TEST=TestName$(RESET)" |
| 70 | + @exit 1 |
| 71 | +endif |
| 72 | + @echo "$(BLUE)Running single test: $(TEST)...$(RESET)" |
| 73 | + @go test -v -race -run $(TEST) ./... |
| 74 | + @echo "$(GREEN)✅ Single test completed$(RESET)" |
| 75 | + |
| 76 | +lint: ## Run code quality checks |
| 77 | + @echo "$(BLUE)Running code quality checks...$(RESET)" |
| 78 | + @if command -v golangci-lint >/dev/null 2>&1; then \ |
| 79 | + golangci-lint run ./...; \ |
| 80 | + echo "$(GREEN)✅ Linting completed$(RESET)"; \ |
| 81 | + else \ |
| 82 | + echo "$(YELLOW)⚠ golangci-lint not found. Install with: brew install golangci-lint$(RESET)"; \ |
| 83 | + fi |
| 84 | + |
| 85 | +format: ## Format code |
| 86 | + @echo "$(BLUE)Formatting code...$(RESET)" |
| 87 | + @go fmt ./... |
| 88 | + @if command -v goimports >/dev/null 2>&1; then \ |
| 89 | + goimports -w .; \ |
| 90 | + else \ |
| 91 | + echo "$(YELLOW)⚠ goimports not found. Install with: go install golang.org/x/tools/cmd/goimports@latest$(RESET)"; \ |
| 92 | + fi |
| 93 | + @echo "$(GREEN)✅ Code formatted$(RESET)" |
| 94 | + |
| 95 | +format-check: ## Check if code is properly formatted |
| 96 | + @echo "$(BLUE)Checking code formatting...$(RESET)" |
| 97 | + @test -z "$$(gofmt -l .)" || (echo "$(RED)Code not formatted. Run 'make format'$(RESET)" && exit 1) |
| 98 | + @echo "$(GREEN)✅ Format check completed$(RESET)" |
| 99 | + |
| 100 | +check-types: ## Validate types and compilation |
| 101 | + @echo "$(BLUE)Checking types and compilation...$(RESET)" |
| 102 | + @go build -o /dev/null ./... |
| 103 | + @echo "$(GREEN)✅ Type checking completed$(RESET)" |
| 104 | + |
| 105 | +verify: check-types test lint ## Run full verification (compile, test, lint) |
| 106 | + @echo "$(GREEN)✅ Verification completed$(RESET)" |
| 107 | + |
| 108 | +install: ## Install to local |
| 109 | + @echo "$(BLUE)Installing to local repository...$(RESET)" |
| 110 | + @echo "$(GREEN)✅ Installed to ...?$(RESET)" |
| 111 | + |
| 112 | +force-install: ## Force-install to local |
| 113 | + @echo "$(RED)Installing to local repository...$(RESET)" |
| 114 | + @echo "$(GREEN)‼️ Force-installed to ~/.m2/repository$(RESET)" |
| 115 | + |
| 116 | +publish-local: install ## Alias for install |
| 117 | + |
| 118 | +package: ## Create package |
| 119 | + @echo "$(BLUE)Creating package...$(RESET)" |
| 120 | + @echo "$(GREEN)✅ Package created$(RESET)" |
| 121 | + |
| 122 | +site: ## Generate project site and reports |
| 123 | + @echo "$(BLUE)Generating project site...$(RESET)" |
| 124 | + @echo "$(GREEN)✅ Site generated in target/site/$(RESET)" |
| 125 | + |
| 126 | +dependency-tree: ## Show dependency tree |
| 127 | + @echo "$(BLUE)Showing dependency tree...$(RESET)" |
| 128 | + |
| 129 | +dependency-updates: ## Check for dependency updates |
| 130 | + @echo "$(BLUE)Checking for dependency updates...$(RESET)" |
| 131 | + |
| 132 | +plugin-updates: ## Check for plugin updates |
| 133 | + @echo "$(BLUE)Checking for plugin updates...$(RESET)" |
| 134 | + |
| 135 | +security-check: ## Run security vulnerability check |
| 136 | + @echo "$(BLUE)Running security vulnerability check...$(RESET)" |
| 137 | + @echo "$(GREEN)✅ Security check completed$(RESET)" |
| 138 | + |
| 139 | +release-prepare: ## Prepare release (update versions, create tag) |
| 140 | + @echo "$(BLUE)Preparing release...$(RESET)" |
| 141 | + @echo "$(GREEN)✅ Release prepared$(RESET)" |
| 142 | + |
| 143 | +release-perform: ## Perform release (deploy to repository) |
| 144 | + @echo "$(BLUE)Performing release...$(RESET)" |
| 145 | + @echo "$(GREEN)✅ Release performed$(RESET)" |
| 146 | + |
| 147 | +quick: ## Quick build and test |
| 148 | + @echo "$(BLUE)Running quick build and test...$(RESET)" |
| 149 | + @echo "$(GREEN)✅ Quick build completed$(RESET)" |
| 150 | + |
| 151 | +ci: clean lint check-types test package ## CI pipeline (clean, lint, check-types, test, package) |
| 152 | + @echo "$(GREEN)✅ CI pipeline completed successfully$(RESET)" |
| 153 | + |
| 154 | +dev-setup: deps ## Setup development environment |
| 155 | + @echo "$(BLUE)Setting up development environment...$(RESET)" |
| 156 | + @echo "$(GREEN)✅ Development environment ready$(RESET)" |
| 157 | + |
| 158 | +watch: ## Watch for changes and run tests |
| 159 | + @echo "$(BLUE)Watching for changes...$(RESET)" |
| 160 | + @echo "$(YELLOW)Note: This uses fswatch. Install with: brew install fswatch (macOS) or apt-get install fswatch (Linux)$(RESET)" |
| 161 | + @which fswatch > /dev/null || (echo "$(RED)Error: fswatch not found$(RESET)" && exit 1) |
| 162 | + fswatch -o src/ pom.xml | xargs -n1 -I{} make quick |
| 163 | + |
| 164 | +clean-all: clean ## Clean everything including IDE files |
| 165 | + @echo "$(BLUE)Cleaning all files...$(RESET)" |
| 166 | + @echo "$(GREEN)✅ Everything cleaned$(RESET)" |
| 167 | + |
| 168 | +version: ## Show current project version |
| 169 | + @echo TBD |
| 170 | + |
| 171 | +micro+: ## Increment micro/patch version (x.y.z -> x.y.z+1) |
| 172 | + @echo "$(BLUE)Incrementing micro version...$(RESET)" |
| 173 | + echo "$(GREEN)✅ Version updated to: $$new_version$(RESET)" |
| 174 | + |
| 175 | +minor+: ## Increment minor version (x.y.z -> x.y+1.0) |
| 176 | + @echo "$(BLUE)Incrementing minor version...$(RESET)" |
| 177 | + echo "$(GREEN)✅ Version updated to: $$new_version$(RESET)" |
| 178 | + |
| 179 | +major+: ## Increment major version (x.y.z -> x+1.0.0) |
| 180 | + @echo "$(BLUE)Incrementing major version...$(RESET)" |
| 181 | + @current=$$($(MVN) help:evaluate -Dexpression=project.version -q -DforceStdout) && \ |
| 182 | + echo "$(GREEN)✅ Version updated to: $$new_version$(RESET)" |
| 183 | + |
| 184 | +release: ## Create and tag release version |
| 185 | + @echo "$(BLUE)Creating release...$(RESET)" |
| 186 | + @version=TBD && \ |
| 187 | + git tag -a "v$$version" -m "Release version $$version" && \ |
| 188 | + echo "$(GREEN)Tagged release v$$version$(RESET)" |
| 189 | + |
| 190 | +just-publish: ## Push changes and tags to origin |
| 191 | + @echo "$(BLUE)Publishing to origin...$(RESET)" |
| 192 | + @git pull origin main --rebase && \ |
| 193 | + git push origin main && \ |
| 194 | + git push origin main --tags |
| 195 | + @echo "$(GREEN)✅ Published to origin$(RESET)" |
| 196 | + |
| 197 | +publish: clean build release just-publish ## Full publish workflow (clean, build, release, publish) |
| 198 | + @echo "$(GREEN)✅ Full publish workflow completed$(RESET)" |
| 199 | + |
| 200 | +info: ## Show project information |
| 201 | + @echo "$(BLUE)Project Information$(RESET)" |
| 202 | + @echo "===================" |
| 203 | + @echo "$(YELLOW)Project:$(RESET) $(PROJ_DESC)" |
| 204 | + @echo "$(YELLOW)Module:$(RESET) $$(go list -m)" |
| 205 | + @echo "$(YELLOW)Go Version:$(RESET) $$(go version | cut -d' ' -f3)" |
| 206 | + @echo "$(YELLOW)Binary Directory:$(RESET) $(BIN_DIR)" |
| 207 | + @echo "" |
| 208 | + |
| 209 | +run: |
| 210 | + @echo "$(BLUE)Running REPL ...$(RESET)" |
| 211 | + @go run cmd/zylisp/main.go |
| 212 | + |
| 213 | +run-alt: |
| 214 | + @echo "$(BLUE)Running REPL with alternate prompt ...$(RESET)" |
| 215 | + @go run cmd/zylisp/main.go --prompt=alt |
| 216 | + |
| 217 | +test-integration: ## Run integration tests |
| 218 | + @echo "$(BLUE)Running integration tests...$(RESET)" |
| 219 | + @go test -tags=integration -v ./tests/integration/... |
| 220 | + @echo "$(GREEN)✅ Integration tests completed$(RESET)" |
| 221 | + |
| 222 | +# Development shortcuts |
| 223 | +dev: quick ## Alias for quick |
| 224 | +all: ci ## Alias for ci |
| 225 | +check: verify ## Alias for verify |
0 commit comments