Repository navigation
483 lines (464 loc) · 23 KB
/
Copy pathci.yml
File metadata and controls
483 lines (464 loc) · 23 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
name: ci
on:
push:
branches: [main]
pull_request:
# release.yml runs this same gate before it publishes a release.
workflow_call:
permissions:
contents: read
# A pull request keeps only its newest run: an older push to the same branch has
# nothing left to prove. A commit on main is never cancelled, so every commit a
# release is cut from has run this whole gate to the end; the group is keyed on
# the commit there, which lets consecutive pushes overlap instead of dropping
# one.
concurrency:
group: ci-${{ github.event_name == 'pull_request' && github.ref || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
# A change that only touches documentation runs no gate at all. This job always
# runs, though: the check a branch protection rule requires is "ci passed"
# below, and a required check that a path filter skipped would stay pending
# forever and hold the pull request shut.
changes:
runs-on: ubuntu-latest
outputs:
code: ${{ steps.paths.outputs.code }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: decide whether this change needs the gate
id: paths
run: |
# A release tag always runs the whole gate: the tag is what ships, so
# nothing about its contents may skip a check.
case "${{ github.ref }}" in
refs/tags/*) echo "code=true" >> "$GITHUB_OUTPUT"; exit 0 ;;
esac
base="${{ github.event.pull_request.base.sha }}"
[ -n "$base" ] || base="${{ github.event.before }}"
code=true
if [ -n "$base" ] && git cat-file -e "$base^{commit}" 2>/dev/null; then
git diff --name-only --no-renames "$base" HEAD > "$RUNNER_TEMP/changed"
code=false
while IFS= read -r file; do
case "$file" in
# Nothing here can change what the gate builds, runs or measures.
# website/ is not documentation: tools/docs generates pages from
# Go sources, and website.yml is what builds the site.
*.md | docs/* | LICENSE | NOTICE | .github/ISSUE_TEMPLATE/*) ;;
*) code=true ;;
esac
done < "$RUNNER_TEMP/changed"
else
echo "no base commit to compare with; running the gate" >&2
fi
echo "code=$code" >> "$GITHUB_OUTPUT"
{
echo "### changed files"
head -50 "$RUNNER_TEMP/changed" 2>/dev/null | sed 's/^/ /' || true
echo "code=$code"
} >> "$GITHUB_STEP_SUMMARY"
# Formatting and the Linux type-check of every package. Both are the same on
# every operating system, so they belong on the cheapest runner there is
# rather than on a macOS one.
lint:
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: gofmt
run: test -z "$(gofmt -l .)"
# The darwin type-check is the darwin job's; cross-vet covers the other
# targets this repository ships for.
- name: vet
run: go vet ./...
# The page-facing packages keep reflection and untyped containers out of
# their exported API; the layout, input, scene and render paths depend on
# it, and a symbol that needs one usually needs a typed one instead.
- name: API discipline
run: go run ./tools/apicheck ./ui ./components ./app ./gfx
# The attribute rules (ADR 0089 stage 3) exist only in the dev build: they
# report a generic attribute that an element cannot use instead of letting it
# be silently ignored. The release build must not carry the rules or their
# messages, so this job tests the dev variant and proves the release one has
# neither.
dev-attributes:
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: vet the dev build
run: go vet -tags dev ./...
- name: test the dev build
run: go test -tags dev ./base ./ui ./components -count=1
- name: prove the release build has no attribute rules
run: |
if go list -f '{{.GoFiles}}' ./base | grep -q attrcheck_dev.go; then
echo "the release build compiles the dev attribute rules" >&2
exit 1
fi
go build -o /tmp/base-release.a ./base
if grep -aq 'does not support' /tmp/base-release.a; then
echo "the release build carries the dev attribute messages" >&2
exit 1
fi
go build -tags dev -o /tmp/base-dev.a ./base
if ! grep -aq 'does not support' /tmp/base-dev.a; then
echo "the dev build does not carry the attribute rules" >&2
exit 1
fi
# Every target Viva ships for must at least type-check, tests included. The
# targets do not depend on each other, so they run at the same time on one
# runner: asking for four runners to do what one can finish in the same minute
# only spends more queue time.
cross-vet:
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: vet every target
run: |
status=0
pids=""
# linux/amd64 is the lint job's `go vet ./...`, over every package.
for target in linux/arm64 windows/amd64 windows/arm64; do
GOOS=${target%/*} GOARCH=${target#*/} \
go vet ./internal/... ./app/ ./cmd/... ./components/... ./update/... &
pids="$pids $!"
done
for pid in $pids; do
wait "$pid" || status=1
done
exit "$status"
- name: Native Linux text rasterization
run: |
sudo apt-get install -y libpangocairo-1.0-0 fonts-noto-color-emoji ||
{ sudo apt-get update && sudo apt-get install -y libpangocairo-1.0-0 fonts-noto-color-emoji; }
go test ./internal/platform/linux -run '^TestTextEngineRasterizesProportionalText$' -count=1 -v
- name: GTK optional capability contracts
run: |
go vet -tags vivagtk ./app ./internal/platform/linux
go test -tags vivagtk ./internal/platform/linux -run '^Test(GTK(WaylandAlwaysOnTopReportsUnsupported|ClipboardFileWriteReportsUnsupportedWithoutASetter|ClipboardImageWriteReportsUnsupportedWithoutSetWithData)|APartition(KeepsItsStoreInTheUsersDirectories|FollowsTheXdgDirectories|IsNamedAfterTheApplicationWithoutAClass))$' -count=1
# The Linux package is not part of the sharded run (it drives X11), so the
# titlebar contracts that do not need a server name their tests here.
- name: Titlebar and window contracts
run: go test ./internal/platform/linux -run '^Test(MaximizeButtonSetsBothDirections|OpeningMaximizedAsksForBothDirectionsBeforeMapping|PreviewMovePreservesSizeAndFocus|AClipboardImageIsOfferedAsPNGAndNoText|SetClipboardImageClaimsTheClipboardAndDropsOtherFlavours)$' -count=1 -v
- name: Native X11 drag preview and notification
env:
VIVA_TEST_PREVIEW_XVFB: '1'
VIVA_TEST_NOTIFICATION_XVFB: '1'
run: |
sudo apt-get install -y xvfb libxcb-shape0 libgtk-3-0 ||
{ sudo apt-get update && sudo apt-get install -y xvfb libxcb-shape0 libgtk-3-0; }
xvfb-run -a -s '-screen 0 1280x1024x24 -noreset' go test ./internal/platform/linux -run '^Test(PreviewNativeX11Contract|NotificationNativeX11|TrayWindowQueuedRedrawBeforeInput|TrayWindowRepaintsLaterExposure)$' -count=1 -v
GDK_BACKEND=x11 VIVA_TEST_GTK_NOTIFICATION=1 xvfb-run -a go test -tags vivagtk ./internal/platform/linux -run '^TestGTKNotificationFocusHints$' -count=1 -v
- name: Native X11 global shortcut
env:
VIVA_NATIVE_GLOBAL_SHORTCUT_TEST: '1'
run: |
sudo apt-get install -y xvfb xdotool libx11-xcb1 ||
{ sudo apt-get update && sudo apt-get install -y xvfb xdotool libx11-xcb1; }
xvfb-run -a go test ./internal/platform/linux -run '^TestNativeX11(GlobalShortcut|WindowIconPropertyUpdates)$' -count=1 -v
- name: Native X11 clipboard formats and ownership
run: |
sudo apt-get install -y xclip python3-gi gir1.2-gtk-3.0 ||
{ sudo apt-get update && sudo apt-get install -y xclip python3-gi gir1.2-gtk-3.0; }
env -u WAYLAND_DISPLAY GDK_BACKEND=x11 VIVA_LINUX_XCB_SMOKE=1 \
xvfb-run -a -s '-screen 0 1280x1024x24 -noreset' \
go test ./internal/platform/linux -run '^TestClipboardImage(FromX11Owner|AfterExternalOwnerReplacesCachedText|StreamedWithINCR)$|^TestX11ClipboardChangeLifecycle$' -count=1 -timeout=60s -v
env -u WAYLAND_DISPLAY GDK_BACKEND=x11 VIVA_TEST_GTK_CLIPBOARD_WATCH=x11 \
xvfb-run -a -s '-screen 0 1280x1024x24 -noreset' \
go test -tags vivagtk ./internal/platform/linux -run '^TestGTKClipboardChangeNative$' -count=1 -timeout=60s -v
# The browser target is a release target: it compiles every package, runs the
# shared tests under GOOS=js, and builds the browser entry points and a guide.
# The browser gate below is separate so installing Playwright's system
# dependencies does not extend this job's critical path.
web:
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: set up Go with the WASM GC fix (golang/go#80499)
uses: actions/setup-go@v5
with:
go-version: '1.26.10'
cache: true
- name: vet the browser target
run: GOOS=js GOARCH=wasm go vet ./...
- name: test under the Go wasm runtime
run: |
# cmd/viva is the host build tool; its tests invoke a host Go toolchain
# and package installers, not the browser runtime.
# A package with no files for js/wasm (the native window backends,
# host-only tools) cannot be tested on this target; go list prints a
# blank line for it, which is dropped here.
packages=$(GOOS=js GOARCH=wasm CGO_ENABLED=0 \
go list -f '{{if .GoFiles}}{{.ImportPath}}{{end}}' ./... |
sed '/^$/d' | grep -v '^github.com/vivaui/viva/cmd/viva$')
# shellcheck disable=SC2086 # one package per word, by design
GOOS=js GOARCH=wasm go test $packages \
-exec="$(go env GOROOT)/lib/wasm/go_js_wasm_exec" -count=1
- name: build browser entry points
run: |
GOOS=js GOARCH=wasm go build \
./cmd/component-preview ./cmd/gallery-web \
./examples/guides/hello ./examples/guides/webview
# The docs previews and the gallery build through the same public command
# an application uses, so a break in the deployment path fails here.
- name: build the public web entry points
run: |
go run ./cmd/viva build --target web ./cmd/component-preview -o build/component-preview-web
go run ./cmd/viva build --target web ./cmd/gallery-web -o build/gallery-web
# The real browser gate. It builds the fixture and drives it through the
# three engines in parallel with the wasm tests above; most of its elapsed
# time is Playwright's GTK/GStreamer dependency install, which has no place
# on the wasm job's critical path.
web-browser:
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm
cache-dependency-path: tools/webcheck/package-lock.json
- name: build the browser verification fixture
run: go run ./cmd/viva build --target web ./tools/webcheck/fixture -o build/webcheck
- name: install the browser gate
run: |
npm ci --prefix tools/webcheck
tools/webcheck/node_modules/.bin/playwright install --with-deps chromium firefox webkit
# Each engine gets its own step so a failure names the engine that broke
# and the others still report their own result.
- name: drive the browser verification page (chromium, WebGL2)
run: node tools/webcheck/check.mjs --dir build/webcheck --browser chromium --renderer webgl2
- name: drive the browser verification page (chromium, Canvas2D fallback)
run: node tools/webcheck/check.mjs --dir build/webcheck --browser chromium --renderer canvas2d
- name: drive the browser verification page (firefox)
run: node tools/webcheck/check.mjs --dir build/webcheck --browser firefox --renderer auto
- name: drive the browser verification page (webkit)
run: node tools/webcheck/check.mjs --dir build/webcheck --browser webkit --renderer auto
# The whole test suite except the packages that carry darwin-only files, split
# over several runners. .github/scripts/test-packages.sh decides what this
# shard owns: a package with no darwin file behaves identically on every
# operating system, so it runs here once instead of on macOS as well.
test:
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: this shard's packages
run: |
.github/scripts/test-packages.sh linux "${{ matrix.shard }}" 3 > "$RUNNER_TEMP/packages"
sed 's/^/ /' "$RUNNER_TEMP/packages"
# NSIS is what makes the Windows installer tests build a real installer
# instead of skipping it: install it only in the shard that has them.
- name: NSIS
run: |
if grep -qE '/(cmd/viva|tools/winpkg)$' "$RUNNER_TEMP/packages"; then
# The runner's package lists are normally usable as they are, and
# refreshing them is the slow half of an install.
sudo apt-get install -y nsis ||
{ sudo apt-get update && sudo apt-get install -y nsis; }
fi
- name: test
run: |
# shellcheck disable=SC2046 # one package per word, by design
go test $(cat "$RUNNER_TEMP/packages") -count=1
# The one job that has to be on macOS: cgo reaches Cocoa there, and the
# packages that carry a darwin-only file can be tested nowhere else. Everything
# else is in the test job above.
darwin:
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Native AppKit notification focus and click
working-directory: internal/platform/darwin
run: |
xcrun clang -fno-objc-arc -Werror -Wno-deprecated-declarations testdata/window_notification.m -o "$RUNNER_TEMP/window-notification" -framework Cocoa -framework CoreText -framework Metal -framework QuartzCore
"$RUNNER_TEMP/window-notification"
# A package with no darwin file compiles to the same source on every
# operating system, so the lint job's `go vet ./...` already covers it;
# what is left here is the darwin build of the packages that have one. The
# tests of that set are bound by hdiutil, codesign and the linker rather
# than by the cores, so the two type-checks run beside them, not before.
- name: vet and test
run: |
status=0
# shellcheck disable=SC2046 # one package per word, by design
go vet $(.github/scripts/test-packages.sh darwin) & vet=$!
go vet -tags vivahead ./internal/platform/darwin ./headless/... & headless=$!
# shellcheck disable=SC2046 # one package per word, by design
go test $(.github/scripts/test-packages.sh darwin) -count=1 & tests=$!
for job in "$vet" "$headless" "$tests"; do
wait "$job" || status=1
done
exit "$status"
- name: Native Carbon global shortcut
env:
VIVA_NATIVE_GLOBAL_SHORTCUT_TEST: '1'
run: go test ./internal/platform/darwin -run '^TestNativeCarbonGlobalShortcut$' -count=1 -v
windows-materials:
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: windows-latest
env:
VIVA_SOFTWARE_RENDERING: '1'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
# WARP is a Windows API: this cannot run anywhere else. The file icon and
# native structure ABI tests are here for the same reason: they build only
# on Windows.
- name: Material contracts and controls (WARP)
run: go test ./internal/platform/windows ./ui ./components ./headless ./app -run 'Test(Backdrop|WindowBackdrop|OpeningMaximized|Notification|TaskbarCreated|CompositionClear|CompositionFallback|CompositionCreation|CustomBackdrop|AcrylicAccent|LegacyAcrylic|RoundedOutline|Translucent|MonospaceFamilies|FontWeights|(The)?MonoWeights|(The)?InterfaceWeights|EveryListedFamilyResolves|EngineReportsTheFontsUnderline|AlwaysOnTop|SaveDialogCheckbox|FileIcon|NativeStructureABI|ResizePresents|WindowSwapChain|LiveResize|FlipWindowResize|RedrawWaits|ContinuousRedraw|NoOpFrame|SameSize|ZeroSize|ResizeTimer|RedrawQueue|NativeRedrawMessage|CompositionSupersededFrame|DragPreview|QueuedMenuKeysLeaveTerminalCompositionWithItsOwner|MenuKeysPreserveSystemChordsAndShift|TerminalMenuStopsCapturingWhenWindowLosesFocus|DisabledIMEOffersMenuShortcutDuringComposition)' -count=1 -v
- name: Web view partitions
run: go test ./internal/platform/windows -run '^Test(APageWithoutAPartitionAsksForNoProfileOfItsOwn|APartitionNamesTheWebView2Profile|AnEphemeralPartitionIsAnOffTheRecordProfile|EphemeralPagesWithoutAPartitionEachGetAProfileOfTheirOwn)$' -count=1 -v
- name: Terminal keyboard routing
run: go test ./internal/platform/windows -run '^TestATerminalGetsEditingKeysAndChordsAsRawKeys$' -count=1 -v
- name: Native window and grouped taskbar icons
run: go test ./internal/platform/windows -run '^TestWindowIconUpdatesOnTheWindowThread$' -count=1 -v
- name: Non-activating desktop notification
env:
VIVA_TEST_NOTIFICATION_DESKTOP: '1'
run: go test ./internal/platform/windows -run '^TestNotificationNativeWindows$' -count=1 -v
- name: Native Windows global shortcut
env:
VIVA_NATIVE_GLOBAL_SHORTCUT_TEST: '1'
run: go test ./internal/platform/windows -run '^TestNativeGlobalShortcutRegistration$' -count=1 -v
- name: Native Direct2D text origins and hidden labels
run: go test ./internal/platform/windows -run '^Test(DirectTextLayoutOriginByValue|HiddenNativeEditorDoesNotDrawColorEmoji|TextEngineRasterizesProportionalText)$' -count=1 -v
# The installer contracts, including WinVerifyTrust's struct layout, only
# compile and run on Windows.
- name: Update installer contracts
run: go test ./update -count=1 -v
# A paint that arrives while a window is minimized is a Windows-only
# window management case, and the swap chain it would otherwise resize is
# what the taskbar previews.
- name: Minimized windows keep their visible frame
run: go test ./internal/platform/windows -run '^TestMinimizedPaintKeepsTheVisibleSwapChain$' -count=1 -v
# Cross-vet does not exercise the Windows ARM64 calling convention.
windows-arm64-text:
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: windows-11-arm
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
architecture: arm64
cache: true
- name: Native ARM64 Direct2D text origins
run: |
if ((go env GOARCH) -ne 'arm64') { throw 'Expected native ARM64 Go' }
go test ./internal/platform/windows -run '^TestDirectTextLayoutOriginByValue$' -count=1 -v
# A noise-tolerant benchmark regression gate for the pure-Go paths: the base
# revision and the pull request run the same benchmarks on the same runner,
# and a slowdown above benchmarks/history.sh's threshold (15% and at least
# 20 ns) or any new allocation fails. Platform, GPU and window benchmarks are
# deliberately out: they are not reproducible on a shared runner.
benchmarks:
needs: changes
if: needs.changes.outputs.code == 'true' && github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: checkout the base revision
run: |
git fetch --no-tags origin "${{ github.base_ref }}"
git worktree add --detach ../base FETCH_HEAD
- name: benchmark base
run: VIVA_ROOT=../base ./benchmarks/ci.sh /tmp/base.txt
- name: benchmark candidate
run: ./benchmarks/ci.sh /tmp/head.txt
- name: compare
run: go run ./tools/perfhistory compare -threshold 0.20 -min-ns 100 /tmp/base.txt < /tmp/head.txt
# The single check to require in branch protection. It reports success when
# every job this change needed passed and the rest were skipped, so a
# documentation-only pull request is green without running anything and a
# change that skipped a job by path filter can never sit pending forever.
passed:
name: ci passed
if: always()
needs: [changes, lint, dev-attributes, cross-vet, web, web-browser, test, darwin, windows-materials, windows-arm64-text, benchmarks]
runs-on: ubuntu-latest
steps:
- name: every job this change needed passed
run: |
for result in ${{ join(needs.*.result, ' ') }}; do
case "$result" in
success | skipped) ;;
*)
echo "a job ended $result: ${{ join(needs.*.result, ' ') }}" >&2
exit 1
;;
esac
done
# Release sizes on every change, without blocking: hello is over its own
# alarm limit while the ui/components boundary decision (see
# docs/benchmarks/2026-11-12-size-attribution-darwin-arm64.md) is open, so
# the job records the number on each run and the hard limit returns with
# the boundary. Builds the same targets benchmarks/size.sh checks on a
# release machine; remove continue-on-error when the limit is honest again.
size:
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: macos-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: release sizes
run: ./benchmarks/size.sh