Something went wrong. Try again.
A community based topic aggregation platform built on atproto
Something went wrong. Try again.
coves Makefile
11 kB · 261 lines
Makefile
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262.PHONY: help dev-up dev-down dev-logs dev-status dev-reset test e2e-test clean
# Default target - show help.DEFAULT_GOAL := help
# Colors for outputCYAN := \033[36mRESET := \033[0mGREEN := \033[32mYELLOW := \033[33m
# Load test database configuration from .env.devinclude .env.devexport
##@ General
help: ## Show this help message @echo "" @echo "$(CYAN)Coves Development Commands$(RESET)" @echo "" @awk 'BEGIN {FS = ":.*##"; printf "Usage: make $(CYAN)<target>$(RESET)\n"} \ /^[a-zA-Z_-]+:.*?##/ { printf " $(CYAN)%-15s$(RESET) %s\n", $$1, $$2 } \ /^##@/ { printf "\n$(YELLOW)%s$(RESET)\n", substr($$0, 5) }' $(MAKEFILE_LIST) @echo ""
##@ Local Development (All-in-One)
dev-up: ## Start PDS + PostgreSQL + Jetstream + PLC Directory for local development @echo "$(GREEN)Starting Coves development stack...$(RESET)" @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile jetstream --profile plc up -d postgres postgres-plc plc-directory pds jetstream @echo "" @echo "$(GREEN)✓ Development stack started!$(RESET)" @echo "" @echo "Services available at:" @echo " - PostgreSQL: localhost:5435" @echo " - PDS (XRPC): http://localhost:3001" @echo " - PDS Firehose: ws://localhost:3001/xrpc/com.atproto.sync.subscribeRepos" @echo " - Jetstream: ws://localhost:6008/subscribe $(CYAN)(Read-Forward)$(RESET)" @echo " - Jetstream Metrics: http://localhost:6009/metrics" @echo " - PLC Directory: http://localhost:3002 $(CYAN)(Local DID registry)$(RESET)" @echo "" @echo "$(CYAN)Next steps:$(RESET)" @echo " 1. Run: make run (starts AppView)" @echo " 2. AppView will auto-index users from Jetstream" @echo "" @echo "$(CYAN)Note:$(RESET) Using local PLC directory - DIDs registered locally (won't pollute plc.directory)" @echo "Run 'make dev-logs' to view logs"
dev-down: ## Stop all development services @echo "$(YELLOW)Stopping Coves development stack...$(RESET)" @docker-compose -f docker-compose.dev.yml --env-file .env.dev down @echo "$(GREEN)✓ Development stack stopped$(RESET)"
dev-logs: ## Tail logs from all development services @docker-compose -f docker-compose.dev.yml --env-file .env.dev logs -f
dev-status: ## Show status of all development containers @echo "$(CYAN)Development Stack Status:$(RESET)" @docker-compose -f docker-compose.dev.yml --env-file .env.dev ps
dev-reset: ## Nuclear option - stop everything and remove all volumes @echo "$(YELLOW)⚠️ WARNING: This will delete ALL data (PostgreSQL + PDS)!$(RESET)" @read -p "Are you sure? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1 @echo "$(YELLOW)Stopping and removing containers and volumes...$(RESET)" @docker-compose -f docker-compose.dev.yml --env-file .env.dev down -v @echo "$(GREEN)✓ Reset complete - all data removed$(RESET)" @echo "Run 'make dev-up' to start fresh"
##@ Database Management
db-shell: ## Open PostgreSQL shell for development database @echo "$(CYAN)Connecting to development database...$(RESET)" @docker exec -it coves-dev-postgres psql -U dev_user -d coves_dev
db-migrate: ## Run database migrations @echo "$(GREEN)Running database migrations...$(RESET)" @goose -dir internal/db/migrations postgres "postgresql://dev_user:dev_password@localhost:5433/coves_dev?sslmode=disable" up @echo "$(GREEN)✓ Migrations complete$(RESET)"
db-migrate-down: ## Rollback last migration @echo "$(YELLOW)Rolling back last migration...$(RESET)" @goose -dir internal/db/migrations postgres "postgresql://dev_user:dev_password@localhost:5433/coves_dev?sslmode=disable" down @echo "$(GREEN)✓ Rollback complete$(RESET)"
db-reset: ## Reset database (delete all data and re-run migrations) @echo "$(YELLOW)⚠️ WARNING: This will delete all database data!$(RESET)" @read -p "Are you sure? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1 @echo "$(YELLOW)Resetting database...$(RESET)" @docker-compose -f docker-compose.dev.yml --env-file .env.dev rm -sf postgres @docker volume rm coves-dev-postgres-data || true @docker-compose -f docker-compose.dev.yml --env-file .env.dev up -d postgres @echo "Waiting for PostgreSQL to be ready..." @sleep 3 @make db-migrate @echo "$(GREEN)✓ Database reset complete$(RESET)"
##@ Testing
test: ## Run fast unit/integration tests (skips slow E2E tests) @echo "$(GREEN)Starting test database...$(RESET)" @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile test up -d postgres-test @echo "Waiting for test database to be ready..." @sleep 3 @echo "$(GREEN)Running migrations on test database...$(RESET)" @goose -dir internal/db/migrations postgres "postgresql://$(POSTGRES_TEST_USER):$(POSTGRES_TEST_PASSWORD)@localhost:$(POSTGRES_TEST_PORT)/$(POSTGRES_TEST_DB)?sslmode=disable" up || true @echo "$(GREEN)Running fast tests (use 'make e2e-test' for E2E tests)...$(RESET)" @go test ./cmd/... ./internal/... ./tests/... -short -v @echo "$(GREEN)✓ Tests complete$(RESET)"
e2e-test: ## Run automated E2E tests (requires: make dev-up + make run in another terminal) @echo "$(CYAN)========================================$(RESET)" @echo "$(CYAN) E2E Test: Full User Signup Flow $(RESET)" @echo "$(CYAN)========================================$(RESET)" @echo "" @echo "$(CYAN)Prerequisites:$(RESET)" @echo " 1. Run 'make dev-up' (starts PDS + Jetstream)" @echo " 2. Run 'make run' in another terminal (AppView must be running)" @echo "" @echo "$(GREEN)Running E2E tests...$(RESET)" @go test ./tests/e2e -run TestE2E_UserSignup -v @echo "" @echo "$(GREEN)✓ E2E tests complete!$(RESET)"
e2e-vote-test: ## Run vote E2E tests (requires: make dev-up) @echo "$(CYAN)========================================$(RESET)" @echo "$(CYAN) E2E Test: Vote System $(RESET)" @echo "$(CYAN)========================================$(RESET)" @echo "" @echo "$(CYAN)Prerequisites:$(RESET)" @echo " 1. Run 'make dev-up' (starts PDS + Jetstream + PostgreSQL)" @echo " 2. Test database will be used (port 5434)" @echo "" @echo "$(GREEN)Running vote E2E tests...$(RESET)" @echo "" @echo "$(CYAN)Running simulated E2E test (fast)...$(RESET)" @go test ./tests/integration -run TestVote_E2E_WithJetstream -v @echo "" @echo "$(CYAN)Running live PDS E2E test (requires PDS + Jetstream)...$(RESET)" @go test ./tests/integration -run TestVote_E2E_LivePDS -v || echo "$(YELLOW)Live PDS test skipped (run 'make dev-up' first)$(RESET)" @echo "" @echo "$(GREEN)✓ Vote E2E tests complete!$(RESET)"
test-db-reset: ## Reset test database @echo "$(GREEN)Resetting test database...$(RESET)" @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile test rm -sf postgres-test @docker volume rm coves-test-postgres-data || true @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile test up -d postgres-test @echo "Waiting for PostgreSQL to be ready..." @sleep 3 @goose -dir internal/db/migrations postgres "postgresql://$(POSTGRES_TEST_USER):$(POSTGRES_TEST_PASSWORD)@localhost:$(POSTGRES_TEST_PORT)/$(POSTGRES_TEST_DB)?sslmode=disable" up || true @echo "$(GREEN)✓ Test database reset$(RESET)"
test-db-stop: ## Stop test database @docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile test stop postgres-test @echo "$(GREEN)✓ Test database stopped$(RESET)"
##@ Code Quality
fmt: ## Format all Go code with gofmt @echo "$(GREEN)Formatting Go code...$(RESET)" @gofmt -w ./cmd ./internal ./tests @echo "$(GREEN)✓ Formatting complete$(RESET)"
fmt-check: ## Check if Go code is properly formatted @echo "$(GREEN)Checking code formatting...$(RESET)" @unformatted=$$(gofmt -l ./cmd ./internal ./tests); \ if [ -n "$$unformatted" ]; then \ echo "$(RED)✗ The following files are not formatted:$(RESET)"; \ echo "$$unformatted"; \ echo "$(YELLOW)Run 'make fmt' to fix$(RESET)"; \ exit 1; \ fi @echo "$(GREEN)✓ All files are properly formatted$(RESET)"
lint: fmt-check ## Run golangci-lint on the codebase (includes format check) @echo "$(GREEN)Running linter...$(RESET)" @golangci-lint run ./cmd/... ./internal/... ./tests/... @echo "$(GREEN)✓ Linting complete$(RESET)"
lint-fix: ## Run golangci-lint and auto-fix issues @echo "$(GREEN)Running linter with auto-fix...$(RESET)" @golangci-lint run --fix ./cmd/... ./internal/... ./tests/... @gofmt -w ./cmd ./internal ./tests @echo "$(GREEN)✓ Linting complete$(RESET)"
##@ Build & Run
build: ## Build the Coves server @echo "$(GREEN)Building Coves server...$(RESET)" @go build -o server ./cmd/server @echo "$(GREEN)✓ Build complete: ./server$(RESET)"
run: ## Run the Coves server with dev environment (requires database running) @./scripts/dev-run.sh
##@ Cleanup
clean: ## Clean build artifacts and temporary files @echo "$(YELLOW)Cleaning build artifacts...$(RESET)" @rm -f server main validate-lexicon @go clean @echo "$(GREEN)✓ Clean complete$(RESET)"
clean-all: clean ## Clean everything including Docker volumes (DESTRUCTIVE) @echo "$(YELLOW)⚠️ WARNING: This will remove ALL Docker volumes!$(RESET)" @read -p "Are you sure? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1 @make dev-reset @echo "$(GREEN)✓ All clean$(RESET)"
##@ Workflows (Common Tasks)
fresh-start: ## Complete fresh start (reset everything, start clean) @echo "$(CYAN)Starting fresh development environment...$(RESET)" @make dev-reset || true @sleep 2 @make dev-up @sleep 3 @make db-migrate @echo "" @echo "$(GREEN)✓ Fresh environment ready!$(RESET)" @make dev-status
quick-restart: ## Quick restart of development stack (keeps data) @make dev-down @make dev-up
##@ Mobile Testing
mobile-setup: ## Setup Android port forwarding for USB-connected devices (recommended) @echo "$(CYAN)Setting up Android mobile testing environment...$(RESET)" @./scripts/setup-mobile-ports.sh
mobile-reset: ## Remove all Android port forwarding @echo "$(YELLOW)Removing Android port forwarding...$(RESET)" @adb reverse --remove-all || echo "$(YELLOW)No device connected$(RESET)" @echo "$(GREEN)✓ Port forwarding removed$(RESET)"
ngrok-up: ## Start ngrok tunnels (for iOS or WiFi testing - requires paid plan for 3 tunnels) @echo "$(GREEN)Starting ngrok tunnels for mobile testing...$(RESET)" @./scripts/start-ngrok.sh
ngrok-down: ## Stop all ngrok tunnels @./scripts/stop-ngrok.sh
##@ Utilities
validate-lexicon: ## Validate all Lexicon schemas @echo "$(GREEN)Validating Lexicon schemas...$(RESET)" @./validate-lexicon @echo "$(GREEN)✓ Lexicon validation complete$(RESET)"
##@ Documentation
docs: ## Open project documentation @echo "$(CYAN)Project Documentation:$(RESET)" @echo " - Setup Guide: docs/LOCAL_DEVELOPMENT.md" @echo " - Project Structure: PROJECT_STRUCTURE.md" @echo " - Build Guide: CLAUDE.md" @echo " - atProto Guide: ATPROTO_GUIDE.md" @echo " - PRD: PRD.md"