-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.e2e.yml
More file actions
90 lines (85 loc) · 3.82 KB
/
Copy pathdocker-compose.e2e.yml
File metadata and controls
90 lines (85 loc) · 3.82 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
# Own Compose project. Without this, the project name is derived from the
# directory and collides with docker-compose.yml — and since both declare a
# service called `db`, starting the e2e stack REPLACED the running dev database
# container with one mounting pgdata_e2e. The dev data survived in its volume,
# but the app pointed at an empty database until `docker compose up -d db` was
# run again, which reads as "login suddenly broken". The `down -v` in the
# pre-push cleanup was likewise scoped to the shared project.
name: magicaibuilder-e2e
services:
db:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_DB: magicaibuilder
POSTGRES_USER: magic
POSTGRES_PASSWORD: magic_dev_only
ports:
- "5433:5432"
volumes:
- pgdata_e2e:/var/lib/postgresql/data
healthcheck:
# -h 127.0.0.1 forces the probe over TCP. Without it pg_isready uses the
# Unix socket, which the temporary bootstrap server postgres runs during
# initdb happily answers — so on a cold volume (every gate run: the
# cleanup is `down -v`) the check could pass seconds before the real
# server bound TCP, and Prisma's `db:5432` connect died with P1001
# before a single test executed.
test: ["CMD-SHELL", "pg_isready -h 127.0.0.1 -U magic -d magicaibuilder"]
interval: 5s
timeout: 5s
retries: 20
e2e:
build:
context: .
dockerfile: Dockerfile.playwright
# Without these, the report and traces are written inside the container and
# destroyed by the `down -v` in the pre-push cleanup. What stayed on the
# host was whatever an older local run had left there, so
# "Check playwright-report/ for details" pointed at a stale report
# describing a different run — which is why the intermittent failure went
# undiagnosed for so long.
volumes:
- ./playwright-report:/app/playwright-report
- ./test-results:/app/test-results
depends_on:
db:
condition: service_healthy
environment:
# Prisma / app
DATABASE_URL: "postgresql://magic:magic_dev_only@db:5432/magicaibuilder"
NEXT_PUBLIC_APP_URL: "http://localhost:3000"
AUTH_SECRET: "playwright-test-secret"
# NextAuth providers are irrelevant in PLAYWRIGHT_TEST mode, but keep them defined to avoid runtime surprises
GOOGLE_CLIENT_ID: "playwright"
GOOGLE_CLIENT_SECRET: "playwright"
# Ensure auth is bypassed for E2E
PLAYWRIGHT_TEST: "1"
# Default to the FULL suite. `:-` would also swallow an explicit empty
# value, so use `-`: setting PLAYWRIGHT_SPEC="" deliberately means "all
# specs", while naming a file narrows the run to it.
#
# This was previously a hardcoded single spec with no interpolation, so
# host-shell overrides were silently ignored and the pre-push gate ran
# 1 of 8 spec files while reporting a full green.
PLAYWRIGHT_SPEC: "${PLAYWRIGHT_SPEC-}"
# Excluded from the blocking gate by default:
# @external — depends on third-party services (e.g. the live Moxfield
# API); a deck going private there once turned the gate red with no
# code change on our side.
# @perf — asserts wall-clock latency against `next dev`, which compiles
# routes on demand; the same endpoint measured 41ms alone and 5163ms
# under full-suite contention.
# Set this to "" to run them deliberately.
PLAYWRIGHT_GREP_INVERT: "${PLAYWRIGHT_GREP_INVERT-@external|@perf}"
command: >
sh -lc "
pnpm exec prisma migrate deploy &&
if [ -n \"$${PLAYWRIGHT_GREP_INVERT}\" ]; then
pnpm exec playwright test $${PLAYWRIGHT_SPEC} --grep-invert \"$${PLAYWRIGHT_GREP_INVERT}\"
else
pnpm exec playwright test $${PLAYWRIGHT_SPEC}
fi
"
volumes:
pgdata_e2e: