Repository navigation
570 lines (562 loc) · 29.5 KB
/
Copy pathci.yml
File metadata and controls
570 lines (562 loc) · 29.5 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
name: CI
on:
push:
branches: [main]
pull_request:
# Nightly on main: catches what changes without a commit (a new stable Rust, a runner image
# update) and runs the slow Windows self-test even on days without a merge.
schedule:
- cron: '23 4 * * *'
workflow_dispatch:
concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
# Every job runs on a GitHub-hosted runner (free for public repositories):
# macos-latest (Apple silicon), windows-latest and ubuntu-latest. There is no
# audio endpoint and no GPU on them, so the engine's device tests skip (except
# on Linux, which runs a headless PipeWire server) and the app smoke tests use
# a software renderer.
#
# The repository is public, so pull requests from forks run this workflow too.
# It never uses a self-hosted runner (that would run a stranger's code on our
# machine), uses no secrets, its token can only read the repository, and pull
# requests only restore caches (only pushes to main and the nightly run save
# them), so a pull request cannot plant a cache that main would use. Actions
# are pinned to full commit hashes; Dependabot keeps them current.
#
# Layout. Each system has two jobs that run side by side:
# tests (<system>) the engine's standalone CMake build (warnings as errors)
# and ctest, then `cargo test` over the workspace (debug);
# app (<system>) the app's release build and its smoke tests (a
# screenshot and the scripted self-test).
# plus `lint` (workflow, script and Rust formatting checks, seconds). The required checks are
# `build-test (macOS)`, `build-test (Windows)` and `build-test (Linux)`: each
# passes only when lint and every tests and app job passed, so one failure
# turns all three red (the failing job is named in the check list).
#
# Pull requests run only what their changes can reach (tools/ci/changes.sh):
# a documentation-only change builds nothing, an app-only change skips the
# standalone engine build, an engine-test-only change skips the app. Jobs that
# have nothing to do still run and pass, so the required checks always report.
# Pushes to main and the nightly run do everything.
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
# CI builds start from a restored target dir, never edit-compile loops, so
# incremental data is dead weight (bigger cache, slower builds). Line tables
# keep file:line in test backtraces.
CARGO_INCREMENTAL: "0"
CARGO_PROFILE_DEV_DEBUG: line-tables-only
# Every C/C++ compile (the standalone engine build and the one the engine's
# build script runs) goes through ccache, so an unchanged engine file is
# compiled once and then served from the cache. ccache hashes the compiler
# (path, size, mtime), its flags and the preprocessed source, so a changed
# header, flag or compiler misses.
CMAKE_C_COMPILER_LAUNCHER: ccache
CMAKE_CXX_COMPILER_LAUNCHER: ccache
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_NOHASHDIR: "true"
CCACHE_MAXSIZE: 1G
# Toolchain for `cargo fmt --check` and clippy (builds and tests use stable).
RUST_LINT_TOOLCHAIN: "1.97.0"
HOMEBREW_NO_AUTO_UPDATE: "1"
HOMEBREW_NO_INSTALL_CLEANUP: "1"
jobs:
lint:
name: lint
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# actionlint checks every workflow (expressions, job graph, action inputs)
# and runs shellcheck over their `run:` scripts. Pinned release, checked
# against its published SHA-256.
- name: Workflows (actionlint + shellcheck)
run: |
v=1.7.12
curl -sSfL -o "$RUNNER_TEMP/actionlint.tar.gz" "https://github.com/rhysd/actionlint/releases/download/v$v/actionlint_${v}_linux_amd64.tar.gz"
echo "8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8 $RUNNER_TEMP/actionlint.tar.gz" | sha256sum -c -
tar -xzf "$RUNNER_TEMP/actionlint.tar.gz" -C "$RUNNER_TEMP" actionlint
"$RUNNER_TEMP/actionlint" -color
- name: CI scripts (shellcheck)
run: shellcheck -S warning tools/ci/*.sh tools/release/*.sh tools/*.sh
- name: Change detection (tools/ci/changes.sh)
run: tools/ci/test-changes.sh
- name: Release notes extraction
run: tools/release/test-changelog-notes.sh
- name: Release scanner lookup (tools/release/find-scanner.sh)
run: tools/release/test-find-scanner.sh
- name: Agent skills
run: python3 tools/agents/check_skills.py
# Formatting is checked with a pinned toolchain (RUST_LINT_TOOLCHAIN,
# also used for clippy in `tests (Linux)`), so a new stable Rust cannot
# turn the job red overnight. Raise the pin by hand, in its own change.
- name: Rust formatting (cargo fmt --check)
run: |
rustup toolchain install "$RUST_LINT_TOOLCHAIN" --profile minimal --component rustfmt --no-self-update
cargo "+$RUST_LINT_TOOLCHAIN" fmt --all --check
- name: Engine pin checker (offline self-test)
run: tools/ci/engine_pins.py --self-test
tests:
name: tests (${{ matrix.name }})
strategy:
fail-fast: false
matrix:
include:
- name: macOS
runner: macos-latest
- name: Windows
runner: windows-latest
- name: Linux
runner: ubuntu-latest
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 2 # the merge commit and its base, for the change check
- name: What this change needs
id: changes
shell: bash
run: |
if [ "$GITHUB_EVENT_NAME" = pull_request ]; then
git diff --name-only HEAD^1 HEAD > "$RUNNER_TEMP/changed.txt"
cat "$RUNNER_TEMP/changed.txt"
tools/ci/changes.sh < "$RUNNER_TEMP/changed.txt" > "$RUNNER_TEMP/needs.txt"
else
printf 'engine=true\nrust=true\napp=true\n' > "$RUNNER_TEMP/needs.txt"
fi
tee -a "$GITHUB_OUTPUT" < "$RUNNER_TEMP/needs.txt"
if grep -qE '^(engine|rust)=true' "$RUNNER_TEMP/needs.txt"; then run=true; else run=false; echo "Nothing in this change reaches the engine or Rust tests: skipping them."; fi
echo "run=$run" | tee -a "$GITHUB_OUTPUT"
- name: Rust toolchain (stable)
if: steps.changes.outputs.run == 'true'
shell: bash
run: |
rustup toolchain install stable --profile minimal --no-self-update
rustup default stable
- name: Install build tools and system packages (Linux)
if: runner.os == 'Linux' && steps.changes.outputs.run == 'true'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends ninja-build pkg-config ccache \
xvfb mesa-vulkan-drivers \
libpipewire-0.3-dev libasound2-dev \
libxkbcommon-dev libxkbcommon-x11-dev libwayland-dev libx11-dev libx11-xcb-dev \
libxcursor-dev libxrandr-dev libxi-dev libfontconfig1-dev libfreetype-dev libudev-dev \
pipewire pipewire-bin wireplumber dbus
- name: Install Ninja and ccache (macOS)
if: runner.os == 'macOS' && steps.changes.outputs.run == 'true'
run: brew install ninja ccache
- name: Install ccache (Windows)
if: runner.os == 'Windows' && steps.changes.outputs.run == 'true'
shell: pwsh
run: |
$v = '4.12.1'
$zip = Join-Path $env:RUNNER_TEMP 'ccache.zip'
Invoke-WebRequest "https://github.com/ccache/ccache/releases/download/v$v/ccache-$v-windows-x86_64.zip" -OutFile $zip
$hash = (Get-FileHash $zip -Algorithm SHA256).Hash
if ($hash -ne '98AEA520D66905B8BA7A8E648A4CC0CA941D5E119D441F1E879A4A9045BF18F6') { throw "ccache zip checksum mismatch: $hash" }
Expand-Archive $zip -DestinationPath $env:RUNNER_TEMP
Join-Path $env:RUNNER_TEMP "ccache-$v-windows-x86_64" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8
- name: MSVC developer environment (Windows)
if: runner.os == 'Windows' && steps.changes.outputs.run == 'true'
shell: pwsh
run: |
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$vs = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
if (-not $vs) { throw "no Visual Studio with the C++ x64 tools" }
cmd /c "`"$vs\VC\Auxiliary\Build\vcvars64.bat`" >nul && set" | ForEach-Object {
if ($_ -match '^([^=]+)=(.*)$') { "$($Matches[1])=$($Matches[2])" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 }
}
- name: Tool versions and build directories
if: steps.changes.outputs.run == 'true'
shell: bash
run: |
cmake --version | head -1
ninja --version
ccache --version | head -1
rustc --version
if [ "$RUNNER_OS" = "Windows" ]; then cl 2>&1 | head -1; else c++ --version | head -1; fi
echo "CARGO_TARGET_DIR=$GITHUB_WORKSPACE/target" >> "$GITHUB_ENV"
echo "DSTUDIO_DEPS_DIR=$GITHUB_WORKSPACE/.deps" >> "$GITHUB_ENV"
# The SDK downloads, the cargo target dir (debug builds only in this
# job) and the ccache store are restored on every run but saved only by
# pushes to main and the nightly run. Pull requests then start from
# main's latest build, and their own saves cannot fill the repository's
# 10 GB cache and evict main's.
- name: Restore SDK downloads
id: deps-cache
if: steps.changes.outputs.engine == 'true'
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .deps
key: deps-${{ runner.os }}-${{ hashFiles('engine/CMakeLists.txt') }}
# The cargo and ccache keys are new on every save. The cargo-v2 fallback
# is the layout before the tests/app split (one cache with both profiles).
- name: Restore cargo registry and target
if: steps.changes.outputs.run == 'true'
id: cargo-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
target
key: cargo-v3-${{ runner.os }}-tests-${{ hashFiles('Cargo.lock') }}-${{ github.sha }}
restore-keys: |
cargo-v3-${{ runner.os }}-tests-${{ hashFiles('Cargo.lock') }}-
cargo-v3-${{ runner.os }}-tests-
cargo-v2-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}-
cargo-v2-${{ runner.os }}-
- name: Restore ccache
if: steps.changes.outputs.run == 'true'
id: ccache-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .ccache
key: ccache-v2-${{ runner.os }}-tests-${{ github.sha }}
restore-keys: |
ccache-v2-${{ runner.os }}-tests-
ccache-${{ runner.os }}-
# See tools/ci/prepare-target.sh: keeps this job's profile only, makes
# every source newer than the restored build, drops CMake caches made in
# another checkout and the engine build script's output.
- name: Prepare the restored build
if: steps.changes.outputs.run == 'true'
shell: bash
run: tools/ci/prepare-target.sh debug
- name: Engine — configure
if: steps.changes.outputs.engine == 'true'
run: cmake -S engine -B engine/build-ci -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDSTUDIO_ENGINE_WERROR=ON "-DFETCHCONTENT_BASE_DIR=${{ env.DSTUDIO_DEPS_DIR }}"
- name: Engine — build
if: steps.changes.outputs.engine == 'true'
run: cmake --build engine/build-ci -- -k 0
# Linux has no sound card on the hosted runner, but it can run a real
# PipeWire server: a null sink (driven by the system clock like a
# device) and a loopback from its monitor to a virtual source. The
# device tests then open real PipeWire streams, and the duplex
# loopback tests (ctest and cargo) record what the engine plays and
# check every click lands at its timeline position
# (tools/ci/headless-pipewire.sh).
- name: Headless PipeWire graph (Linux)
if: runner.os == 'Linux' && steps.changes.outputs.run == 'true'
run: |
tools/ci/headless-pipewire.sh | sed -e "s/^export //" -e "s/'//g" >> "$GITHUB_ENV"
echo "DSTUDIO_TEST_LOOPBACK_INPUT=dstudio-loop-source" >> "$GITHUB_ENV"
- name: Engine — test
if: steps.changes.outputs.engine == 'true'
run: ctest --test-dir engine/build-ci --output-on-failure -j 4
- name: Engine — PipeWire device tests, verbose (Linux)
if: runner.os == 'Linux' && steps.changes.outputs.engine == 'true' && !cancelled()
run: ctest --test-dir engine/build-ci -V -R "^(device_|transport_commands_across_device)"
# Plugin editor windows (X11): the main test run has no display, so the
# editor test skips there; here it opens the GUI test plugin's window on
# Xvfb and checks its size, its timer and fd callbacks, and closing.
- name: Engine — plugin editor windows on Xvfb (Linux)
if: runner.os == 'Linux' && steps.changes.outputs.engine == 'true' && !cancelled()
run: xvfb-run -a ctest --test-dir engine/build-ci --output-on-failure -R "^plugin_editor_window_x11"
# Runs even when the engine tests failed (both results are reported; the
# job still fails). cargo test compiles every crate of the workspace, so
# there is no separate debug `cargo build`.
- name: Rust workspace — test
if: steps.changes.outputs.rust == 'true' && !cancelled()
run: cargo test --workspace --locked --no-fail-fast
# Clippy over every target with warnings as errors, on Linux only (the
# lints are the same on every system) and with the pinned lint toolchain.
- name: Rust workspace — clippy (Linux)
if: runner.os == 'Linux' && steps.changes.outputs.rust == 'true' && !cancelled()
run: |
rustup toolchain install "$RUST_LINT_TOOLCHAIN" --profile minimal --component clippy --no-self-update
cargo "+$RUST_LINT_TOOLCHAIN" clippy --workspace --all-targets --locked -- -D warnings
- name: ccache statistics
if: steps.changes.outputs.run == 'true' && !cancelled()
run: ccache --show-stats
- name: Save SDK downloads
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && steps.changes.outputs.engine == 'true' && steps.deps-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .deps
key: ${{ steps.deps-cache.outputs.cache-primary-key }}
- name: Save cargo registry and target
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && steps.changes.outputs.run == 'true' && !cancelled()
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
target
key: ${{ steps.cargo-cache.outputs.cache-primary-key }}
- name: Save ccache
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && steps.changes.outputs.run == 'true' && !cancelled()
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .ccache
key: ${{ steps.ccache-cache.outputs.cache-primary-key }}
app:
name: app (${{ matrix.name }})
strategy:
fail-fast: false
matrix:
include:
- name: macOS
runner: macos-latest
- name: Windows
runner: windows-latest
- name: Linux
runner: ubuntu-latest
runs-on: ${{ matrix.runner }}
# The Windows self-test under WARP alone takes about 30 minutes.
timeout-minutes: 90
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 2 # the merge commit and its base, for the change check
- name: What this change needs
id: changes
shell: bash
run: |
if [ "$GITHUB_EVENT_NAME" = pull_request ]; then
git diff --name-only HEAD^1 HEAD > "$RUNNER_TEMP/changed.txt"
cat "$RUNNER_TEMP/changed.txt"
tools/ci/changes.sh < "$RUNNER_TEMP/changed.txt" > "$RUNNER_TEMP/needs.txt"
else
printf 'engine=true\nrust=true\napp=true\n' > "$RUNNER_TEMP/needs.txt"
fi
cat "$RUNNER_TEMP/needs.txt"
if grep -q '^app=true' "$RUNNER_TEMP/needs.txt"; then run=true; else run=false; echo "Nothing in this change reaches the app: skipping its build and smoke tests."; fi
echo "run=$run" | tee -a "$GITHUB_OUTPUT"
- name: Rust toolchain (stable)
if: steps.changes.outputs.run == 'true'
shell: bash
run: |
rustup toolchain install stable --profile minimal --no-self-update
rustup default stable
- name: Install build tools and system packages (Linux)
if: runner.os == 'Linux' && steps.changes.outputs.run == 'true'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends ninja-build pkg-config ccache \
xvfb mesa-vulkan-drivers \
libpipewire-0.3-dev libasound2-dev \
libxkbcommon-dev libxkbcommon-x11-dev libwayland-dev libx11-dev libx11-xcb-dev \
libxcursor-dev libxrandr-dev libxi-dev libfontconfig1-dev libfreetype-dev libudev-dev \
pipewire pipewire-bin wireplumber dbus
- name: Install Ninja and ccache (macOS)
if: runner.os == 'macOS' && steps.changes.outputs.run == 'true'
run: brew install ninja ccache
- name: Install ccache (Windows)
if: runner.os == 'Windows' && steps.changes.outputs.run == 'true'
shell: pwsh
run: |
$v = '4.12.1'
$zip = Join-Path $env:RUNNER_TEMP 'ccache.zip'
Invoke-WebRequest "https://github.com/ccache/ccache/releases/download/v$v/ccache-$v-windows-x86_64.zip" -OutFile $zip
$hash = (Get-FileHash $zip -Algorithm SHA256).Hash
if ($hash -ne '98AEA520D66905B8BA7A8E648A4CC0CA941D5E119D441F1E879A4A9045BF18F6') { throw "ccache zip checksum mismatch: $hash" }
Expand-Archive $zip -DestinationPath $env:RUNNER_TEMP
Join-Path $env:RUNNER_TEMP "ccache-$v-windows-x86_64" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8
- name: MSVC developer environment (Windows)
if: runner.os == 'Windows' && steps.changes.outputs.run == 'true'
shell: pwsh
run: |
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$vs = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
if (-not $vs) { throw "no Visual Studio with the C++ x64 tools" }
cmd /c "`"$vs\VC\Auxiliary\Build\vcvars64.bat`" >nul && set" | ForEach-Object {
if ($_ -match '^([^=]+)=(.*)$') { "$($Matches[1])=$($Matches[2])" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 }
}
- name: Tool versions and build directories
if: steps.changes.outputs.run == 'true'
shell: bash
run: |
cmake --version | head -1
ninja --version
ccache --version | head -1
rustc --version
if [ "$RUNNER_OS" = "Windows" ]; then cl 2>&1 | head -1; else c++ --version | head -1; fi
echo "CARGO_TARGET_DIR=$GITHUB_WORKSPACE/target" >> "$GITHUB_ENV"
- name: Restore cargo registry and target
if: steps.changes.outputs.run == 'true'
id: cargo-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
target
key: cargo-v3-${{ runner.os }}-app-${{ hashFiles('Cargo.lock') }}-${{ github.sha }}
restore-keys: |
cargo-v3-${{ runner.os }}-app-${{ hashFiles('Cargo.lock') }}-
cargo-v3-${{ runner.os }}-app-
cargo-v2-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}-
cargo-v2-${{ runner.os }}-
- name: Restore ccache
if: steps.changes.outputs.run == 'true'
id: ccache-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .ccache
key: ccache-v2-${{ runner.os }}-app-${{ github.sha }}
restore-keys: |
ccache-v2-${{ runner.os }}-app-
ccache-${{ runner.os }}-
- name: Prepare the restored build
if: steps.changes.outputs.run == 'true'
shell: bash
run: tools/ci/prepare-target.sh release
# Release build: the build users run.
- name: App — release build
if: steps.changes.outputs.run == 'true'
run: cargo build --release -p dstudio-app --locked
- name: ccache statistics
if: steps.changes.outputs.run == 'true' && !cancelled()
run: ccache --show-stats
# Saved before the smoke tests, so a hung self-test cannot lose them.
- name: Save cargo registry and target
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && steps.changes.outputs.run == 'true' && !cancelled()
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
target
key: ${{ steps.cargo-cache.outputs.cache-primary-key }}
- name: Save ccache
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && steps.changes.outputs.run == 'true' && !cancelled()
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .ccache
key: ${{ steps.ccache-cache.outputs.cache-primary-key }}
# App smoke tests without a GPU or audio device: a reference-state
# screenshot and the scripted self-test, on a software renderer (Linux:
# Xvfb + Mesa lavapipe Vulkan; Windows: WARP via DX12). The self-test
# prints "self-test: P / N checks passed"; P must equal N (skipped checks
# are not counted in N), checked by tools/ci/self-test.sh.
- name: App — self-test (macOS)
if: runner.os == 'macOS' && steps.changes.outputs.run == 'true'
env:
RUST_BACKTRACE: "1"
run: tools/ci/self-test.sh macos "$CARGO_TARGET_DIR/release/device-studio" --self-test --no-audio
# Two self-tests: --no-audio (offline rendering and export, like macOS and
# Windows) and --self-test-audio (plays, records and exports through the
# headless PipeWire graph: a real output stream). Each takes about six
# minutes under lavapipe and they share nothing (each run has its own
# scratch folder), so they run side by side on their own X servers, with
# the screenshot: 6.3 minutes for both instead of 12.3 back to back on a
# 4-core machine, both passing.
- name: Headless PipeWire graph (Linux)
if: runner.os == 'Linux' && steps.changes.outputs.run == 'true'
run: tools/ci/headless-pipewire.sh | sed -e "s/^export //" -e "s/'//g" >> "$GITHUB_ENV"
- name: App — screenshot and self-tests (Linux, Xvfb + lavapipe)
if: runner.os == 'Linux' && steps.changes.outputs.run == 'true'
env:
WGPU_BACKEND: vulkan
SLINT_WGPU_CPU: "1" # Slint refuses CPU adapters (lavapipe) unless allowed
RUST_BACKTRACE: "1"
run: |
app="$CARGO_TARGET_DIR/release/device-studio"
xvfb-run -n 90 -s "-screen 0 1600x1000x24" "$app" --state reference-default --screenshot app-linux.png > "$RUNNER_TEMP/screenshot.log" 2>&1 &
shot=$!
tools/ci/self-test.sh linux xvfb-run -n 91 -s "-screen 0 1600x1000x24" "$app" --self-test --no-audio > "$RUNNER_TEMP/selftest.log" 2>&1 &
plain=$!
tools/ci/self-test.sh linux-audio xvfb-run -n 92 -s "-screen 0 1600x1000x24" "$app" --self-test-audio > "$RUNNER_TEMP/selftest-audio.log" 2>&1 &
audio=$!
shot_status=0; wait "$shot" || shot_status=$?
plain_status=0; wait "$plain" || plain_status=$?
audio_status=0; wait "$audio" || audio_status=$?
echo "::group::screenshot (exit status $shot_status)"; cat "$RUNNER_TEMP/screenshot.log"; echo "::endgroup::"
echo "::group::self-test --no-audio"; cat "$RUNNER_TEMP/selftest.log"; echo "::endgroup::"
echo "::group::self-test --self-test-audio"; cat "$RUNNER_TEMP/selftest-audio.log"; echo "::endgroup::"
grep -h -E "^self-test" "$RUNNER_TEMP/selftest.log" "$RUNNER_TEMP/selftest-audio.log"
if [ "$shot_status" -ne 0 ] || [ ! -s app-linux.png ]; then echo "::error title=Screenshot failed (Linux)::exit status $shot_status"; exit 1; fi
[ "$plain_status" -eq 0 ] && [ "$audio_status" -eq 0 ]
# A non-zero exit code, a missing screenshot or self-test summary, or a
# failed check fails the step.
- name: App — screenshot (Windows, WARP)
if: runner.os == 'Windows' && steps.changes.outputs.run == 'true'
timeout-minutes: 5
shell: pwsh
env:
WGPU_BACKEND: dx12
SLINT_WGPU_CPU: "1" # Slint refuses CPU adapters (WARP) unless allowed
RUST_BACKTRACE: "1"
run: |
$exe = Join-Path $env:CARGO_TARGET_DIR "release\device-studio.exe"
$p = Start-Process -FilePath $exe -ArgumentList '--state','reference-default','--screenshot','app-windows.png' -NoNewWindow -Wait -PassThru -RedirectStandardError shot-windows-stderr.txt
Get-Content shot-windows-stderr.txt
"screenshot run exit code: 0x{0:X8}" -f $p.ExitCode
if (-not (Test-Path app-windows.png)) { throw "no screenshot" }
if ($p.ExitCode -ne 0) { throw "the app exited with 0x{0:X8}" -f $p.ExitCode }
# The full self-test under WARP takes about 30 minutes (the software
# renderer is capped at two frames in flight so it no longer runs out of
# memory), so pull requests skip it unless they carry the
# `windows-self-test` label (add the label, then push). Pushes to main,
# the nightly run and manual runs always run it, and a failure fails the
# job.
- name: App — self-test (Windows, WARP)
if: >-
runner.os == 'Windows' && steps.changes.outputs.run == 'true' &&
(github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'windows-self-test'))
timeout-minutes: 60
shell: pwsh
env:
WGPU_BACKEND: dx12
SLINT_WGPU_CPU: "1"
RUST_BACKTRACE: "1"
run: |
$exe = Join-Path $env:CARGO_TARGET_DIR "release\device-studio.exe"
$start = Get-Date
$p = Start-Process -FilePath $exe -ArgumentList '--self-test','--no-audio' -NoNewWindow -Wait -PassThru -RedirectStandardOutput selftest-windows.txt -RedirectStandardError selftest-windows-stderr.txt
"self-test exit code: 0x{0:X8} after {1:N0} s" -f $p.ExitCode, ((Get-Date) - $start).TotalSeconds
Select-String -Path selftest-windows.txt -Pattern '^(FAIL|SKIP)' | ForEach-Object { $_.Line }
Select-String -Path selftest-windows-stderr.txt -Pattern 'frames waited for the GPU' | ForEach-Object { $_.Line }
$line = (Select-String -Path selftest-windows.txt -Pattern '^self-test: (\d+) / (\d+) checks passed').Matches | Select-Object -First 1
if (-not $line) { Get-Content selftest-windows-stderr.txt -Tail 30; throw "no self-test summary" }
$line.Value
if ($line.Groups[1].Value -ne $line.Groups[2].Value) { throw "self-test failures" }
if ($p.ExitCode -ne 0) { throw "the self-test passed but the app exited with 0x{0:X8}" -f $p.ExitCode }
- name: Upload app screenshots and self-test logs
if: steps.changes.outputs.run == 'true' && !cancelled()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: app-${{ runner.os }}
path: |
app-*.png
selftest-*.txt
shot-*.txt
if-no-files-found: ignore
retention-days: 14
# The required checks. One per system so branch protection keeps the names it
# already requires; each passes only when every job above passed (a job with
# nothing to do for a change passes too).
build-test:
name: build-test (${{ matrix.name }})
needs: [lint, tests, app]
if: ${{ !cancelled() }}
strategy:
matrix:
name: [macOS, Windows, Linux]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Every CI job passed
env:
LINT: ${{ needs.lint.result }}
TESTS: ${{ needs.tests.result }}
APP: ${{ needs.app.result }}
run: |
echo "lint: $LINT"
echo "tests (all systems): $TESTS"
echo "app (all systems): $APP"
[ "$LINT" = success ] && [ "$TESTS" = success ] && [ "$APP" = success ]