mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-12-05 11:15:01 +03:00
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:
1 parent
9b43941b27
commit
2d38ee5f18
3 files changed
+141
-40
No files matched your search
@@ -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'
|
||||
|
||||
Reference in new issue
Block a user