-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
167 lines (133 loc) · 5.2 KB
/
Makefile
File metadata and controls
167 lines (133 loc) · 5.2 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
# Makefile for {{PROJECT_NAME}}
# Run `make help` to see available commands
.PHONY: help install dev test test-e2e lint build clean
DOCKER_COMPOSE := docker-compose
help:
@echo "Available commands (see CONTRIBUTING.md for when to use make vs raw commands):"
@echo ""
@echo " make install - Install all dependencies"
@echo " make dev - Start development environment"
@echo " make test - Run all tests"
@echo " make test-e2e - Run E2E tests with server lifecycle"
@echo " make lint - Run linters"
@echo " make build - Build for production"
@echo " make clean - Clean up containers and volumes"
@echo ""
@echo "Backend:"
@echo " make install-backend / test-backend / lint-backend / format-backend"
@echo " make migrate - Run migrations"
@echo " make migration - Create new migration"
@echo ""
@echo "Frontend:"
@echo " make install-frontend / test-frontend / lint-frontend"
@echo ""
@echo "E2E:"
@echo " make test-e2e - Full browser tests with server lifecycle"
@echo ""
@echo "Infrastructure:"
@echo " make cdk-diff-preprod / cdk-deploy-preprod"
@echo " make cdk-diff-prod / cdk-deploy-prod"
# ============================================================================
# Full Stack
# ============================================================================
install: install-backend install-frontend
dev:
$(DOCKER_COMPOSE) up -d
stop:
$(DOCKER_COMPOSE) down
clean:
$(DOCKER_COMPOSE) down -v
rm -rf backend/__pycache__ backend/.pytest_cache
rm -rf frontend/node_modules frontend/dist
test: test-backend test-frontend
lint: lint-backend lint-frontend
build: build-backend build-frontend
# ============================================================================
# Backend
# ============================================================================
install-backend:
cd backend && pip install -r requirements.txt
test-backend:
cd backend && pytest tests/ -v
test-backend-ci:
cd backend && pytest tests/ -v --cov=app --cov-report=xml --cov-fail-under=70
lint-backend:
cd backend && black --check app tests
cd backend && isort --check-only app tests
cd backend && mypy app
format-backend:
cd backend && black app tests
cd backend && isort app tests
migrate:
cd backend && alembic upgrade head
migration:
@read -p "Migration message: " msg; \
cd backend && alembic revision --autogenerate -m "$$msg"
build-backend:
docker build -t app-backend ./backend
# ============================================================================
# Frontend
# ============================================================================
install-frontend:
cd frontend && npm install
test-frontend:
cd frontend && npm run test
test-frontend-ci:
cd frontend && npm run lint && npm run typecheck && npm run test -- --coverage
lint-frontend:
cd frontend && npm run lint
build-frontend:
cd frontend && npm run build
# ============================================================================
# E2E Tests
# ============================================================================
test-browser-install:
cd frontend && npx playwright install --with-deps chromium
test-e2e:
@echo "=============================================="
@echo "E2E Integration Tests"
@echo "=============================================="
@# Clean up any existing servers
@pkill -f "uvicorn app.main:app --port 8000" 2>/dev/null || true
@pkill -f "vite.*3000" 2>/dev/null || true
@sleep 1
@# Ensure database is running
@$(DOCKER_COMPOSE) up db -d
@sleep 3
@# Run migrations
@cd backend && DATABASE_URL="postgresql://admin:secret@localhost:5432/appdb" \
alembic upgrade head 2>/dev/null || true
@# Start backend with E2E test mode
@cd backend && DATABASE_URL="postgresql://admin:secret@localhost:5432/appdb" \
E2E_TEST_MODE=true \
nohup uvicorn app.main:app --port 8000 > /tmp/e2e-backend.log 2>&1 & echo $$! > /tmp/e2e-backend.pid
@echo "Backend starting (PID: $$(cat /tmp/e2e-backend.pid))..."
@sleep 3
@# Start frontend
@cd frontend && nohup npm run dev > /tmp/e2e-frontend.log 2>&1 & echo $$! > /tmp/e2e-frontend.pid
@echo "Frontend starting (PID: $$(cat /tmp/e2e-frontend.pid))..."
@sleep 5
@# Run Playwright tests
@echo "Running Playwright tests..."
@cd frontend && npx playwright test --reporter=list; \
TEST_EXIT=$$?; \
echo ""; \
echo "Test artifacts:"; \
find frontend/test-results -name "*.webm" 2>/dev/null | head -5 || echo " (none)"; \
echo ""; \
# Stop servers
kill $$(cat /tmp/e2e-backend.pid) 2>/dev/null || true; \
kill $$(cat /tmp/e2e-frontend.pid) 2>/dev/null || true; \
rm -f /tmp/e2e-backend.pid /tmp/e2e-frontend.pid; \
exit $$TEST_EXIT
# ============================================================================
# Infrastructure
# ============================================================================
cdk-diff-preprod:
cd infrastructure && AWS_PROFILE=app-preprod npx cdk diff --all -c environment=preprod
cdk-deploy-preprod:
cd infrastructure && AWS_PROFILE=app-preprod npx cdk deploy --all -c environment=preprod
cdk-diff-prod:
cd infrastructure && AWS_PROFILE=app-prod npx cdk diff --all -c environment=prod
cdk-deploy-prod:
cd infrastructure && AWS_PROFILE=app-prod npx cdk deploy --all -c environment=prod