-
Notifications
You must be signed in to change notification settings - Fork 0
179 lines (152 loc) · 5.79 KB
/
Copy pathplaywright.yml
File metadata and controls
179 lines (152 loc) · 5.79 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
168
169
170
171
172
173
174
175
176
177
178
179
# Runs Playwright E2E suite for merge-queue validation
name: Playwright
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
permissions: {}
jobs:
e2e-test:
name: E2E Tests
runs-on: ubuntu-latest
environment: testing
if: ${{ !startsWith(github.head_ref || github.ref_name, 'hotfix/') }}
permissions:
actions: write
contents: read
env:
ASTRO_DB_APP_TOKEN: ${{ secrets.ASTRO_DB_APP_TOKEN }}
ASTRO_DB_REMOTE_URL: ${{ secrets.ASTRO_DB_REMOTE_URL }}
COMPOSE_PROJECT_NAME: ${{ vars.COMPOSE_PROJECT_NAME }}
CRON_SECRET: ${{ vars.CRON_SECRET }}
# Use localhost so IPv6-only listeners (e.g. ::1) are reachable under act.
DEV_SERVER_HOST: localhost
DEV_SERVER_PORT: ${{ vars.DEV_SERVER_PORT }}
DISABLE_TELEMETRY: true
FORCE_COLOR: 3
PUBLIC_GOOGLE_MAPS_API_KEY: ${{ vars.PUBLIC_GOOGLE_MAPS_API_KEY }}
PUBLIC_GOOGLE_MAP_ID: ${{ vars.PUBLIC_GOOGLE_MAP_ID }}
PUBLIC_UPSTASH_SEARCH_READONLY_TOKEN: ${{ vars.PUBLIC_UPSTASH_SEARCH_READONLY_TOKEN }}
PUBLIC_UPSTASH_SEARCH_REST_URL: ${{ vars.PUBLIC_UPSTASH_SEARCH_REST_URL }}
RESEND_API_KEY: ${{ vars.RESEND_API_KEY }}
RESEND_HTTP_PORT: ${{ vars.RESEND_HTTP_PORT }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
PUBLIC_SENTRY_DSN: ${{ vars.PUBLIC_SENTRY_DSN }}
WEBMENTION_IO_TOKEN: ${{ vars.WEBMENTION_IO_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ">=24.16.0 <25"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Install Playwright browsers
run: npx playwright install --with-deps
- name: Start Astro dev server
run: |
echo "Starting Astro dev server on ${DEV_SERVER_HOST}:${DEV_SERVER_PORT}"
build_healthcheck_urls() {
echo "http://localhost:${DEV_SERVER_PORT}/"
echo "http://127.0.0.1:${DEV_SERVER_PORT}/"
echo "http://[::1]:${DEV_SERVER_PORT}/"
}
if [ "${DEBUG:-0}" = "1" ]; then
echo "[debug] DEBUG=1"
echo "[debug] DEV_SERVER_HOST=${DEV_SERVER_HOST:-<unset>}"
echo "[debug] DEV_SERVER_PORT=${DEV_SERVER_PORT:-<unset>}"
echo "[debug] node=$(node --version 2>/dev/null || true)"
echo "[debug] npm=$(npm --version 2>/dev/null || true)"
fi
nohup npm run dev -- --host 0.0.0.0 --port "${DEV_SERVER_PORT}" > /tmp/astro-dev.log 2>&1 &
echo $! > /tmp/astro-dev.pid
sleep 1
if ! ps -p "$(cat /tmp/astro-dev.pid)" > /dev/null 2>&1; then
echo "❌ Astro dev server process exited immediately"
echo '--- Astro dev server log ---'
cat /tmp/astro-dev.log || true
exit 1
fi
if [ "${DEBUG:-0}" = "1" ]; then
echo "[debug] astro pid=$(cat /tmp/astro-dev.pid)"
ps -fp "$(cat /tmp/astro-dev.pid)" || true
echo "[debug] listening ports (ss -ltnp)"
ss -ltnp || true
echo "[debug] curl check (verbose)"
while read -r url; do
echo "[debug] probing ${url}"
curl -v "${url}" || true
done < <(build_healthcheck_urls)
echo "[debug] tail /tmp/astro-dev.log"
tail -n 200 /tmp/astro-dev.log || true
fi
- name: Wait for Astro dev server
run: |
build_healthcheck_urls() {
echo "http://localhost:${DEV_SERVER_PORT}/"
echo "http://127.0.0.1:${DEV_SERVER_PORT}/"
echo "http://[::1]:${DEV_SERVER_PORT}/"
}
probe_dev_server() {
local url
while read -r url; do
if curl -fsS "${url}" > /dev/null; then
echo "✅ Dev server is responding at ${url}"
return 0
fi
done < <(build_healthcheck_urls)
return 1
}
# `npm run dev` runs `astro sync` first; allow time for it to finish.
for i in $(seq 1 120); do
if probe_dev_server; then
exit 0
fi
if [ "${DEBUG:-0}" = "1" ]; then
echo "[debug] still waiting... attempt=${i}/120"
if [ -f /tmp/astro-dev.pid ]; then
echo "[debug] pid=$(cat /tmp/astro-dev.pid)"
ps -fp "$(cat /tmp/astro-dev.pid)" || true
fi
ss -ltnp || true
tail -n 50 /tmp/astro-dev.log || true
fi
sleep 1
done
echo "❌ Dev server did not start within 120 seconds"
echo '--- Astro dev server log ---'
cat /tmp/astro-dev.log || true
exit 1
- name: Run Playwright E2E tests
run: npm run test:e2e:smoke
env:
CI: "1"
- name: Stop Astro dev server
if: always()
run: |
if [ -f /tmp/astro-dev.pid ]; then
kill $(cat /tmp/astro-dev.pid) || true
rm /tmp/astro-dev.pid
fi
- name: Upload Playwright report
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: playwright-report
path: playwright-report/
retention-days: 30
hotfix-bypass:
name: E2E Test Hotfix Bypass
runs-on: ubuntu-latest
if: ${{ startsWith(github.head_ref || github.ref_name, 'hotfix/') }}
permissions: {}
steps:
- name: Skip E2E for hotfix branch
run: echo "hotfix/* branch detected; skipping e2e workflow but allowing
deployments."