.PHONY: tier1-up tier1-down tier1-logs fe-unit e2e e2e-install e2e-fresh

# Two-phase: run the Gitea seed to completion FIRST so it writes the bot token /
# OAuth creds into generated/.env.tier1.generated, THEN create the backend/web —
# compose snapshots env_file at container-create time, so the backend must be
# created after the seed has populated it. The touch seeds an empty placeholder
# for compose's up-front env_file existence check on a clean checkout.
tier1-up:
	touch testing/generated/.env.tier1.generated
	docker compose -f testing/docker-compose.yml up --build -d gitea-seed
	docker compose -f testing/docker-compose.yml wait gitea-seed
	docker compose -f testing/docker-compose.yml up --build -d

tier1-down:
	touch testing/generated/.env.tier1.generated
	docker compose -f testing/docker-compose.yml down -v

tier1-logs:
	docker compose -f testing/docker-compose.yml logs -f

fe-unit:
	cd frontend && npm run test:run

e2e-install:
	cd e2e && npm ci && npx playwright install chromium

e2e:
	cd e2e && BASE_URL=$${BASE_URL:-http://localhost:8080} MAILSINK_URL=$${MAILSINK_URL:-http://localhost:8025} npm run e2e

# Canonical run: the metadata specs mutate the seeded corpus (edit/bulk write
# real commits), so they assume a freshly-seeded stack. This brings the stack
# down, back up (re-seeds), and runs the suite once — the shape CI uses.
e2e-fresh: tier1-down tier1-up e2e
