-
Notifications
You must be signed in to change notification settings - Fork 1
344 lines (306 loc) · 11.3 KB
/
Copy pathe2e.yml
File metadata and controls
344 lines (306 loc) · 11.3 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
name: E2E
on:
workflow_call:
jobs:
cypress:
name: Cypress (shard ${{ matrix.containers }}/5)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4, 5]
services:
redis:
image: redis:6-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
postgres:
image: debezium/postgres:14
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v7
- name: Setup Node and pnpm
uses: ./.github/actions/node-and-cache
- name: Install pg_dump
uses: ./.github/actions/install-pg-dump
- name: Setup environment and database
run: |
cp .env.ci .env
CONFIRM_DROP=1 pnpm run setup
- name: Build server-side TypeScript
# Mirror `pnpm dev`'s preamble: build @app/graphql (codegen + tsc) and
# the rest of the workspace via project-references. Skip `pnpm build`
# / `next build` deliberately — the server drives Next in dev mode
# against source files (NODE_ENV != production in installSSR.ts), and
# leaving production .next/ artifacts around makes Next 16 + Turbopack
# 500 on the homepage.
run: |
pnpm --filter @app/graphql run build
pnpm tsc
- name: Start server in background
# Redirect to a log file so output isn't lost when this step's shell
# exits — the cypress action's wait-on then either succeeds or trips
# a 500, and we dump the server log on always() to see why.
run: pnpm --filter @app/server run start > /tmp/server.log 2>&1 &
- name: Start worker in background
run: pnpm --filter @app/worker run start > /tmp/worker.log 2>&1 &
- name: Probe homepage response
# Captures the actual 500 body (Next dev mode renders the error into
# the response). Always run, never fail the job — this is just for
# diagnostics.
if: always()
continue-on-error: true
run: |
set +e
for _ in 1 2 3 4 5; do
if curl -sS -o /tmp/homepage-response.txt -w "HTTP %{http_code}\n" http://localhost:5678; then
break
fi
sleep 2
done
echo "::group::homepage response"
head -c 8000 /tmp/homepage-response.txt 2>/dev/null || echo "(no response captured)"
echo "::endgroup::"
- name: Ensure Cypress binary is installed
# `pnpm install` runs cypress's postinstall on a cold pnpm-store cache,
# which downloads the binary to ~/.cache/Cypress. setup-node@v4's
# `cache: pnpm` only caches the pnpm store though — on a store cache
# hit pnpm sees nothing to (re)install and skips postinstalls, but the
# ephemeral runner has no Cypress cache, so the binary is missing.
# `cypress install` is idempotent: no-op when the binary is present,
# downloads it when it isn't.
working-directory: "@app/e2e"
run: pnpm exec cypress install
- name: Cypress run
uses: cypress-io/github-action@v7
with:
command: pnpm --filter @app/e2e run run:ci
working-directory: "@app/e2e"
wait-on: http://localhost:5678
parallel: true
install: false
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Dump server and worker logs
if: always()
run: |
echo "::group::server log (tail 300)"
tail -300 /tmp/server.log 2>/dev/null || echo "(no server log)"
echo "::endgroup::"
echo "::group::worker log (tail 300)"
tail -300 /tmp/worker.log 2>/dev/null || echo "(no worker log)"
echo "::endgroup::"
- name: Upload screenshots
uses: actions/upload-artifact@v7
if: failure()
with:
name: cypress-screenshots-${{ matrix.containers }}
path: "@app/e2e/cypress/screenshots"
- name: Upload videos
uses: actions/upload-artifact@v7
if: failure()
with:
name: cypress-videos-${{ matrix.containers }}
path: "@app/e2e/cypress/videos"
cypress-sso:
name: Cypress (SSO enabled)
runs-on: ubuntu-latest
services:
redis:
image: redis:6-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
postgres:
image: debezium/postgres:14
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v7
- name: Setup Node and pnpm
uses: ./.github/actions/node-and-cache
- name: Install pg_dump
uses: ./.github/actions/install-pg-dump
- name: Setup environment and database
# SSO is gated on the presence of the three variables, not on the
# issuer being reachable. Port 8180 has nothing listening on it, so
# discovery fails and the login chain ends on the error page while
# every step before the discovery call is the production path. The
# sharded job above runs with SSO off, which is why this is a separate
# server, and the reachable-provider half lives in its own job below
# because these specs need discovery to fail.
run: |
cp .env.ci .env
{
echo "KEYCLOAK_ISSUER=http://localhost:8180/realms/ci"
echo "KEYCLOAK_CLIENT_ID=ci"
echo "KEYCLOAK_CLIENT_SECRET=ci"
} >> .env
CONFIRM_DROP=1 pnpm run setup
- name: Build server-side TypeScript
run: |
pnpm --filter @app/graphql run build
pnpm tsc
- name: Start server in background
run: pnpm --filter @app/server run start > /tmp/server.log 2>&1 &
- name: Ensure Cypress binary is installed
working-directory: "@app/e2e"
run: pnpm exec cypress install
- name: Cypress run
uses: cypress-io/github-action@v7
with:
command: pnpm --filter @app/e2e run run:sso
working-directory: "@app/e2e"
wait-on: http://localhost:5678
install: false
- name: Dump server log
if: always()
run: |
echo "::group::server log (tail 300)"
tail -300 /tmp/server.log 2>/dev/null || echo "(no server log)"
echo "::endgroup::"
- name: Upload screenshots
uses: actions/upload-artifact@v7
if: failure()
with:
name: cypress-sso-screenshots
path: "@app/e2e/cypress/screenshots"
- name: Upload videos
uses: actions/upload-artifact@v7
if: failure()
with:
name: cypress-sso-videos
path: "@app/e2e/cypress/videos"
cypress-sso-live:
name: Cypress (SSO live)
runs-on: ubuntu-latest
services:
redis:
image: redis:6-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
postgres:
image: debezium/postgres:14
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v7
- name: Setup Node and pnpm
uses: ./.github/actions/node-and-cache
- name: Install pg_dump
uses: ./.github/actions/install-pg-dump
- name: Start Keycloak
# Not a service container like redis and postgres above: services are
# created before the checkout step runs, so the realm fixture that has
# to be mounted into the container does not exist yet at that point.
run: |
docker run -d --name keycloak -p 8080:8080 \
-e KC_BOOTSTRAP_ADMIN_USERNAME=admin \
-e KC_BOOTSTRAP_ADMIN_PASSWORD=admin \
-v "$PWD/@app/e2e/keycloak/realm-ci.json:/opt/keycloak/data/import/realm-ci.json:ro" \
quay.io/keycloak/keycloak:26.0 start-dev --import-realm
- name: Wait for Keycloak
# The discovery document is what the server asks Keycloak for first, so
# serving it is the readiness signal worth waiting on: it proves both
# that Keycloak is up and that the realm import landed.
run: |
for _ in $(seq 1 60); do
if curl -sfo /dev/null http://localhost:8080/realms/ilmo-ci/.well-known/openid-configuration; then
exit 0
fi
sleep 2
done
echo "keycloak never served the ilmo-ci discovery document"
docker logs keycloak
exit 1
- name: Setup environment and database
# Realm name, client id and secret are the ones the fixture defines;
# its redirect URIs are pinned to .env.ci's ROOT_URL.
run: |
cp .env.ci .env
{
echo "KEYCLOAK_ISSUER=http://localhost:8080/realms/ilmo-ci"
echo "KEYCLOAK_CLIENT_ID=ilmo-ci"
echo "KEYCLOAK_CLIENT_SECRET=ilmo-ci-secret"
} >> .env
CONFIRM_DROP=1 pnpm run setup
- name: Build server-side TypeScript
run: |
pnpm --filter @app/graphql run build
pnpm tsc
- name: Start server in background
run: pnpm --filter @app/server run start > /tmp/server.log 2>&1 &
- name: Ensure Cypress binary is installed
working-directory: "@app/e2e"
run: pnpm exec cypress install
- name: Cypress run
uses: cypress-io/github-action@v7
with:
command: pnpm --filter @app/e2e run run:sso-live
working-directory: "@app/e2e"
wait-on: http://localhost:5678
install: false
- name: Dump server and Keycloak logs
if: always()
run: |
echo "::group::server log (tail 300)"
tail -300 /tmp/server.log 2>/dev/null || echo "(no server log)"
echo "::endgroup::"
echo "::group::keycloak log (tail 300)"
docker logs --tail 300 keycloak 2>&1 || echo "(no keycloak log)"
echo "::endgroup::"
- name: Upload screenshots
uses: actions/upload-artifact@v7
if: failure()
with:
name: cypress-sso-live-screenshots
path: "@app/e2e/cypress/screenshots"
- name: Upload videos
uses: actions/upload-artifact@v7
if: failure()
with:
name: cypress-sso-live-videos
path: "@app/e2e/cypress/videos"