A community based topic aggregation platform built on atproto
1.PHONY: help dev-up dev-down dev-logs dev-status dev-reset test e2e-test clean
2
3# Default target - show help
4.DEFAULT_GOAL := help
5
6# Colors for output
7CYAN := \033[36m
8RESET := \033[0m
9GREEN := \033[32m
10YELLOW := \033[33m
11
12# Load test database configuration from .env.dev
13include .env.dev
14export
15
16##@ General
17
18help: ## Show this help message
19 @echo ""
20 @echo "$(CYAN)Coves Development Commands$(RESET)"
21 @echo ""
22 @awk 'BEGIN {FS = ":.*##"; printf "Usage: make $(CYAN)<target>$(RESET)\n"} \
23 /^[a-zA-Z_-]+:.*?##/ { printf " $(CYAN)%-15s$(RESET) %s\n", $$1, $$2 } \
24 /^##@/ { printf "\n$(YELLOW)%s$(RESET)\n", substr($$0, 5) }' $(MAKEFILE_LIST)
25 @echo ""
26
27##@ Local Development (All-in-One)
28
29dev-up: ## Start PDS + PostgreSQL + Jetstream for local development
30 @echo "$(GREEN)Starting Coves development stack...$(RESET)"
31 @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile jetstream up -d postgres pds jetstream
32 @echo ""
33 @echo "$(GREEN)✓ Development stack started!$(RESET)"
34 @echo ""
35 @echo "Services available at:"
36 @echo " - PostgreSQL: localhost:5433"
37 @echo " - PDS (XRPC): http://localhost:3001"
38 @echo " - PDS Firehose: ws://localhost:3001/xrpc/com.atproto.sync.subscribeRepos"
39 @echo " - Jetstream: ws://localhost:6008/subscribe $(CYAN)(Read-Forward)$(RESET)"
40 @echo " - Jetstream Metrics: http://localhost:6009/metrics"
41 @echo ""
42 @echo "$(CYAN)Next steps:$(RESET)"
43 @echo " 1. Run: make run (starts AppView)"
44 @echo " 2. AppView will auto-index users from Jetstream"
45 @echo ""
46 @echo "Run 'make dev-logs' to view logs"
47
48dev-down: ## Stop all development services
49 @echo "$(YELLOW)Stopping Coves development stack...$(RESET)"
50 @docker-compose -f docker-compose.dev.yml --env-file .env.dev down
51 @echo "$(GREEN)✓ Development stack stopped$(RESET)"
52
53dev-logs: ## Tail logs from all development services
54 @docker-compose -f docker-compose.dev.yml --env-file .env.dev logs -f
55
56dev-status: ## Show status of all development containers
57 @echo "$(CYAN)Development Stack Status:$(RESET)"
58 @docker-compose -f docker-compose.dev.yml --env-file .env.dev ps
59
60dev-reset: ## Nuclear option - stop everything and remove all volumes
61 @echo "$(YELLOW)⚠️ WARNING: This will delete ALL data (PostgreSQL + PDS)!$(RESET)"
62 @read -p "Are you sure? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1
63 @echo "$(YELLOW)Stopping and removing containers and volumes...$(RESET)"
64 @docker-compose -f docker-compose.dev.yml --env-file .env.dev down -v
65 @echo "$(GREEN)✓ Reset complete - all data removed$(RESET)"
66 @echo "Run 'make dev-up' to start fresh"
67
68##@ Database Management
69
70db-shell: ## Open PostgreSQL shell for development database
71 @echo "$(CYAN)Connecting to development database...$(RESET)"
72 @docker exec -it coves-dev-postgres psql -U dev_user -d coves_dev
73
74db-migrate: ## Run database migrations
75 @echo "$(GREEN)Running database migrations...$(RESET)"
76 @goose -dir internal/db/migrations postgres "postgresql://dev_user:dev_password@localhost:5433/coves_dev?sslmode=disable" up
77 @echo "$(GREEN)✓ Migrations complete$(RESET)"
78
79db-migrate-down: ## Rollback last migration
80 @echo "$(YELLOW)Rolling back last migration...$(RESET)"
81 @goose -dir internal/db/migrations postgres "postgresql://dev_user:dev_password@localhost:5433/coves_dev?sslmode=disable" down
82 @echo "$(GREEN)✓ Rollback complete$(RESET)"
83
84db-reset: ## Reset database (delete all data and re-run migrations)
85 @echo "$(YELLOW)⚠️ WARNING: This will delete all database data!$(RESET)"
86 @read -p "Are you sure? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1
87 @echo "$(YELLOW)Resetting database...$(RESET)"
88 @docker-compose -f docker-compose.dev.yml --env-file .env.dev rm -sf postgres
89 @docker volume rm coves-dev-postgres-data || true
90 @docker-compose -f docker-compose.dev.yml --env-file .env.dev up -d postgres
91 @echo "Waiting for PostgreSQL to be ready..."
92 @sleep 3
93 @make db-migrate
94 @echo "$(GREEN)✓ Database reset complete$(RESET)"
95
96##@ Testing
97
98test: ## Run fast unit/integration tests (skips slow E2E tests)
99 @echo "$(GREEN)Starting test database...$(RESET)"
100 @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile test up -d postgres-test
101 @echo "Waiting for test database to be ready..."
102 @sleep 3
103 @echo "$(GREEN)Running migrations on test database...$(RESET)"
104 @goose -dir internal/db/migrations postgres "postgresql://$(POSTGRES_TEST_USER):$(POSTGRES_TEST_PASSWORD)@localhost:$(POSTGRES_TEST_PORT)/$(POSTGRES_TEST_DB)?sslmode=disable" up || true
105 @echo "$(GREEN)Running fast tests (use 'make e2e-test' for E2E tests)...$(RESET)"
106 @go test ./cmd/... ./internal/... ./tests/... -short -v
107 @echo "$(GREEN)✓ Tests complete$(RESET)"
108
109e2e-test: ## Run automated E2E tests (requires: make dev-up + make run in another terminal)
110 @echo "$(CYAN)========================================$(RESET)"
111 @echo "$(CYAN) E2E Test: Full User Signup Flow $(RESET)"
112 @echo "$(CYAN)========================================$(RESET)"
113 @echo ""
114 @echo "$(CYAN)Prerequisites:$(RESET)"
115 @echo " 1. Run 'make dev-up' (if not already running)"
116 @echo " 2. Run 'make run' in another terminal (AppView must be running)"
117 @echo ""
118 @echo "$(GREEN)Running E2E tests...$(RESET)"
119 @go test ./tests/e2e -run TestE2E_UserSignup -v
120 @echo ""
121 @echo "$(GREEN)✓ E2E tests complete!$(RESET)"
122
123test-db-reset: ## Reset test database
124 @echo "$(GREEN)Resetting test database...$(RESET)"
125 @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile test rm -sf postgres-test
126 @docker volume rm coves-test-postgres-data || true
127 @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile test up -d postgres-test
128 @echo "Waiting for PostgreSQL to be ready..."
129 @sleep 3
130 @goose -dir internal/db/migrations postgres "postgresql://$(POSTGRES_TEST_USER):$(POSTGRES_TEST_PASSWORD)@localhost:$(POSTGRES_TEST_PORT)/$(POSTGRES_TEST_DB)?sslmode=disable" up || true
131 @echo "$(GREEN)✓ Test database reset$(RESET)"
132
133test-db-stop: ## Stop test database
134 @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile test stop postgres-test
135 @echo "$(GREEN)✓ Test database stopped$(RESET)"
136
137##@ Code Quality
138
139lint: ## Run golangci-lint on the codebase
140 @echo "$(GREEN)Running linter...$(RESET)"
141 @golangci-lint run
142 @echo "$(GREEN)✓ Linting complete$(RESET)"
143
144lint-fix: ## Run golangci-lint and auto-fix issues
145 @echo "$(GREEN)Running linter with auto-fix...$(RESET)"
146 @golangci-lint run --fix
147 @echo "$(GREEN)✓ Linting complete$(RESET)"
148
149##@ Build & Run
150
151build: ## Build the Coves server
152 @echo "$(GREEN)Building Coves server...$(RESET)"
153 @go build -o server ./cmd/server
154 @echo "$(GREEN)✓ Build complete: ./server$(RESET)"
155
156run: ## Run the Coves server (requires database running)
157 @echo "$(GREEN)Starting Coves server...$(RESET)"
158 @go run ./cmd/server
159
160##@ Cleanup
161
162clean: ## Clean build artifacts and temporary files
163 @echo "$(YELLOW)Cleaning build artifacts...$(RESET)"
164 @rm -f server main validate-lexicon
165 @go clean
166 @echo "$(GREEN)✓ Clean complete$(RESET)"
167
168clean-all: clean ## Clean everything including Docker volumes (DESTRUCTIVE)
169 @echo "$(YELLOW)⚠️ WARNING: This will remove ALL Docker volumes!$(RESET)"
170 @read -p "Are you sure? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1
171 @make dev-reset
172 @echo "$(GREEN)✓ All clean$(RESET)"
173
174##@ Workflows (Common Tasks)
175
176fresh-start: ## Complete fresh start (reset everything, start clean)
177 @echo "$(CYAN)Starting fresh development environment...$(RESET)"
178 @make dev-reset || true
179 @sleep 2
180 @make dev-up
181 @sleep 3
182 @make db-migrate
183 @echo ""
184 @echo "$(GREEN)✓ Fresh environment ready!$(RESET)"
185 @make dev-status
186
187quick-restart: ## Quick restart of development stack (keeps data)
188 @make dev-down
189 @make dev-up
190
191##@ Utilities
192
193validate-lexicon: ## Validate all Lexicon schemas
194 @echo "$(GREEN)Validating Lexicon schemas...$(RESET)"
195 @./validate-lexicon
196 @echo "$(GREEN)✓ Lexicon validation complete$(RESET)"
197
198##@ Documentation
199
200docs: ## Open project documentation
201 @echo "$(CYAN)Project Documentation:$(RESET)"
202 @echo " - Setup Guide: docs/LOCAL_DEVELOPMENT.md"
203 @echo " - Project Structure: PROJECT_STRUCTURE.md"
204 @echo " - Build Guide: CLAUDE.md"
205 @echo " - atProto Guide: ATPROTO_GUIDE.md"
206 @echo " - PRD: PRD.md"