-
-
Notifications
You must be signed in to change notification settings - Fork 459
Expand file tree
/
Copy pathmise.toml
More file actions
132 lines (112 loc) · 4.94 KB
/
Copy pathmise.toml
File metadata and controls
132 lines (112 loc) · 4.94 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
[tools]
elixir = "1.19.5-otp-28"
erlang = "28.5.0.4"
node = "24"
supabase = "2.105.0"
"npm:@supabase/pg-delta" = "1.0.0-alpha.42"
[env]
API_JWT_SECRET = "dev"
DB_ENC_KEY = "1234567890123456"
METRICS_JWT_SECRET = "dev"
DASHBOARD_USER = "admin"
DASHBOARD_PASSWORD = "admin"
[tasks.dev]
description = "Start the dev server"
run = "iex --name ${NAME}@127.0.0.1 --cookie cookie -S mix phx.server"
env = { NAME = "pink", PORT = "4000", REGION = "us-east-1", GEN_RPC_TCP_SERVER_PORT = "5369", GEN_RPC_TCP_CLIENT_PORT = "5469" }
[tasks.dev-orange]
description = "Start another dev server (orange)"
run = "iex --name ${NAME}@127.0.0.1 --cookie cookie -S mix phx.server"
env = { NAME = "orange", PORT = "4001", REGION = "eu-west-1", GEN_RPC_TCP_SERVER_PORT = "5469", GEN_RPC_TCP_CLIENT_PORT = "5369" }
[tasks.db-start]
description = "Start all dev databases"
run = "docker compose -f compose.dbs.yml up -d --wait"
[tasks.db-stop]
description = "Stop all dev databases"
run = "docker compose -f compose.dbs.yml stop"
[tasks.db-rm]
description = "Remove all dev databases"
run = "docker compose -f compose.dbs.yml rm -sf"
[tasks.realtime-start]
description = "Start realtime server and dev databases"
run = "docker compose up"
[tasks.realtime-stop]
description = "Stop realtime server and dev databases"
run = "docker compose stop"
[tasks.realtime-rm]
description = "Remove realtime server and dev databases"
run = "docker compose rm -sf"
[tasks.realtime-rebuild]
description = "Rebuild realtime server and dev databases"
run = "docker compose down --remove-orphans && docker compose build"
[tasks.test-start]
description = "Start test services"
run = "docker compose -f compose.tests.yml up"
[tasks.test-stop]
description = "Stop test services"
run = "docker compose -f compose.tests.yml stop"
[tasks.test-rm]
description = "Remove test services"
run = "docker compose -f compose.tests.yml rm -sf"
[tasks.e2e]
description = "Run e2e tests locally. Starts supabase if needed. Pass --url http://127.0.0.1:4000 to test against the local dev server."
dir = "test/e2e"
run = """
supabase start
eval "$(supabase status --output env)"
bun run realtime-check.ts --env local \
--publishable-key "$PUBLISHABLE_KEY" \
--secret-key "$SECRET_KEY" \
--db-url "postgresql://postgres:postgres@127.0.0.1:54322/postgres" \
"$@"
"""
[tasks.e2e-local]
description = "Run e2e tests against a locally-built realtime image (carries unreleased migrations). Builds the repo, swaps it in for supabase's stock realtime, then runs the suite. e.g. mise run e2e-local -- --test postgres-changes-filters"
dir = "test/e2e"
run = """
set -e
REF=$(grep -E '^[[:space:]]*project_id' supabase/config.toml | sed -E 's/.*"(.*)".*/\\1/')
IMAGE=realtime:e2e-local
RT="supabase_realtime_${REF}"
# 1. Build the repo into a local image (Docker layer cache keeps rebuilds cheap).
docker build -t "$IMAGE" ../..
# 2. Bring up the full supabase stack. We use its realtime container only as the source of
# truth for env vars (JWT secret, DB creds, encryption key, etc.). A prior run may have left
# realtime swapped out / removed; `supabase start` won't recreate an externally-removed
# container, so if it's missing we recycle the stack to get a clean one back.
supabase start
if ! docker inspect "$RT" >/dev/null 2>&1; then
echo "realtime container missing (left over from a prior swap); recreating supabase stack..."
supabase stop >/dev/null 2>&1 || true
supabase start
fi
# 3. Swap realtime: copy supabase's exact env (via `env` inside their container, so we avoid
# Go-template braces that collide with mise's templating), drop their container, and run ours
# under the same name / network / aliases / healthcheck so Kong routes to it unchanged.
ENVFILE=$(mktemp)
docker exec "$RT" env > "$ENVFILE"
docker rm -f "$RT" >/dev/null
docker run -d --name "$RT" \
--network "supabase_network_${REF}" \
--network-alias realtime --network-alias realtime-dev \
--env-file "$ENVFILE" \
--health-cmd 'curl -sSfL --head -o /dev/null -H "Host:realtime-dev" http://127.0.0.1:4000/api/ping' \
--health-interval 10s --health-timeout 2s --health-retries 3 \
"$IMAGE" >/dev/null
rm -f "$ENVFILE"
# 4. Wait for our realtime to report healthy (boot + tenant migrations). `docker ps` with a
# health filter prints the container id only once it is healthy — no Go-template needed.
echo "Waiting for local realtime ($IMAGE) to become healthy..."
for _ in $(seq 1 30); do
if [ -n "$(docker ps -q --filter "name=$RT" --filter health=healthy)" ]; then break; fi
sleep 2
done
# 5. Run the suite against the stack (Kong -> our realtime). Do NOT call `supabase start` again
# here, or it would recreate realtime from the stock image.
eval "$(supabase status --output env)"
bun run realtime-check.ts --env local \
--publishable-key "$PUBLISHABLE_KEY" \
--secret-key "$SECRET_KEY" \
--db-url "postgresql://postgres:postgres@127.0.0.1:54322/postgres" \
"$@"
"""