-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
177 lines (143 loc) · 6.41 KB
/
Makefile
File metadata and controls
177 lines (143 loc) · 6.41 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
# Solid Fortnight - Management Makefile
# Load environment variables if .env exists
ifneq (,$(wildcard ./.env))
include .env
export
endif
# --- Variables ---
BINARY_DIR=bin
DOCKER_COMPOSE=docker compose
DOCKER_COMPOSE_FILE=deployments/docker-compose.yml
DOCKER_COMPOSE_TEST=deployments/docker-compose.test.yml
# Default values for local development if not in .env
POSTGRES_HOST ?= localhost
POSTGRES_PORT ?= 5432
DB_USER ?= postgres
DB_PASSWORD ?= password
DB_NAME ?= solid_fortnight
REDIS_ADDR ?= localhost:6379
# --- Colors ---
BLUE := \033[0;34m
GREEN := \033[0;32m
CYAN := \033[0;36m
BOLD := \033[1m
MAGENTA := \033[0;35m
NC := \033[0m # No Color
.PHONY: help
help: ## Display this help screen
@echo ""
@echo "$(BOLD)Solid Fortnight - Available Commands:$(NC)"
@echo ""
@cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | awk 'BEGIN {FS = ":.*?## "}; {printf "$(CYAN)%-25s$(NC) %s\n", $$1, $$2}'
@echo ""
# ====================================================================================
# DOCKER & INFRASTRUCTURE
# ====================================================================================
.PHONY: db-up db-down status logs
db-up: ## Start PostgreSQL and Redis containers
@echo "$(BLUE)Starting PostgreSQL and Redis...$(NC)"
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) up -d postgres redis
@./scripts/wait-for-db.sh deployments-postgres-1 deployments-redis-1
db-down: ## Stop PostgreSQL and Redis containers
@echo "$(BLUE)Stopping PostgreSQL and Redis...$(NC)"
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) stop postgres redis
start-all: ## Start the entire stack in Docker
@echo "$(GREEN)Starting the entire application with Docker Compose...$(NC)"
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) up -d --build
stop-all: ## Stop all services and containers
@echo "$(BLUE)Stopping the entire application...$(NC)"
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) down
tilt-up: ## Start the entire stack with Tilt (recommended for development)
@echo "$(GREEN)Starting the application with Tilt...$(NC)"
@tilt up
status: ## Show status of all containers
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) ps
logs: ## Follow logs of all containers
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) logs -f
clean: ## Remove build artifacts and prune Docker
@echo "$(BLUE)Cleaning up...$(NC)"
@rm -rf $(BINARY_DIR)
@docker system prune -f
# ====================================================================================
# DEVELOPMENT (Local Go Execution)
# ====================================================================================
.PHONY: run-mgmt run-eval run-stream run-analytics run-gateway run-ui
run-mgmt: ## Run Management service locally
@echo "$(GREEN)Running Management service...$(NC)"
@go run apps/management/main.go
run-eval: ## Run Evaluator service locally
@echo "$(GREEN)Running Evaluator service...$(NC)"
@go run apps/evaluator/main.go
run-stream: ## Run Streamer service locally
@echo "$(GREEN)Running Streamer service...$(NC)"
@go run apps/streamer/main.go
run-analytics: ## Run Analytics service locally
@echo "$(GREEN)Running Analytics service...$(NC)"
@go run apps/analytics/main.go
run-gateway: ## Run API Gateway locally
@echo "$(GREEN)Running API Gateway...$(NC)"
@go run apps/gateway/main.go
run-ui: ## Run Admin Dashboard locally
@echo "$(GREEN)Starting Admin Dashboard...$(NC)"
@cd cmd/dashboard && bun run dev
# ====================================================================================
# TESTING
# ====================================================================================
.PHONY: test test-integration test-e2e test-ui
test: ## Run all unit tests
@echo "$(CYAN)Running all unit tests...$(NC)"
@go test ./apps/analytics/... ./apps/evaluator/... ./apps/gateway/... ./apps/management/... ./apps/streamer/... ./internal/config/... ./internal/engine/... ./internal/health/... ./internal/logging/... ./internal/metrics/... ./internal/protocol/... ./internal/storage/...
test-db-up:
@echo "$(BLUE)Setting up test database...$(NC)"
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_TEST) up -d postgres-test redis-test
@./scripts/wait-for-db.sh deployments-postgres-test-1 deployments-redis-test-1
test-integration: test-db-up ## Run all backend integration tests
@echo "$(MAGENTA)Running integration tests...$(NC)"
@JWT_SECRET=test_secret \
POSTGRES_HOST=localhost POSTGRES_PORT=5433 DB_NAME=solid_fortnight_test \
DB_USER=testuser DB_PASSWORD=testpassword REDIS_ADDR=localhost:6380 \
go test -v -p 1 -tags integration ./apps/management/handlers ./apps/evaluator/handlers ./apps/streamer ./apps/analytics/handlers
@$(MAKE) test-db-down
test-db-down:
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_TEST) down -v
test-e2e: ## Run Playwright end-to-end tests
@echo "$(MAGENTA)Running E2E integration tests...$(NC)"
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_TEST) up -d --build
@echo "Waiting for stack to be ready..."
@sleep 20
@cd cmd/dashboard && bunx playwright test
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_TEST) down -v
test-ui: ## Run dashboard unit tests
@echo "$(CYAN)Running UI unit tests...$(NC)"
@cd cmd/dashboard && bun run test --run
# ====================================================================================
# QUALITY & UTILS
# ====================================================================================
.PHONY: lint tidy-all
lint: ## Run golangci-lint on all modules
@echo "$(CYAN)Running linters...$(NC)"
@for dir in $$(find . -name "go.mod" -not -path "*/node_modules/*" -exec dirname {} \;); do \
echo "Linting $$dir..."; \
golangci-lint run --config $(shell pwd)/.golangci.yml --path-prefix $$dir ./$$dir/... || exit 1; \
done
tidy-all: ## Run go mod tidy in all Go modules and sync workspace
@echo "$(CYAN)Tidying all Go modules...$(NC)"
@find . -name "go.mod" -not -path "*/node_modules/*" -execdir go mod tidy \;
@if [ -f go.work ]; then \
echo "$(CYAN)Syncing workspace...$(NC)"; \
go work sync; \
fi
# ====================================================================================
# SETUP
# ====================================================================================
.PHONY: setup setup-colima
setup: ## Initial project setup (.env, tools)
@if [ ! -f .env ]; then \
cp .env.example .env; \
echo "$(GREEN).env file created.$(NC)"; \
fi
@echo "$(BLUE)Ready! Type 'make help' to see all commands.$(NC)"
setup-colima: ## Configure Colima (MacOS)
@echo "$(BLUE)Configuring Colima...$(NC)"
@colima stop || true
@colima start --cpu 4 --memory 8