ci(frontend): split desktop-only wasm smoke and macOS gallery gate

Update `native-playground.yml` for `desktop-leaf-only` and macOS checks:
- Skip `playground` Wasm build and `web-smoke.mjs` when `desktop-leaf-only` is true. Keep `affine_desktop` Wasm, `check-snapshot-prefixes.mjs`, and `verify-desktop-persistence.mjs`.
- Narrow macOS desktop tests to `affine-desktop --lib --features harness` while keeping `--all-targets` check coverage.
- Build `bs-harness` and `desktop-harness` together in `macos-headless`, and verify deterministic `desktop-harness gallery` output across two runs (`14` PNG files).

Add seven live desktop snapshot prefixes to `check-snapshot-prefixes.mjs` (`250` to `257`) and update `check-snapshot-prefixes.test.mjs` with a single-bundle CLI test.
This commit is contained in:
DarkSky committed 2026-12-05 11:11:27 +09:00
1 parent 9b43941b27
commit 2d38ee5f18
3 files changed
+141 -40

No files matched your search

+79 -35
View File
@@ -388,15 +388,16 @@ jobs:
- name: Build production WebAssembly bundles and check snapshot prefixes
id: wasm
env:
DESKTOP_LEAF_ONLY: ${{ needs.changes.outputs.desktop-leaf-only }}
run: |
set -euo pipefail
t0=$(date +%s)
playground_pkg=../../blocksuite/crates/playground/web/pkg
desktop_pkg=artifacts/desktop-pkg
wasm_target=target/wasm32-unknown-unknown/wasm-release-size
mkdir -p "$playground_pkg" "$desktop_pkg"
WASM_RUSTFLAGS="$(printf '%s\037%s\037%s' "--remap-path-prefix=$(cd ../.. && pwd)=/src" "--remap-path-prefix=${CARGO_HOME:-$HOME/.cargo}=/cargo" "-Ctarget-feature=+simd128")"
CARGO_ENCODED_RUSTFLAGS="$WASM_RUSTFLAGS" cargo build --locked --profile wasm-release-size -p playground --lib --target wasm32-unknown-unknown
CARGO_ENCODED_RUSTFLAGS="$WASM_RUSTFLAGS" cargo rustc --locked --profile wasm-release-size -p affine-desktop --lib --target wasm32-unknown-unknown --crate-type cdylib
optimize_bundle() {
local name="$1" pkg="$2"
@@ -410,20 +411,29 @@ jobs:
"$pkg/${name}_bg.wasm" -o "$pkg/${name}_bg.opt.wasm"
}
optimize_bundle playground "$playground_pkg"
CARGO_ENCODED_RUSTFLAGS="$WASM_RUSTFLAGS" cargo rustc --locked --profile wasm-release-size -p affine-desktop --lib --target wasm32-unknown-unknown --crate-type cdylib
optimize_bundle affine_desktop "$desktop_pkg"
node scripts/check-snapshot-prefixes.mjs \
"$playground_pkg/playground_bg.opt.wasm" \
"$desktop_pkg/affine_desktop_bg.opt.wasm"
mv "$playground_pkg/playground_bg.opt.wasm" "$playground_pkg/playground_bg.wasm"
mv "$desktop_pkg/affine_desktop_bg.opt.wasm" "$desktop_pkg/affine_desktop_bg.wasm"
WASM_RAW=$(wc -c < "$playground_pkg/playground_bg.wasm" | tr -d ' ')
WASM_GZIP=$(gzip -9 -c "$playground_pkg/playground_bg.wasm" | wc -c | tr -d ' ')
echo "raw=$WASM_RAW" >> "$GITHUB_OUTPUT"
echo "gzip=$WASM_GZIP" >> "$GITHUB_OUTPUT"
if [ "${DESKTOP_LEAF_ONLY:-false}" = "true" ]; then
node scripts/check-snapshot-prefixes.mjs "$desktop_pkg/affine_desktop_bg.opt.wasm"
mv "$desktop_pkg/affine_desktop_bg.opt.wasm" "$desktop_pkg/affine_desktop_bg.wasm"
else
CARGO_ENCODED_RUSTFLAGS="$WASM_RUSTFLAGS" cargo build --locked --profile wasm-release-size -p playground --lib --target wasm32-unknown-unknown
optimize_bundle playground "$playground_pkg"
node scripts/check-snapshot-prefixes.mjs \
"$playground_pkg/playground_bg.opt.wasm" \
"$desktop_pkg/affine_desktop_bg.opt.wasm"
mv "$playground_pkg/playground_bg.opt.wasm" "$playground_pkg/playground_bg.wasm"
mv "$desktop_pkg/affine_desktop_bg.opt.wasm" "$desktop_pkg/affine_desktop_bg.wasm"
WASM_RAW=$(wc -c < "$playground_pkg/playground_bg.wasm" | tr -d ' ')
WASM_GZIP=$(gzip -9 -c "$playground_pkg/playground_bg.wasm" | wc -c | tr -d ' ')
echo "raw=$WASM_RAW" >> "$GITHUB_OUTPUT"
echo "gzip=$WASM_GZIP" >> "$GITHUB_OUTPUT"
fi
echo "Build Wasm bundles $(( $(date +%s) - t0 ))" >> /tmp/np-wasm-timings.tsv
- name: Run headless Chromium Web smoke test
if: needs.changes.outputs.desktop-leaf-only != 'true'
run: |
t0=$(date +%s)
mkdir -p artifacts
@@ -720,36 +730,70 @@ jobs:
cargo test --locked -p ui --features harness --test metal_atlas_fence
- name: Test Desktop on macOS
env:
DESKTOP_LEAF_ONLY: ${{ needs.changes.outputs.desktop-leaf-only }}
run: |
cargo test --locked -p affine-desktop
if [ "${{ needs.changes.outputs.desktop-leaf-only }}" = "true" ]; then
set -euo pipefail
cargo test --locked -p affine-desktop --lib --features harness
if [ "${DESKTOP_LEAF_ONLY:-false}" = "true" ]; then
cargo check --locked -p affine-desktop --all-targets --features harness
fi
- name: Deterministic Metal headless render and audit
if: needs.changes.outputs.desktop-leaf-only != 'true'
env:
DESKTOP_LEAF_ONLY: ${{ needs.changes.outputs.desktop-leaf-only }}
run: |
set -euo pipefail
mkdir -p artifacts
cargo build --locked --profile test -p affine-desktop -p playground --features playground/harness --bin bs-harness
./target/debug/bs-harness render \
--out artifacts/macos-run1.png \
--snapshot artifacts/macos-run1.json \
--width 1280 \
--height 800
./target/debug/bs-harness render \
--out artifacts/macos-run2.png \
--snapshot artifacts/macos-run2.json \
--width 1280 \
--height 800
test -s artifacts/macos-run1.png
test -s artifacts/macos-run1.json
sha1=$(shasum -a 256 artifacts/macos-run1.png | awk '{print $1}')
sha2=$(shasum -a 256 artifacts/macos-run2.png | awk '{print $1}')
echo "Run 1 SHA256: $sha1"
echo "Run 2 SHA256: $sha2"
test "$sha1" = "$sha2"
cmp artifacts/macos-run1.json artifacts/macos-run2.json
./target/debug/bs-harness audit --snapshot artifacts/macos-run1.json
verify_desktop_gallery() {
local dir1="artifacts/desktop-gallery-1"
local dir2="artifacts/desktop-gallery-2"
rm -rf "$dir1" "$dir2"
./target/debug/desktop-harness gallery --out "$dir1"
./target/debug/desktop-harness gallery --out "$dir2"
local count=0
for f1 in "$dir1"/*.png; do
test -e "$f1"
test -s "$f1"
local name f2 sha1 sha2
name=$(basename "$f1")
f2="$dir2/$name"
test -s "$f2"
sha1=$( (shasum -a 256 "$f1" 2>/dev/null || sha256sum "$f1") | awk '{print $1}' )
sha2=$( (shasum -a 256 "$f2" 2>/dev/null || sha256sum "$f2") | awk '{print $1}' )
test "$sha1" = "$sha2"
cmp -s "$f1" "$f2"
count=$((count + 1))
done
echo "Desktop gallery verified: $count/14 PNGs byte-identical"
test "$count" -eq 14
}
if [ "${DESKTOP_LEAF_ONLY:-false}" = "true" ]; then
cargo build --locked --profile test -p affine-desktop --bin desktop-harness --features affine-desktop/harness
verify_desktop_gallery
else
cargo build --locked --profile test -p playground -p affine-desktop --bin bs-harness --bin desktop-harness --features playground/harness,affine-desktop/harness
./target/debug/bs-harness render \
--out artifacts/macos-run1.png \
--snapshot artifacts/macos-run1.json \
--width 1280 \
--height 800
./target/debug/bs-harness render \
--out artifacts/macos-run2.png \
--snapshot artifacts/macos-run2.json \
--width 1280 \
--height 800
test -s artifacts/macos-run1.png
test -s artifacts/macos-run1.json
sha1=$(shasum -a 256 artifacts/macos-run1.png | awk '{print $1}')
sha2=$(shasum -a 256 artifacts/macos-run2.png | awk '{print $1}')
echo "Run 1 SHA256: $sha1"
echo "Run 2 SHA256: $sha2"
test "$sha1" = "$sha2"
cmp artifacts/macos-run1.json artifacts/macos-run2.json
./target/debug/bs-harness audit --snapshot artifacts/macos-run1.json
verify_desktop_gallery
fi
- name: Upload macOS headless artifacts
if: needs.changes.outputs.desktop-leaf-only != 'true'
@@ -270,6 +270,13 @@ export const ZERO_IN_PRODUCTION = Object.freeze([
'desktop.inspector.frame.title.',
'desktop.sidebar.linked_doc.',
'edgeless.link_picker',
'desktop.settings.about.version.',
'desktop.settings.delete_workspace_confirm.body',
'desktop.settings.delete_workspace_confirm.close.icon',
'desktop.settings.delete_workspace_confirm.description',
'desktop.settings.delete_workspace_confirm.title',
'desktop.settings.storage.export',
'desktop.trash.select.',
]);
const WASM_MAGIC = new Uint8Array([0x00, 0x61, 0x73, 0x6d]);
@@ -245,6 +245,16 @@ const DISPLAY_AND_LINK_PICKER_PREFIXES = [
'edgeless.link_picker',
];
const SETTINGS_AND_TRASH_SELECT_PREFIXES = [
'desktop.settings.about.version.',
'desktop.settings.delete_workspace_confirm.body',
'desktop.settings.delete_workspace_confirm.close.icon',
'desktop.settings.delete_workspace_confirm.description',
'desktop.settings.delete_workspace_confirm.title',
'desktop.settings.storage.export',
'desktop.trash.select.',
];
const NON_OVERLAPPING_PREFIXES = new Set([
'desktop.explorer.display.body',
'desktop.explorer.display.icon',
@@ -253,6 +263,7 @@ const NON_OVERLAPPING_PREFIXES = new Set([
'desktop.trash_prompt.close.icon',
'desktop.trash_prompt.title',
...DISPLAY_AND_LINK_PICKER_PREFIXES,
...SETTINGS_AND_TRASH_SELECT_PREFIXES,
]);
/**
@@ -352,8 +363,8 @@ test('rejects bare snapshot container IDs in Wasm Data segments', () => {
}
});
test('verifies all 250 live prefixes including desktop production sources', () => {
assert.equal(ZERO_IN_PRODUCTION.length, 250);
test('verifies all 257 live prefixes including desktop production sources', () => {
assert.equal(ZERO_IN_PRODUCTION.length, 257);
const firstBatchAdditions = ZERO_IN_PRODUCTION.slice(81, 175);
assert.deepEqual(
firstBatchAdditions,
@@ -393,9 +404,20 @@ test('verifies all 250 live prefixes including desktop production sources', () =
'Shell container and dialog prefixes must stay sorted lexicographically'
);
assert.deepEqual(
ZERO_IN_PRODUCTION.slice(246),
ZERO_IN_PRODUCTION.slice(246, 250),
DISPLAY_AND_LINK_PICKER_PREFIXES
);
const settingsAndTrashAdditions = ZERO_IN_PRODUCTION.slice(250);
assert.deepEqual(
settingsAndTrashAdditions,
SETTINGS_AND_TRASH_SELECT_PREFIXES,
'Settings and trash select prefixes must match appended order'
);
assert.deepEqual(
settingsAndTrashAdditions,
[...settingsAndTrashAdditions].sort(),
'Settings and trash select prefixes must stay sorted lexicographically'
);
assert.equal(
new Set(ZERO_IN_PRODUCTION).size,
ZERO_IN_PRODUCTION.length,
@@ -450,6 +472,7 @@ test('verifies all 250 live prefixes including desktop production sources', () =
for (const prefix of [
...SHELL_CONTAINER_AND_DIALOG_PREFIXES,
...DISPLAY_AND_LINK_PICKER_PREFIXES,
...SETTINGS_AND_TRASH_SELECT_PREFIXES,
]) {
for (const existing of ZERO_IN_PRODUCTION) {
if (existing === prefix) continue;
@@ -473,7 +496,7 @@ test('verifies all 250 live prefixes including desktop production sources', () =
true,
`Missing prefixes in repo: ${result.missing.join(', ')}`
);
assert.equal(Object.keys(result.counts).length, 250);
assert.equal(Object.keys(result.counts).length, 257);
for (const prefix of [
...DESKTOP_PREFIXES,
...NEW_DESKTOP_PREFIXES,
@@ -483,6 +506,7 @@ test('verifies all 250 live prefixes including desktop production sources', () =
...EXPLORER_SNAPSHOT_PREFIXES,
...SHELL_CONTAINER_AND_DIALOG_PREFIXES,
...DISPLAY_AND_LINK_PICKER_PREFIXES,
...SETTINGS_AND_TRASH_SELECT_PREFIXES,
]) {
assert.ok(
result.counts[prefix] >= 1,
@@ -561,6 +585,7 @@ test('fails CLI gate on desktop prefixes in Section 11 and ignores custom/code s
...EXPLORER_SNAPSHOT_PREFIXES,
...SHELL_CONTAINER_AND_DIALOG_PREFIXES,
...DISPLAY_AND_LINK_PICKER_PREFIXES,
...SETTINGS_AND_TRASH_SELECT_PREFIXES,
]) {
const payload = `${prefix}item-1`;
const wasm = buildWasm([buildPassiveDataSection([payload])]);
@@ -614,6 +639,16 @@ test('fails CLI gate on desktop prefixes in Section 11 and ignores custom/code s
['overlay.pdf_viewer.titlebar', /overlay\.pdf_viewer\.titlebar/],
['page.database_cell_caret', /page\.database_cell_caret/],
['root.canvas', /root\.canvas/],
[
'desktop.settings.about.version.app',
/desktop\.settings\.about\.version\./,
],
['desktop.trash.select.doc-1', /desktop\.trash\.select\./],
['desktop.settings.storage.export', /desktop\.settings\.storage\.export/],
[
'desktop.settings.delete_workspace_confirm.title',
/desktop\.settings\.delete_workspace_confirm\.title/,
],
]) {
const badWasm = join(dir, 'bad.wasm');
writeFileSync(badWasm, buildWasm([buildPassiveDataSection([sample])]));
@@ -630,6 +665,7 @@ test('fails CLI gate on desktop prefixes in Section 11 and ignores custom/code s
...EXTENDED_SNAPSHOT_PREFIXES,
...EXPLORER_SNAPSHOT_PREFIXES,
...DISPLAY_AND_LINK_PICKER_PREFIXES,
...SETTINGS_AND_TRASH_SELECT_PREFIXES,
].join(' '),
'utf8'
);
@@ -677,7 +713,21 @@ test('fails CLI gate on desktop prefixes in Section 11 and ignores custom/code s
encoding: 'utf8',
});
assert.equal(passRun.status, 0, passRun.stderr);
assert.match(passRun.stdout, /250\/250 prefixes at 0/);
assert.match(passRun.stdout, /257\/257 prefixes at 0/);
const desktopOnlyOptWasm = join(dir, 'affine_desktop_bg.opt.wasm');
writeFileSync(
desktopOnlyOptWasm,
buildWasm([buildPassiveDataSection(['desktop.settings.appearance'])])
);
const singleRun = spawnSync(
process.execPath,
[SCRIPT_PATH, desktopOnlyOptWasm],
{ encoding: 'utf8' }
);
assert.equal(singleRun.status, 0, singleRun.stderr);
assert.match(singleRun.stdout, /257\/257 prefixes at 0/);
assert.match(singleRun.stdout, /affine_desktop_bg\.opt\.wasm/);
} finally {
rmSync(dir, { recursive: true, force: true });
}