|
| 1 | +# Makefile for InferaDB Management API |
| 2 | +# Provides convenient shortcuts for common cargo commands |
| 3 | +# |
| 4 | +# Quick start: |
| 5 | +# make setup - One-time setup (installs tools) |
| 6 | +# make test - Run all tests |
| 7 | +# make check - Run all quality checks |
| 8 | +# make dev - Start development server with watch |
| 9 | +# |
| 10 | +# Use 'make help' to see all available commands |
| 11 | + |
| 12 | +.PHONY: help setup test test-integration test-fdb check format lint audit deny run build release clean reset dev doc coverage bench fix ci |
| 13 | + |
| 14 | +# Use mise exec if available, otherwise use system cargo |
| 15 | +CARGO := $(shell command -v mise > /dev/null 2>&1 && echo "mise exec -- cargo" || echo "cargo") |
| 16 | +PRETTIER := $(shell command -v mise > /dev/null 2>&1 && echo "mise exec -- prettier" || echo "prettier") |
| 17 | +TAPLO := $(shell command -v mise > /dev/null 2>&1 && echo "mise exec -- taplo" || echo "taplo") |
| 18 | + |
| 19 | +# Default target - show help |
| 20 | +.DEFAULT_GOAL := help |
| 21 | + |
| 22 | +help: ## Show this help message |
| 23 | + @echo "InferaDB Management API Commands" |
| 24 | + @echo "" |
| 25 | + @echo "Setup & Development:" |
| 26 | + @grep -E '^(setup|run|dev|build|release|clean|reset):.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-22s\033[0m %s\n", $$1, $$2}' |
| 27 | + @echo "" |
| 28 | + @echo "Testing:" |
| 29 | + @grep -E '^test.*:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-22s\033[0m %s\n", $$1, $$2}' |
| 30 | + @echo "" |
| 31 | + @echo "Code Quality:" |
| 32 | + @grep -E '^(check|format|lint|audit|deny|fix):.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-22s\033[0m %s\n", $$1, $$2}' |
| 33 | + @echo "" |
| 34 | + @echo "Documentation & Analysis:" |
| 35 | + @grep -E '^(doc|coverage|bench):.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-22s\033[0m %s\n", $$1, $$2}' |
| 36 | + @echo "" |
| 37 | + @echo "CI/CD:" |
| 38 | + @grep -E '^ci:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-22s\033[0m %s\n", $$1, $$2}' |
| 39 | + @echo "" |
| 40 | + @echo "Use 'cargo <command> --help' for more options" |
| 41 | + @echo "" |
| 42 | + |
| 43 | +setup: ## One-time development environment setup |
| 44 | + @echo "🔧 Setting up Management API development environment..." |
| 45 | + @if command -v mise > /dev/null 2>&1; then \ |
| 46 | + mise trust && mise install; \ |
| 47 | + else \ |
| 48 | + echo "⚠️ mise not found - using system cargo"; \ |
| 49 | + fi |
| 50 | + @$(CARGO) fetch |
| 51 | + @echo "✅ Setup complete!" |
| 52 | + |
| 53 | +test: ## Run all tests (unit + integration) |
| 54 | + @echo "🧪 Running all tests..." |
| 55 | + @$(CARGO) test --all-targets |
| 56 | + |
| 57 | +test-integration: ## Run integration tests only |
| 58 | + @echo "🧪 Running integration tests..." |
| 59 | + @$(CARGO) test --test '*' --workspace |
| 60 | + |
| 61 | +test-fdb: ## Run FoundationDB integration tests (requires Docker) |
| 62 | + @echo "🧪 Running FDB integration tests..." |
| 63 | + @./docker/fdb-integration-tests/test.sh |
| 64 | + |
| 65 | +check: ## Run code quality checks (format, lint, audit) |
| 66 | + @echo "🔍 Running code quality checks..." |
| 67 | + @$(MAKE) format |
| 68 | + @$(MAKE) lint |
| 69 | + @$(MAKE) audit |
| 70 | + @echo "✅ All checks passed!" |
| 71 | + |
| 72 | +format: ## Format code (Prettier, Taplo, rustfmt) |
| 73 | + @echo "📝 Formatting code..." |
| 74 | + @$(PRETTIER) --write "**/*.{md,yml,yaml,json}" --log-level warn || true |
| 75 | + @$(TAPLO) fmt || true |
| 76 | + @$(CARGO) +nightly fmt --all || $(CARGO) fmt --all |
| 77 | + @echo "✅ Formatting complete!" |
| 78 | + |
| 79 | +lint: ## Run clippy linter |
| 80 | + @echo "🔍 Running clippy..." |
| 81 | + @$(CARGO) clippy --workspace --all-targets --all-features -- -D warnings |
| 82 | + |
| 83 | +audit: ## Run security audit |
| 84 | + @echo "🔒 Running security audit..." |
| 85 | + @$(CARGO) audit || echo "⚠️ cargo-audit not installed, skipping..." |
| 86 | + |
| 87 | +deny: ## Check dependencies with cargo-deny |
| 88 | + @echo "🔍 Checking dependencies..." |
| 89 | + @$(CARGO) deny check || echo "⚠️ cargo-deny not installed, skipping..." |
| 90 | + |
| 91 | +run: ## Run the management API server (debug mode) |
| 92 | + @echo "🚀 Starting Management API server..." |
| 93 | + @$(CARGO) run --bin infera-management |
| 94 | + |
| 95 | +dev: ## Run with auto-reload (requires cargo-watch) |
| 96 | + @echo "🔄 Starting Management API server with auto-reload..." |
| 97 | + @$(CARGO) watch -x 'run --bin infera-management' |
| 98 | + |
| 99 | +build: ## Build debug binary |
| 100 | + @echo "🔨 Building debug binary..." |
| 101 | + @$(CARGO) build |
| 102 | + |
| 103 | +release: ## Build optimized release binary |
| 104 | + @echo "🚀 Building release binary..." |
| 105 | + @$(CARGO) build --release |
| 106 | + |
| 107 | +clean: ## Clean build artifacts |
| 108 | + @echo "🧹 Cleaning build artifacts..." |
| 109 | + @$(CARGO) clean |
| 110 | + |
| 111 | +reset: ## Full reset (clean + remove target directory) |
| 112 | + @echo "⚠️ Performing full reset..." |
| 113 | + @$(CARGO) clean |
| 114 | + @rm -rf target |
| 115 | + @rm -rf Cargo.lock |
| 116 | + @echo "✅ Reset complete!" |
| 117 | + |
| 118 | +doc: ## Generate and open documentation |
| 119 | + @echo "📚 Generating documentation..." |
| 120 | + @$(CARGO) doc --no-deps --open |
| 121 | + |
| 122 | +coverage: ## Generate code coverage report |
| 123 | + @echo "📊 Generating coverage report..." |
| 124 | + @$(CARGO) tarpaulin --workspace --timeout 300 --out Html --output-dir target/coverage |
| 125 | + @echo "✅ Coverage report generated at target/coverage/index.html" |
| 126 | + |
| 127 | +bench: ## Run benchmarks |
| 128 | + @echo "⚡ Running benchmarks..." |
| 129 | + @$(CARGO) bench |
| 130 | + |
| 131 | +fix: ## Auto-fix clippy warnings |
| 132 | + @echo "🔧 Auto-fixing clippy warnings..." |
| 133 | + @$(CARGO) clippy --fix --allow-dirty --allow-staged |
| 134 | + |
| 135 | +ci: ## Run CI checks (format, lint, test, audit) |
| 136 | + @echo "🤖 Running CI checks..." |
| 137 | + @$(MAKE) format |
| 138 | + @$(MAKE) lint |
| 139 | + @$(MAKE) test |
| 140 | + @$(MAKE) audit |
| 141 | + @echo "✅ CI checks passed!" |
0 commit comments