-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (81 loc) · 4.26 KB
/
Copy pathMakefile
File metadata and controls
101 lines (81 loc) · 4.26 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
# Makefile — PULSE monorepo workflows. Run `make help` for the target list.
#
# The integration/E2E targets mirror .github/workflows/ci.yml exactly (same
# compose files, ports, env, migration command) so local runs and CI cannot drift.
.DEFAULT_GOAL := help
.PHONY: help install dev up down logs build lint typecheck test \
test-integration test-e2e test-tour migrate migrate-generate clean verify ship
# ── CI-parity knobs (keep in sync with .github/workflows/ci.yml) ──────────────
# Pinned Node version — single source of truth is .nvmrc; exported so every
# `docker compose build`/`up --build` target builds the pinned version.
NODE_VERSION := $(shell cat .nvmrc 2>/dev/null)
export NODE_VERSION
COMPOSE := docker compose
E2E_FILES := -f docker-compose.yml -f docker-compose.e2e.yml
TEST_FILES := -f docker-compose.yml -f docker-compose.test.yml
FRONTEND_PORT ?= 18080
WEB_ORIGIN ?= http://localhost:18080
JWT_ACCESS_SECRET ?= e2e_local_access_secret_32chars_long
JWT_REFRESH_SECRET ?= e2e_local_refresh_secret_32chars_long
BACKEND_CONTAINER ?= tweeter-backend-1
TEST_DB_URL := postgresql://tweeter:tweeter@localhost:5433/tweeter_test
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN{FS=":.*?## "}{printf " \033[36m%-18s\033[0m %s\n",$$1,$$2}'
install: ## Install all workspace deps (root npm install — hoists frontend+backend)
npm install
dev: ## Run the full stack with hot reload (compose + override, foreground)
$(COMPOSE) up --build
up: ## Start the full stack detached (compose + override)
$(COMPOSE) up -d --build
down: ## Stop the stack
$(COMPOSE) down
logs: ## Tail stack logs
$(COMPOSE) logs -f
build: ## Build all packages (Turbo, cached)
npx turbo run build
lint: ## Lint all packages (Turbo)
npx turbo run lint
typecheck: ## Typecheck all packages (Turbo)
npx turbo run typecheck
test: ## Unit tests for all packages (Turbo)
npx turbo run test
test-integration: ## Backend integration tests (host-run vs dockerized db/redis on 5433/6380)
$(COMPOSE) $(TEST_FILES) up -d db redis
@echo "Waiting for Postgres to be healthy..."
@until $(COMPOSE) $(TEST_FILES) exec -T db pg_isready -U tweeter >/dev/null 2>&1; do sleep 1; done
-$(COMPOSE) $(TEST_FILES) exec -T db psql -U tweeter -d tweeter -c "CREATE DATABASE tweeter_test;" 2>/dev/null
cd backend && DATABASE_URL=$(TEST_DB_URL) npm run migration:run
cd backend && npm run test:integration
$(COMPOSE) $(TEST_FILES) down
test-e2e: ## Full dockerized Playwright E2E (mirrors the CI e2e job)
FRONTEND_PORT=$(FRONTEND_PORT) WEB_ORIGIN=$(WEB_ORIGIN) \
JWT_ACCESS_SECRET=$(JWT_ACCESS_SECRET) JWT_REFRESH_SECRET=$(JWT_REFRESH_SECRET) \
$(COMPOSE) $(E2E_FILES) up -d --build --wait
docker exec -w /app/backend $(BACKEND_CONTAINER) \
npx typeorm migration:run -d dist/infra/database/data-source.js
PLAYWRIGHT_BASE_URL=$(WEB_ORIGIN) npx playwright test
$(COMPOSE) $(E2E_FILES) down -v
test-tour: ## Manual UI walkthrough — drives every page/control via Playwright (NOT in CI)
FRONTEND_PORT=$(FRONTEND_PORT) WEB_ORIGIN=$(WEB_ORIGIN) \
JWT_ACCESS_SECRET=$(JWT_ACCESS_SECRET) JWT_REFRESH_SECRET=$(JWT_REFRESH_SECRET) \
$(COMPOSE) $(E2E_FILES) up -d --build --wait
docker exec -w /app/backend $(BACKEND_CONTAINER) \
npx typeorm migration:run -d dist/infra/database/data-source.js
PLAYWRIGHT_BASE_URL=$(WEB_ORIGIN) npx playwright test --config=playwright.tour.config.ts
@echo "Tour finished — stack left UP for inspection. Tear down with: make down"
migrate: ## Run TypeORM migrations against the local dev DB
cd backend && npm run migration:run
migrate-generate: ## Generate a migration: make migrate-generate NAME=AddFoo
cd backend && npm run migration:generate -- src/infra/database/migrations/$(NAME)
clean: ## Tear down volumes and remove dist/.turbo/node_modules
-$(COMPOSE) down -v
rm -rf .turbo node_modules \
frontend/dist frontend/.turbo frontend/node_modules \
backend/dist backend/.turbo backend/node_modules
verify: ## Pre-ship gate: lint + typecheck + unit + docker build + e2e
npx turbo run lint typecheck test
$(COMPOSE) build
$(MAKE) test-e2e
ship: verify ## Run the full verify gate (run before the Step 6 ship commit)
@echo "verify passed — safe to ship"