-
Notifications
You must be signed in to change notification settings - Fork 203
241 lines (210 loc) · 8.72 KB
/
Copy pathci.yml
File metadata and controls
241 lines (210 loc) · 8.72 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
name: CI
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
# A pull request that gets a new push has nothing to learn from the run for the
# superseded commit, and every one of those runs holds a Playwright job for
# minutes. Pushes to main are never cancelled: each one is the commit a deploy
# and the production smoke are about to be judged on.
concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
# The three E2E suites run the same ~95 specs against three different servers
# (vite preview, the production container, wrangler pages dev), which is the
# whole cost of this workflow -- install, vite build and docker build together
# are under two minutes. Each suite is therefore split across three runners,
# and a summary job carries the name the branch protection requires.
#
# Sharding, not more workers: the runner has 4 cores, the editor is a WASM
# process per worker, and the Pages suite deliberately runs single-worker
# (playwright.pages.config.ts explains why workerd dies under concurrent
# aborts). Shards keep every suite's own concurrency semantics untouched.
#
# Changing the shard count means editing both the matrix and the /N in the
# --shard argument of that job.
jobs:
lint:
name: Lint and Validate
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up the toolchain
uses: ./.github/actions/setup
- name: Check formatting
run: pnpm run format:check
- name: Run oxlint and TypeScript checks
run: pnpm run lint:ts
- name: Run unit tests with coverage
run: pnpm run test:coverage
- name: Validate Docker Compose file
run: docker compose -f docker-compose.yaml config --quiet
- name: Lint Dockerfile with Hadolint
uses: hadolint/hadolint-action@v3.4.0
with:
dockerfile: Dockerfile
failure-threshold: error
# The E2E jobs deliberately do NOT wait for lint. Lint is a one-minute job,
# but waiting for it put ~90 seconds of pure latency on the critical path of
# every PR. On a public repository the runners are free, so the only cost of
# starting E2E early is a wasted run on the commits where lint is red -- and
# those commits get their E2E answer for free instead of after a second push.
e2e-shard:
name: E2E shard ${{ matrix.shard }}
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
# One shard failing must not hide the verdict of the other two: a red
# suite should report every failure it has in a single run.
fail-fast: false
matrix:
shard: [1, 2, 3]
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up the toolchain
uses: ./.github/actions/setup
with:
browsers: chromium
- name: Run E2E tests
# `@serial` is excluded here and measured in the next step: those cases
# assert wall-clock budgets, and four WASM editors sharing four cores
# push them past their bound (the font-system wait measured 3.4 s
# against a 2 s budget). See the next step and CLAUDE.md.
run: pnpm exec playwright test --shard=${{ matrix.shard }}/3 --grep-invert @serial
- name: Run the timing-budget E2E cases with the runner to themselves
# Run in every shard rather than one: each shard is its own VM, so this
# pass really is alone, and every shard stays a copy of the others (an
# asymmetric shard is how a step gets dropped unnoticed). Deliberately
# not sharded -- it is a single case.
#
# The case itself takes seconds, but the step does not: this is a second
# `playwright test` process, and `reuseExistingServer` is false in CI, so
# each shard pays another full `vite build` + preview startup (~1 min)
# for it. That is the price of testing the budget at all -- measured
# against three WASM editors it is the machine that fails, not the code
# -- but it is a minute per shard, not seconds.
run: pnpm exec playwright test --grep @serial --workers=1
- name: Upload Playwright report
if: failure()
uses: actions/upload-artifact@v7
with:
name: playwright-report-${{ matrix.shard }}
path: playwright-report/
retention-days: 7
# Summary jobs. Branch protection matches required checks by name, so the
# three names below must stay exactly as they are -- the sharded jobs are
# named "... shard N" precisely so these can keep the original names.
e2e:
name: E2E
runs-on: ubuntu-latest
needs: e2e-shard
if: always()
timeout-minutes: 5
steps:
- name: Report the shard verdict
env:
RESULT: ${{ needs.e2e-shard.result }}
run: |
echo "shards: $RESULT"
[ "$RESULT" = "success" ] || exit 1
# Deploy artifact + host semantics: bin/build.sh output served by
# `wrangler pages dev`, which reproduces Cloudflare Pages' index.html -> 308
# redirects, _headers and _redirects. Catches "works on vite preview, broken
# on the live site" (PDF loader stuck behind the 308; font cache headers).
e2e-pages-shard:
name: E2E (Cloudflare Pages semantics) shard ${{ matrix.shard }}
runs-on: ubuntu-latest
# Five shards rather than three: this suite still serves wrangler with a
# single worker on purpose (see playwright.pages.config.ts), so it is the
# slowest of the three and sets the critical path. Every shard also pays a
# fixed ~2 minutes for its own bin/build.sh and wrangler start, which is
# what stops the split from paying off much beyond this.
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5]
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up the toolchain
uses: ./.github/actions/setup
with:
browsers: chromium
- name: Run E2E against wrangler pages dev
# `@serial` is excluded by playwright.pages.config.ts itself, so a local
# run of that config measures exactly what this job does.
run: pnpm exec playwright test -c playwright.pages.config.ts --shard=${{ matrix.shard }}/5
- name: Upload Playwright report
if: failure()
uses: actions/upload-artifact@v7
with:
name: playwright-report-pages-${{ matrix.shard }}
path: playwright-report-pages/
retention-days: 7
e2e-pages:
name: E2E (Cloudflare Pages semantics)
runs-on: ubuntu-latest
needs: e2e-pages-shard
if: always()
timeout-minutes: 5
steps:
- name: Report the shard verdict
env:
RESULT: ${{ needs.e2e-pages-shard.result }}
run: |
echo "shards: $RESULT"
[ "$RESULT" = "success" ] || exit 1
# The lint job only validates compose config and Dockerfile style; this job
# actually builds the image and runs the full e2e suite against the running
# container, proving the production image serves the editor correctly (this
# is what caught the workspace-manifest install breakage). Every shard builds
# the image itself -- that build is 45 seconds, far cheaper than shipping the
# image between jobs as an artifact.
e2e-docker-shard:
name: E2E (Docker image) shard ${{ matrix.shard }}
runs-on: ubuntu-latest
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3]
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up the toolchain
uses: ./.github/actions/setup
with:
browsers: chromium
- name: Run E2E tests against the Docker image
# Called directly, not through `pnpm run`: pnpm swallows the extra
# arguments, which would silently run the whole suite in every shard.
# `@serial` is excluded by playwright.docker.config.ts itself, so a
# local `pnpm run test:e2e:docker` measures the same set.
run: sh ./bin/test-e2e-docker.sh --shard=${{ matrix.shard }}/3
- name: Upload Playwright report
if: failure()
uses: actions/upload-artifact@v7
with:
name: playwright-report-docker-${{ matrix.shard }}
path: playwright-report-docker/
retention-days: 7
e2e-docker:
name: E2E (Docker image)
runs-on: ubuntu-latest
needs: e2e-docker-shard
if: always()
timeout-minutes: 5
steps:
- name: Report the shard verdict
env:
RESULT: ${{ needs.e2e-docker-shard.result }}
run: |
echo "shards: $RESULT"
[ "$RESULT" = "success" ] || exit 1