-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMakefile
More file actions
299 lines (259 loc) · 15.7 KB
/
Makefile
File metadata and controls
299 lines (259 loc) · 15.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# Aegis Stack CLI Development Makefile
# This Makefile is for developing the Aegis Stack CLI tool itself.
# Generated projects have their own Makefiles for application development.
# Run tests
test: ## Run tests
@uv run pytest
# Run linting
lint: ## Run linting with ruff
@uv run ruff check .
# Auto-fix linting issues
fix: ## Auto-fix linting and formatting issues
@uv run ruff check . --fix
@uv run ruff format .
# Format code only
format: ## Format code with ruff
@uv run ruff format .
# Run type checking
typecheck: ## Run type checking with mypy
@uv run mypy .
# Run all checks (lint + typecheck + test)
check: lint typecheck test ## Run all checks
# Install dependencies
install: ## Install dependencies with uv
uv sync --all-extras
# Clean up cache files
clean: ## Clean up cache files
@find . -type d -name "__pycache__" -exec rm -rf {} +
@find . -type f -name "*.pyc" -delete
# Serve documentation locally
docs-serve: ## Serve documentation locally with live reload on port 8001
@uv run mkdocs serve --dev-addr 0.0.0.0:8001
# Build documentation
docs-build: ## Build the static documentation site
@uv run mkdocs build
# CLI Development Commands
cli-test: ## Test CLI commands locally
@uv run python -m aegis --help
@echo "✅ CLI command working"
# ============================================================================
# REDIS DEVELOPMENT COMMANDS
# For experimenting with Redis/arq without generating new projects
# ============================================================================
redis-start: ## Start Redis container for arq experiments
@echo "🚀 Starting Redis for arq development..."
@docker run -d --name aegis-redis -p 6379:6379 --rm redis:7-alpine redis-server --maxmemory 256mb --maxmemory-policy allkeys-lru
@echo "✅ Redis running on localhost:6379"
@echo "💡 Use 'make redis-stop' to stop"
redis-stop: ## Stop Redis container
@echo "⏹️ Stopping Redis..."
@docker stop aegis-redis 2>/dev/null || echo "Redis container not running"
redis-cli: ## Connect to Redis CLI
@echo "🔧 Connecting to Redis CLI..."
@docker exec -it aegis-redis redis-cli
redis-logs: ## Show Redis logs
@echo "📋 Showing Redis logs..."
@docker logs -f aegis-redis
redis-stats: ## Show Redis memory and connection stats
@echo "📊 Redis stats..."
@docker exec -it aegis-redis redis-cli info memory
@echo ""
@docker exec -it aegis-redis redis-cli info clients
redis-reset: ## Reset Redis (clear all data)
@echo "🔄 Resetting Redis data..."
@docker exec -it aegis-redis redis-cli flushall
@echo "✅ Redis data cleared"
redis-queues: ## Show all arq queues and their depths
@echo "📋 arq Queue Status:"
@echo "===================="
@echo -n "default: "; docker exec -it aegis-redis redis-cli zcard arq:queue 2>/dev/null | tr -d '\r' || echo "0"; echo " jobs"
@echo ""
@echo "📊 Additional Queue Info:"
@echo -n "In Progress: "; docker exec -it aegis-redis redis-cli hlen arq:in-progress 2>/dev/null | tr -d '\r' || echo "0"
@echo -n "Results: "; docker exec -it aegis-redis redis-cli --raw eval "return #redis.call('keys', 'arq:result:*')" 0 2>/dev/null || echo "0"
redis-workers: ## Show active arq workers
@echo "👷 Active Workers:"
@echo "=================="
@docker exec -it aegis-redis redis-cli smembers arq:workers 2>/dev/null || echo "No active workers"
redis-failed: ## Show failed job count
@echo "❌ Failed Jobs:"
@echo "==============="
@docker exec -it aegis-redis redis-cli hlen arq:failed 2>/dev/null || echo "0"
redis-monitor: ## Monitor Redis commands in real-time
@echo "👀 Monitoring Redis commands (Ctrl+C to stop)..."
@docker exec -it aegis-redis redis-cli monitor
redis-info: ## Show comprehensive Redis info
@echo "ℹ️ Redis System Information:"
@echo "============================="
@docker exec -it aegis-redis redis-cli info server
@echo ""
@echo "📊 Memory Usage:"
@echo "================"
@docker exec -it aegis-redis redis-cli info memory
@echo ""
@echo "👥 Client Connections:"
@echo "======================"
@docker exec -it aegis-redis redis-cli info clients
# Show help
help: ## Show this help message
@echo "Available commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
# ============================================================================
# TEMPLATE TESTING TARGETS
# For rapid iteration on cookiecutter template changes
#
# These targets help with the development workflow when modifying the
# cookiecutter templates in aegis/templates/cookiecutter-aegis-project/
#
# Typical workflow:
# 1. Make changes to template files
# 2. Run 'make test-template-quick' for fast feedback
# 3. Run 'make test-template' for full validation
# 4. Run 'make clean-test-projects' to cleanup
# ============================================================================
test-template-quick: ## Quick template test - generate basic project without validation
@echo "🚀 Quick template test - generating basic project..."
@chmod -R +w ../test-basic-stack 2>/dev/null || true
@rm -rf ../test-basic-stack
@env -u VIRTUAL_ENV uv run aegis init test-basic-stack --output-dir .. --no-interactive --force --yes
@echo "📦 Setting up virtual environment and CLI..."
@cd ../test-basic-stack && chmod -R +w .venv 2>/dev/null || true && rm -rf .venv && env -u VIRTUAL_ENV uv sync --extra dev --extra docs
@cd ../test-basic-stack && env -u VIRTUAL_ENV uv pip install -e .
@echo "✅ Basic test project generated in ../test-basic-stack/"
@echo " CLI command 'test-basic-stack' is now available"
@echo " Run 'cd ../test-basic-stack && make check' to validate"
test-template: ## Full template test - generate project and run validation
@echo "🛡️ Full template test - generating and validating project..."
@chmod -R +w ../test-basic-stack 2>/dev/null || true
@rm -rf ../test-basic-stack
@env -u VIRTUAL_ENV uv run aegis init test-basic-stack --output-dir .. --no-interactive --force --yes
@echo "📦 Installing dependencies and CLI..."
@cd ../test-basic-stack && chmod -R +w .venv 2>/dev/null || true && rm -rf .venv && env -u VIRTUAL_ENV uv sync --extra dev --extra docs
@cd ../test-basic-stack && env -u VIRTUAL_ENV uv pip install -e .
@echo "🔍 Running validation checks..."
@cd ../test-basic-stack && env -u VIRTUAL_ENV make check
@echo "🧪 Testing CLI script installation..."
@cd ../test-basic-stack && env -u VIRTUAL_ENV uv run test-basic-stack --help >/dev/null && echo "✅ CLI script 'test-basic-stack --help' works" || echo "⚠️ CLI script test failed"
@cd ../test-basic-stack && env -u VIRTUAL_ENV uv run test-basic-stack health quick >/dev/null 2>&1 && echo "✅ CLI script 'test-basic-stack health quick' works" || echo "ℹ️ Health command test skipped (requires running backend)"
@echo "✅ Template test completed successfully!"
@echo " Test project available in ../test-basic-stack/"
@echo " CLI command 'test-basic-stack' is available"
test-template-with-components: ## Test template with scheduler component included
@echo "🧩 Component template test - generating project with scheduler..."
@chmod -R +w ../test-component-stack 2>/dev/null || true
@rm -rf ../test-component-stack
@env -u VIRTUAL_ENV uv run aegis init test-component-stack --components scheduler --output-dir .. --no-interactive --force --yes
@echo "📦 Installing dependencies and CLI..."
@cd ../test-component-stack && chmod -R +w .venv 2>/dev/null || true && rm -rf .venv && env -u VIRTUAL_ENV uv sync --extra dev --extra docs
@cd ../test-component-stack && env -u VIRTUAL_ENV uv pip install -e .
@echo "🔍 Running validation checks..."
@cd ../test-component-stack && env -u VIRTUAL_ENV make check
@echo "🧪 Testing CLI script installation..."
@cd ../test-component-stack && env -u VIRTUAL_ENV uv run test-component-stack --help >/dev/null && echo "✅ CLI script 'test-component-stack --help' works" || echo "⚠️ CLI script test failed"
@cd ../test-component-stack && env -u VIRTUAL_ENV uv run test-component-stack health quick >/dev/null 2>&1 && echo "✅ CLI script 'test-component-stack health quick' works" || echo "ℹ️ Health command test skipped (requires running backend)"
@echo "✅ Component template test completed successfully!"
@echo " Test project available in ../test-component-stack/"
@echo " CLI command 'test-component-stack' is available"
clean-test-projects: ## Remove all generated test project directories
@echo "🧹 Cleaning up test projects..."
@chmod -R +w ../test-basic-stack ../test-component-stack ../test-worker-stack ../test-database-stack ../test-full-stack 2>/dev/null || true
@rm -rf ../test-basic-stack ../test-component-stack ../test-worker-stack ../test-database-stack ../test-full-stack 2>/dev/null || true
@echo "✅ Test projects cleaned up"
# ============================================================================
# STACK MATRIX TESTING TARGETS
# For comprehensive testing of all component combinations
#
# These targets implement the Stack Generation Matrix Testing plan:
# 1. test-stacks: Test generation of all valid combinations
# 2. test-stacks-build: Test that all stacks build and pass checks
# 3. test-stacks-runtime: Test Docker runtime integration (future)
# 4. test-stacks-full: Complete matrix testing pipeline
# ============================================================================
test-stacks: ## Test all stack combinations generation (fast)
@echo "🧪 Testing all stack combination generation..."
@uv run pytest tests/cli/test_stack_generation.py -v --tb=short
@echo "✅ All stack combinations generate successfully!"
test-stacks-build: ## Test all stacks build and pass checks (slow)
@echo "🔨 Testing all stacks build and validation..."
@echo "⚠️ This is slow - testing dependency installation and code quality for all combinations"
@uv run pytest tests/cli/test_stack_validation.py -v -m "slow" --tb=short
@echo "✅ All stacks build and pass quality checks!"
test-stacks-runtime: ## Test all stacks runtime integration with Docker (future)
@echo "🐳 Runtime integration testing not yet implemented"
@echo "ℹ️ Will test Docker Compose startup and health checks for all combinations"
test-stacks-full: ## Full stack matrix testing pipeline (comprehensive but slow)
@echo "🌟 Running complete stack matrix testing pipeline..."
@echo "📋 Phase 1: Stack Generation Testing"
@make test-stacks
@echo ""
@echo "📋 Phase 2: Stack Build and Validation Testing"
@make test-stacks-build
@echo ""
@echo "📋 Phase 3: Stack Runtime Testing (skipped - not implemented)"
@echo "ℹ️ Runtime testing will be added in future iterations"
@echo ""
@echo "🎉 Complete stack matrix testing completed successfully!"
@echo " All component combinations can generate, build, and pass quality checks"
# Enhanced template testing with specific component combinations
test-template-database: ## Test template with database component
@echo "🗄️ Testing database component template..."
@chmod -R +w ../test-database-stack 2>/dev/null || true
@rm -rf ../test-database-stack
@env -u VIRTUAL_ENV uv run aegis init test-database-stack --components database --output-dir .. --no-interactive --force --yes
@echo "📦 Installing dependencies and CLI..."
@cd ../test-database-stack && chmod -R +w .venv 2>/dev/null || true && rm -rf .venv && env -u VIRTUAL_ENV uv sync --extra dev --extra docs
@cd ../test-database-stack && env -u VIRTUAL_ENV uv pip install -e .
@echo "🔍 Running validation checks..."
@cd ../test-database-stack && env -u VIRTUAL_ENV make check
@echo "🧪 Testing CLI script installation..."
@cd ../test-database-stack && env -u VIRTUAL_ENV uv run test-database-stack --help >/dev/null && echo "✅ CLI script 'test-database-stack --help' works" || echo "⚠️ CLI script test failed"
@cd ../test-database-stack && env -u VIRTUAL_ENV uv run test-database-stack health status --help >/dev/null && echo "✅ Health commands available" || echo "⚠️ Health command test failed"
@echo "✅ Database template test completed successfully!"
@echo " Test project available in ../test-database-stack/"
test-template-worker: ## Test template with worker component
@echo "🔧 Testing worker component template..."
@chmod -R +w ../test-worker-stack 2>/dev/null || true
@rm -rf ../test-worker-stack
@env -u VIRTUAL_ENV uv run aegis init test-worker-stack --components worker --output-dir .. --no-interactive --force --yes
@echo "📦 Installing dependencies and CLI..."
@cd ../test-worker-stack && chmod -R +w .venv 2>/dev/null || true && rm -rf .venv && env -u VIRTUAL_ENV uv sync --extra dev --extra docs
@cd ../test-worker-stack && env -u VIRTUAL_ENV uv pip install -e .
@echo "🔍 Running validation checks..."
@cd ../test-worker-stack && env -u VIRTUAL_ENV make check
@echo "🧪 Testing CLI script installation..."
@cd ../test-worker-stack && env -u VIRTUAL_ENV uv run test-worker-stack --help >/dev/null && echo "✅ CLI script 'test-worker-stack --help' works" || echo "⚠️ CLI script test failed"
@cd ../test-worker-stack && env -u VIRTUAL_ENV uv run test-worker-stack health status --help >/dev/null && echo "✅ Health commands available" || echo "⚠️ Health command test failed"
@echo "✅ Worker template test completed successfully!"
@echo " Test project available in ../test-worker-stack/"
test-template-full: ## Test template with all components (worker + scheduler + database)
@echo "🌟 Testing full component template..."
@chmod -R +w ../test-full-stack 2>/dev/null || true
@rm -rf ../test-full-stack
@env -u VIRTUAL_ENV uv run aegis init test-full-stack --components worker,scheduler,database --output-dir .. --no-interactive --force --yes
@echo "📦 Installing dependencies and CLI..."
@cd ../test-full-stack && chmod -R +w .venv 2>/dev/null || true && rm -rf .venv && env -u VIRTUAL_ENV uv sync --extra dev --extra docs
@cd ../test-full-stack && env -u VIRTUAL_ENV uv pip install -e .
@echo "🔍 Running validation checks..."
@cd ../test-full-stack && env -u VIRTUAL_ENV make check
@echo "🧪 Testing CLI script installation..."
@cd ../test-full-stack && env -u VIRTUAL_ENV uv run test-full-stack --help >/dev/null && echo "✅ CLI script 'test-full-stack --help' works" || echo "⚠️ CLI script test failed"
@cd ../test-full-stack && env -u VIRTUAL_ENV uv run test-full-stack health status --help >/dev/null && echo "✅ Health commands available" || echo "⚠️ Health command test failed"
@echo "✅ Full stack template test completed successfully!"
@echo " Test project available in ../test-full-stack/"
@echo " Includes: backend, frontend, worker queues, scheduler, Redis, database"
# Quick component testing for development workflow
test-component-quick: ## Quick test of specific component (set COMPONENT=worker|scheduler)
ifndef COMPONENT
@echo "❌ Usage: make test-component-quick COMPONENT=worker"
@echo " Available components: worker, scheduler"
@exit 1
endif
@echo "⚡ Quick testing $(COMPONENT) component..."
@chmod -R +w ../test-$(COMPONENT)-quick 2>/dev/null || true
@rm -rf ../test-$(COMPONENT)-quick
@env -u VIRTUAL_ENV uv run aegis init test-$(COMPONENT)-quick --components $(COMPONENT) --output-dir .. --no-interactive --force --yes
@echo "✅ $(COMPONENT) component generated successfully in ../test-$(COMPONENT)-quick/"
@echo " Run 'cd ../test-$(COMPONENT)-quick && make check' to validate"
.PHONY: test lint fix format typecheck check install clean docs-serve docs-build cli-test redis-start redis-stop redis-cli redis-logs redis-stats redis-reset redis-queues redis-workers redis-failed redis-monitor redis-info test-template-quick test-template test-template-with-components test-template-database test-template-worker test-template-full test-component-quick test-stacks test-stacks-build test-stacks-runtime test-stacks-full clean-test-projects help
# Default target
.DEFAULT_GOAL := help