forked from kdlbs/kandev
-
Notifications
You must be signed in to change notification settings - Fork 0
302 lines (252 loc) · 8.91 KB
/
Copy pathe2e-tests.yml
File metadata and controls
302 lines (252 loc) · 8.91 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
name: E2E Tests
on:
push:
branches: [main]
paths:
- "apps/backend/**"
- "apps/web/**"
- "apps/packages/**"
- "apps/pnpm-lock.yaml"
- ".github/workflows/e2e-tests.yml"
- "!**/*.md"
pull_request:
branches: [main]
paths:
- "apps/backend/**"
- "apps/web/**"
- "apps/packages/**"
- "apps/pnpm-lock.yaml"
- ".github/workflows/e2e-tests.yml"
- "!**/*.md"
# Manual trigger for verifying CI on draft PRs and ad-hoc reruns. The
# default sharded run uses the same ref the user picks in the dispatch UI.
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: apps/backend/go.mod
cache-dependency-path: apps/backend/go.sum
- name: Set up pnpm
uses: pnpm/action-setup@v5
with:
version: "9.15.9"
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
- name: Install dependencies
working-directory: apps
run: pnpm install --frozen-lockfile
- name: Build backend and web
run: make build-backend build-web
# Linux/amd64 helper binaries (agentctl + mock-agent) bind-mounted into
# containers by the Docker E2E project. Cheap to build (~1s each) so we
# always do it; the regular E2E job ignores them.
- name: Build Docker E2E helper binaries
run: make build-backend-linux-helpers
- name: Upload backend build
uses: actions/upload-artifact@v5
with:
name: e2e-backend-build
path: apps/backend/bin/
retention-days: 1
# Tar the .next directory to preserve pnpm symlinks in the standalone build.
# upload-artifact dereferences symlinks which breaks the Node.js module resolution.
- name: Package web build
run: tar -cf apps/web/next-build.tar -C apps/web .next
- name: Upload web build
uses: actions/upload-artifact@v5
with:
name: e2e-web-build
path: apps/web/next-build.tar
retention-days: 1
e2e:
name: E2E Shard ${{ matrix.shard }}/10
needs: build
runs-on: ubuntu-latest
timeout-minutes: 22
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up pnpm
uses: pnpm/action-setup@v5
with:
version: "9.15.9"
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
- name: Install dependencies
working-directory: apps
run: pnpm install --frozen-lockfile
- name: Install Playwright browsers
working-directory: apps/web
run: npx playwright install chromium --with-deps
- name: Download backend build
uses: actions/download-artifact@v5
with:
name: e2e-backend-build
path: apps/backend/bin/
- name: Make backend binaries executable
run: chmod +x apps/backend/bin/*
- name: Download web build
uses: actions/download-artifact@v5
with:
name: e2e-web-build
path: apps/web/
- name: Extract web build
working-directory: apps/web
run: tar -xf next-build.tar && rm next-build.tar
# Pinned to chromium + mobile-chrome so the dedicated `e2e-containers`
# job below owns the real-Docker project (which covers both the Docker
# executor and the SSH executor's sshd target). Without --project the
# container-bound specs would run here too, fail seeding (Docker not
# enabled for these shards), and spam every shard.
- name: Run E2E tests (shard ${{ matrix.shard }}/10)
working-directory: apps/web
run: npx playwright test --config e2e/playwright.config.ts --project=chromium --project=mobile-chrome --shard=${{ matrix.shard }}/10
- name: Upload blob report
if: always()
uses: actions/upload-artifact@v5
with:
name: blob-report-${{ matrix.shard }}
path: apps/web/e2e/blob-report/
retention-days: 3
- name: Upload test results
if: failure()
uses: actions/upload-artifact@v5
with:
name: test-results-${{ matrix.shard }}
path: apps/web/e2e/test-results/
retention-days: 7
# Real-Docker E2E: exercises the local_docker executor end-to-end.
# ubuntu-latest ships with Docker preinstalled, so no service container is
# required. Container-bound tests are slow (~2 min each), so we shard across
# 6 runners — Playwright's --shard splits the project's tests into N groups.
# Cleans up any leftover kandev-managed containers at the end so a leaky
# process doesn't poison the next run on the same self-hosted runner.
#
# This job runs the `containers` Playwright project, which covers both the
# Docker executor and the SSH executor (since the SSH executor's e2e tests
# also rely on Docker to host a real sshd container as the remote target).
# Sharded 6 ways — each shard is its own runner. See apps/web/e2e/README.md.
e2e-containers:
name: E2E Containers Shard ${{ matrix.shard }}/6
needs: build
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5, 6]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Verify Docker is available
run: docker info
- name: Set up pnpm
uses: pnpm/action-setup@v5
with:
version: "9.15.9"
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
- name: Install dependencies
working-directory: apps
run: pnpm install --frozen-lockfile
- name: Install Playwright browsers
working-directory: apps/web
run: npx playwright install chromium --with-deps
- name: Download backend build
uses: actions/download-artifact@v5
with:
name: e2e-backend-build
path: apps/backend/bin/
- name: Make backend binaries executable
run: chmod +x apps/backend/bin/*
- name: Download web build
uses: actions/download-artifact@v5
with:
name: e2e-web-build
path: apps/web/
- name: Extract web build
working-directory: apps/web
run: tar -xf next-build.tar && rm next-build.tar
- name: Run container-backed E2E tests shard ${{ matrix.shard }}/6 (Docker executor + SSH executor)
working-directory: apps/web
env:
KANDEV_E2E_CONTAINERS: "1"
run: npx playwright test --config e2e/playwright.config.ts --project=containers --shard=${{ matrix.shard }}/6
- name: Cleanup leftover kandev containers
if: always()
run: docker ps -aq --filter label=kandev.managed=true | xargs -r docker rm -f
# Named with the same `blob-report-*` prefix the merge job globs for
# so the containers results land in the unified HTML report alongside
# the sharded chromium/mobile-chrome runs.
- name: Upload containers blob report
if: always()
uses: actions/upload-artifact@v5
with:
name: blob-report-containers-${{ matrix.shard }}
path: apps/web/e2e/blob-report/
retention-days: 3
- name: Upload containers E2E results
if: failure()
uses: actions/upload-artifact@v5
with:
name: containers-e2e-test-results-${{ matrix.shard }}
path: apps/web/e2e/test-results/
retention-days: 7
e2e-report:
name: Merge E2E Reports
needs: [e2e, e2e-containers]
if: always()
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up pnpm
uses: pnpm/action-setup@v5
with:
version: "9.15.9"
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
- name: Install dependencies
working-directory: apps
run: pnpm install --frozen-lockfile
- name: Download blob reports
uses: actions/download-artifact@v5
with:
path: apps/web/e2e/blob-reports
pattern: blob-report-*
merge-multiple: true
- name: Merge reports
working-directory: apps/web
run: npx playwright merge-reports --reporter=html ./e2e/blob-reports
- name: Upload merged report
uses: actions/upload-artifact@v5
with:
name: playwright-report
path: apps/web/playwright-report/
retention-days: 14