-
Notifications
You must be signed in to change notification settings - Fork 0
823 lines (718 loc) · 30.4 KB
/
Copy pathci.yml
File metadata and controls
823 lines (718 loc) · 30.4 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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
name: CI
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# ===========================================
# Lint - Check code formatting
# ===========================================
lint:
name: Lint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version-file: package.json
- name: Cache Bun dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Check code formatting
run: bun run lint
# ===========================================
# Unit Tests - Shared Packages (Vitest)
# ===========================================
test-packages:
name: Unit Tests (Shared Packages)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version-file: package.json
- name: Cache Bun dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Run shared package tests with coverage
run: cd packages/inkweld-prosemirror && bun run test:coverage
- name: Run inkweld-presence tests with coverage
run: cd packages/inkweld-presence && bun run test:coverage
- name: Upload packages coverage
if: ${{ !cancelled() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: packages-coverage
path: packages/inkweld-prosemirror/coverage/lcov.info
retention-days: 1
- name: Upload presence package coverage
if: ${{ !cancelled() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: presence-coverage
path: packages/inkweld-presence/coverage/lcov.info
retention-days: 1
# ===========================================
# Unit Tests - Frontend (Vitest) - Sharded across parallel runners
# ===========================================
# `ng test` has no --shard flag, so frontend/scripts/test-shard.mjs deals
# the spec files round-robin across the matrix and passes each shard's list
# via --include. Unsharded this was the longest job in the workflow (~18m);
# 2 shards (~9m each) bring it in line with the e2e jobs; 3 ran ~5-6m,
# shorter than the e2e shards, so the extra runner bought no wall-clock. Each shard emits an lcov.info
# covering the whole tree, so per-shard thresholds are disabled (the `shard`
# configuration in angular.json) and enforced on the merged report in the
# frontend-coverage job below.
test-frontend:
name: Unit Tests (Frontend) - Shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2]
shardTotal: [2]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: "24"
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version-file: package.json
- name: Cache Bun dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Show Node.js version
run: node --version && bun --version
- name: Run frontend tests (shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }})
run: cd frontend && NODE_OPTIONS="--max-old-space-size=8192" npm run test:shard -- ${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- name: Upload frontend coverage shard
if: ${{ !cancelled() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: frontend-coverage-shard-${{ matrix.shardIndex }}
path: frontend/coverage/inkweld-frontend/lcov.info
retention-days: 1
# ===========================================
# Frontend Coverage - merge shards + enforce thresholds
# ===========================================
frontend-coverage:
name: Unit Tests (Frontend) - Coverage
runs-on: ubuntu-latest
permissions:
contents: read
needs: [test-frontend]
# Merge whatever shards produced coverage even if a shard's tests failed,
# so SonarCloud still gets a report; skip only on cancellation.
if: ${{ !cancelled() }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: "24"
- name: Download coverage shards
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
pattern: frontend-coverage-shard-*
path: frontend/coverage/shards
- name: Merge coverage and check thresholds
run: cd frontend && node scripts/merge-lcov.mjs --out coverage/inkweld-frontend/lcov.info coverage/shards/*/lcov.info
- name: Upload frontend coverage
if: ${{ !cancelled() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: frontend-coverage
path: frontend/coverage/inkweld-frontend/lcov.info
retention-days: 1
# ===========================================
# Unit Tests - Backend (Bun)
# ===========================================
test-backend:
name: Unit Tests (Backend)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version-file: package.json
- name: Cache Bun dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Run backend tests
run: cd backend && DB_DATABASE=":memory:" USER_APPROVAL_REQUIRED="false" bun run test:coverage
- name: Upload backend coverage
if: ${{ !cancelled() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: backend-coverage
path: backend/coverage/lcov.info
retention-days: 1
# ===========================================
# SonarCloud Analysis
# ===========================================
sonarcloud:
name: SonarCloud Code Analysis
runs-on: ubuntu-latest
permissions:
contents: read
needs: [frontend-coverage, test-backend, test-packages]
# Run even when the test jobs fail (partial coverage is still worth
# scanning), but NOT when the run is cancelled - `always()` would also
# match cancellations, and a superseded run's coverage artifacts never
# get uploaded, so the scan would report 0% coverage on new code and post
# a false quality gate failure to the PR.
# Also skip SonarCloud analysis for Renovate dependency PRs (machine-generated).
if: ${{ !cancelled() && !startsWith(github.head_ref, 'renovate/') }}
# Configure the 15-minute wait timer on the sonarcloud-analysis environment.
environment:
name: sonarcloud-analysis
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
- name: Download frontend coverage
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: frontend-coverage
path: frontend/coverage/inkweld-frontend
continue-on-error: true
- name: Download backend coverage
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: backend-coverage
path: backend/coverage
continue-on-error: true
- name: Download packages coverage
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: packages-coverage
path: packages/inkweld-prosemirror/coverage
continue-on-error: true
- name: Download presence package coverage
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: presence-coverage
path: packages/inkweld-presence/coverage
continue-on-error: true
- name: SonarCloud Scan
uses: SonarSource/sonarqube-scan-action@22918119ff8e1ca75a623e15c8296b6ea4fbe28f # v8
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ===========================================
# E2E Tests - Sharded across parallel runners
# ===========================================
# The heavier e2e jobs are split with Playwright's --shard=N/T flag using a
# GitHub Actions matrix so test files are evenly distributed across runners.
# Wall-clock time drops roughly 1/N at the cost of N runners' worth of
# compute (each shard re-runs setup).
#
# Shard counts were tuned against historical job durations: Docker ~15m,
# Wrangler ~13m at 2 shards (now 3), Online ~11m. Local (~8m) and
# Screenshots (~9m) are left unsharded - Local because the savings don't
# justify the extra runner, and
# Screenshots because it is driven by the docs build rather than
# `playwright test` directly and must run sequentially for visual
# consistency.
# Local E2E Tests (24 spec files - unsharded; ~8m on the runner)
e2e-local:
name: E2E Tests (Local)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: "24"
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version-file: package.json
- name: Cache Bun dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Get installed Playwright version
id: playwright-version
run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT
working-directory: frontend
- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: cd frontend && ./node_modules/.bin/playwright install --with-deps chromium
- name: Install Playwright system deps
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: cd frontend && ./node_modules/.bin/playwright install-deps chromium
- name: Build frontend
run: cd frontend && npm run build
- name: Run local e2e tests
run: cd frontend && npm run e2e:local:ci
env:
E2E_MODE: prod
- name: Upload Playwright reports
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
if: failure()
with:
name: playwright-report-local
path: frontend/playwright-report/
retention-days: 7
# Online E2E Tests (22 spec files - 2 shards)
e2e-online:
name: E2E Tests (Online) - Shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2]
shardTotal: [2]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: "24"
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version-file: package.json
- name: Cache Bun dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Get installed Playwright version
id: playwright-version
run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT
working-directory: frontend
- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: cd frontend && ./node_modules/.bin/playwright install --with-deps chromium
- name: Install Playwright system deps
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: cd frontend && ./node_modules/.bin/playwright install-deps chromium
- name: Build frontend
run: cd frontend && npm run build
- name: Run online e2e tests (shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }})
run: cd frontend && npm run e2e:online:ci -- --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
env:
E2E_MODE: prod
- name: Upload Playwright reports
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
if: failure()
with:
name: playwright-report-online-shard-${{ matrix.shardIndex }}
path: frontend/playwright-report/
retention-days: 7
# Wrangler E2E Tests (22 spec files - 3 shards; the slowest e2e job at 2)
e2e-wrangler:
name: E2E Tests (Wrangler) - Shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3]
shardTotal: [3]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: "24"
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version-file: package.json
- name: Cache Bun dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Get installed Playwright version
id: playwright-version
run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT
working-directory: frontend
- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: cd frontend && ./node_modules/.bin/playwright install --with-deps chromium
- name: Install Playwright system deps
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: cd frontend && ./node_modules/.bin/playwright install-deps chromium
- name: Copy wrangler.toml for CI
run: cp backend/wrangler.toml.example backend/wrangler.toml
- name: Initialize local D1 database
run: cd backend && bun run init:d1-local
- name: Build frontend
run: cd frontend && npm run build
- name: Run wrangler e2e tests (shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }})
# No retries: a failing test is a bug to investigate, not something to
# paper over. If the shared `wrangler dev` backend crashes mid-run, the
# failure surfaces immediately so we can fix the underlying cause.
run: cd frontend && npm run e2e:wrangler:ci -- --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
env:
E2E_MODE: prod
# Where the wrangler backend's stdout/stderr is tee'd (see
# playwright.wrangler.config.ts). Uploaded as an artifact on failure
# so a native workerd crash stack is preserved for investigation.
# Note: the webServer runs with cwd ../backend, so this must be
# absolute to land in a stable, project-owned location.
WRANGLER_LOG_FILE: ${{ github.workspace }}/wrangler-backend.log
# wrangler's own diagnostic log records what the console's empty
# "[ERROR]" line hides. When a transient ProxyWorker disconnect
# ("Network connection lost.") kills `wrangler dev` mid-run — see
# cloudflare/workers-sdk#15317 — the real cause only shows up at
# debug level in this file. Redirected into the workspace so it can
# be uploaded as an artifact instead of staying in the runner home.
WRANGLER_LOG: debug
WRANGLER_LOG_PATH: ${{ github.workspace }}/wrangler-debug-logs
- name: Upload Playwright reports
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
if: failure()
with:
name: playwright-report-wrangler-shard-${{ matrix.shardIndex }}
path: frontend/playwright-report/
retention-days: 7
- name: Upload wrangler backend log
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
if: failure()
with:
name: wrangler-backend-log-shard-${{ matrix.shardIndex }}
path: wrangler-backend.log
retention-days: 7
- name: Upload wrangler diagnostic log
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
if: failure()
with:
name: wrangler-diag-log-shard-${{ matrix.shardIndex }}
path: wrangler-debug-logs/
retention-days: 7
if-no-files-found: warn
# Docker E2E Tests (22 spec files - 2 shards)
# Note: each shard rebuilds the Docker image in globalSetup, so the per-job
# cost is high. We deliberately keep this at 2 shards to avoid blowing up
# compute usage.
e2e-docker:
name: E2E Tests (Docker) - Shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2]
shardTotal: [2]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: "24"
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version-file: package.json
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4
- name: Cache Bun dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Get installed Playwright version
id: playwright-version
run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT
working-directory: frontend
- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: cd frontend && ./node_modules/.bin/playwright install --with-deps chromium
- name: Install Playwright system deps
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: cd frontend && ./node_modules/.bin/playwright install-deps chromium
- name: Run Docker e2e tests (shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }})
run: cd frontend && npm run e2e:docker:ci -- --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- name: Upload Playwright reports
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
if: failure()
with:
name: playwright-report-docker-shard-${{ matrix.shardIndex }}
path: frontend/playwright-report/
retention-days: 7
# ===========================================
# E2E Tests - Screenshots (via docs build)
# ===========================================
# Not sharded: this job builds the docs site, which runs the screenshot
# tests as a side effect. The tests must run sequentially to produce
# consistent visual output.
e2e-screenshots:
name: E2E Tests (Screenshots)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: "24"
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version-file: package.json
- name: Cache Bun dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Get installed Playwright version
id: playwright-version
run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT
working-directory: frontend
- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: cd frontend && ./node_modules/.bin/playwright install --with-deps chromium
- name: Install Playwright system deps
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: cd frontend && ./node_modules/.bin/playwright install-deps chromium
- name: Build docs (runs screenshot e2e tests)
run: cd docs/site && bun run build
- name: Upload Playwright reports
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
if: failure()
with:
name: playwright-report-screenshots
path: frontend/playwright-report/
retention-days: 7
# ===========================================
# Build and Push Dev Docker Image (Multi-arch)
# ===========================================
# Pre-build frontend on AMD64 (output is platform-agnostic)
docker-frontend-build:
name: Build Frontend for Docker
runs-on: ubuntu-latest
permissions:
contents: read
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs:
[
lint,
test-frontend,
frontend-coverage,
test-backend,
test-packages,
e2e-local,
e2e-online,
e2e-wrangler,
e2e-docker,
e2e-screenshots,
]
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version-file: package.json
- name: Install dependencies
# Workspace-root install so the @inkweld/prosemirror peer deps
# (prosemirror-model, yjs) are available for the shared package
# consumed by the frontend build.
run: bun install --frozen-lockfile
- name: Build frontend
run: cd frontend && bun run build
- name: Compress WASM files
run: cd frontend && node scripts/compress-wasm.js
- name: Upload frontend dist
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: frontend-dist
path: frontend/dist
retention-days: 1
# Build AMD64 image
docker-dev-amd64:
name: Build Docker (amd64)
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [docker-frontend-build]
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Download frontend dist
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: frontend-dist
path: frontend/dist
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image (amd64)
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7
with:
context: .
file: Dockerfile
push: true
platforms: linux/amd64
tags: ghcr.io/${{ github.repository_owner }}/inkweld:dev-amd64
build-args: FRONTEND_PREBUILT=true
cache-from: type=gha,scope=amd64
cache-to: type=gha,mode=max,scope=amd64
provenance: false
# Build ARM64 image on native ARM runner
docker-dev-arm64:
name: Build Docker (arm64)
runs-on: ubuntu-24.04-arm
permissions:
contents: read
packages: write
needs: [docker-frontend-build]
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Download frontend dist
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: frontend-dist
path: frontend/dist
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image (arm64)
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7
with:
context: .
file: Dockerfile
push: true
platforms: linux/arm64
tags: ghcr.io/${{ github.repository_owner }}/inkweld:dev-arm64
build-args: FRONTEND_PREBUILT=true
cache-from: type=gha,scope=arm64
cache-to: type=gha,mode=max,scope=arm64
provenance: false
# Create multi-arch manifest
docker-dev-manifest:
name: Create Docker Manifest
runs-on: ubuntu-latest
permissions:
packages: write
needs: [docker-dev-amd64, docker-dev-arm64]
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push multi-arch manifest
run: |
docker manifest create ghcr.io/${{ github.repository_owner }}/inkweld:dev \
ghcr.io/${{ github.repository_owner }}/inkweld:dev-amd64 \
ghcr.io/${{ github.repository_owner }}/inkweld:dev-arm64
docker manifest push ghcr.io/${{ github.repository_owner }}/inkweld:dev