diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml index 8d5da5149..defe1d6fa 100644 --- a/.github/workflows/mobile.yml +++ b/.github/workflows/mobile.yml @@ -76,7 +76,7 @@ jobs: ios: if: ${{ !inputs.android_only && github.event_name == 'workflow_dispatch' && inputs.platforms != 'android' }} runs-on: macos-26 - timeout-minutes: 60 + timeout-minutes: 90 steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: @@ -95,49 +95,70 @@ jobs: node-version: '24' cache: pnpm cache-dependency-path: pnpm-lock.yaml + # The app embeds no commit, so a rerun or an unrelated change reuses the app built from the + # same inputs, Xcode image and Rust toolchain instead of spending its build again. + - name: Key the simulator app by its inputs + id: app + run: echo "key=ios-simulator-app-$ImageOS-$ImageVersion-$( (rustc -V; node -v) | shasum -a 256 | cut -c1-16)-${{ hashFiles('apps/mobile/**', 'packages/**', '!packages/docs/**', 'crates/**', 'config/**', 'package.json', 'pnpm-workspace.yaml', 'Cargo.toml', 'Cargo.lock', 'pnpm-lock.yaml', 'scripts/build-mobile-secure.sh', '!**/node_modules/**') }}" >> "$GITHUB_OUTPUT" + - name: Restore the simulator app built from the same inputs + id: app_cache + uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 + with: + path: .artifacts/native/ios-build/Build/Products/Release-iphonesimulator/Vibeface.app + key: ${{ steps.app.outputs.key }} - run: pnpm install --frozen-lockfile - - run: scripts/build-mobile-secure.sh ios + - if: steps.app_cache.outputs.cache-hit != 'true' + run: scripts/build-mobile-secure.sh ios - name: Build the simulator app + if: steps.app_cache.outputs.cache-hit != 'true' working-directory: apps/mobile run: | - mkdir -p ../../.artifacts/native npx expo prebuild --platform ios xcodebuild -workspace ios/Vibeface.xcworkspace -scheme Vibeface -configuration Release \ -sdk iphonesimulator -destination 'generic/platform=iOS Simulator' ARCHS=arm64 \ -derivedDataPath ../../.artifacts/native/ios-build CODE_SIGN_IDENTITY=- CODE_SIGN_STYLE=Manual DEVELOPMENT_TEAM= build + # Only an app built from the committed sources, including the regenerated bindings, may be cached. + test -z "$(git status --porcelain --untracked-files=normal)" + - name: Save the simulator app for the same inputs + if: steps.app_cache.outputs.cache-hit != 'true' + uses: actions/cache/save@caa296126883cff596d87d8935842f9db880ef25 + with: + path: .artifacts/native/ios-build/Build/Products/Release-iphonesimulator/Vibeface.app + key: ${{ steps.app.outputs.key }} + - name: Package the simulator app + run: | + mkdir -p .artifacts/native # Ad-hoc signing writes the simulator entitlements into the binary; without them the Keychain refuses SecureStore. - otool -l ../../.artifacts/native/ios-build/Build/Products/Release-iphonesimulator/Vibeface.app/Vibeface | grep -q "sectname __entitlements" - cd ../../.artifacts/native/ios-build/Build/Products/Release-iphonesimulator + otool -l .artifacts/native/ios-build/Build/Products/Release-iphonesimulator/Vibeface.app/Vibeface | grep -q "sectname __entitlements" + cd .artifacts/native/ios-build/Build/Products/Release-iphonesimulator zip -qry "$GITHUB_WORKSPACE/.artifacts/native/vibeface-ios-simulator.zip" Vibeface.app - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 with: name: vibeface-ios-simulator-${{ github.sha }} path: .artifacts/native/vibeface-ios-simulator.zip if-no-files-found: error - - name: Build the same-source host Node and browser cryptography - env: - SOURCE_COMMIT: ${{ github.sha }} - CARGO_TARGET_DIR: ${{ github.workspace }}/.artifacts/native/target + # Booting the simulator before the host build overlaps its remaining startup work with the build + # instead of the UI run. The runner's own Spotlight indexing only adds load. + - name: Sample runner load until the job ends run: | - umask 077 - mkdir -p .artifacts/native/private - chmod 700 .artifacts/native .artifacts/native/private - printf '%s\n' host-source > .artifacts/native/private/stage.txt - test "$(git rev-parse HEAD)" = "$SOURCE_COMMIT" - test -z "$(git status --porcelain --untracked-files=normal)" - test "$(uname -m)" = arm64 - printf '%s\n' host-build > .artifacts/native/private/stage.txt - cargo install wasm-bindgen-cli --version 0.2.129 --locked - bash scripts/build-web-crypto.sh - bash scripts/build-web.sh - CARGO_ENCODED_RUSTFLAGS="$(python3 scripts/release-rustflags.py)" cargo build --release -p vibeface -p vibeface-core --locked - .artifacts/native/target/release/vibeface --version - .artifacts/native/target/release/vibeface-core --version + sudo mdutil -a -i off > /dev/null || true + nohup scripts/ci-runner-load.sh > .artifacts/native/runner-load.log 2>&1 & + - name: Install simslim + run: | + mkdir -p .artifacts/native/simslim + cd .artifacts/native/simslim + curl -fsSLo simslim.tar.gz https://github.com/MobAI-App/simslim/releases/download/v0.14.0/simslim-v0.14.0-macos-arm64.tar.gz + echo "a3db0de6f428f9f8fd5dff256b122f98791c138521dc1330d99643719d8fe9ff simslim.tar.gz" | shasum -a 256 -c + tar -xzf simslim.tar.gz simslim + echo "SIMSLIM=$PWD/simslim" >> "$GITHUB_ENV" - name: Create the dedicated iOS Provider simulator env: + SIMSLIM_BOOT_TIMEOUT: 15m + SIMSLIM_SPAWN_TIMEOUT: 5m VIBEFACE_E2E_SOURCE_COMMIT: ${{ github.sha }} run: | umask 077 + mkdir -p .artifacts/native/private python3 - <<'PY' import json, os, pathlib, platform, re, subprocess pathlib.Path(".artifacts/native/private/stage.txt").write_text("simulator-create\n") @@ -161,9 +182,30 @@ jobs: "VIBEFACE_E2E_APP_DIR": str(pathlib.Path("apps/app/dist/client").resolve()), "VIBEFACE_E2E_CRYPTO_MODULE": str(pathlib.Path("apps/app/dist/client/vibeface_secure.js").resolve())}.items(): output.write(key + "=" + value + "\n") - subprocess.run(["xcrun", "simctl", "boot", simulator], check=True) + # Boots once, turns off the widget, search and other daemons the app does not use, then boots slim. + # Keeps photos, push, keychain, links, connectivity and assets that the app or its tests rely on. + subprocess.run([os.environ["SIMSLIM"], "on", simulator, "--except", "photos,store,icloud,web,connectivity,other,mdm"], check=True) subprocess.run(["xcrun", "simctl", "bootstatus", simulator, "-b"], check=True) PY + - name: Build the same-source host Node and browser cryptography + env: + SOURCE_COMMIT: ${{ github.sha }} + CARGO_TARGET_DIR: ${{ github.workspace }}/.artifacts/native/target + run: | + umask 077 + mkdir -p .artifacts/native/private + chmod 700 .artifacts/native .artifacts/native/private + printf '%s\n' host-source > .artifacts/native/private/stage.txt + test "$(git rev-parse HEAD)" = "$SOURCE_COMMIT" + test -z "$(git status --porcelain --untracked-files=normal)" + test "$(uname -m)" = arm64 + printf '%s\n' host-build > .artifacts/native/private/stage.txt + cargo install wasm-bindgen-cli --version 0.2.129 --locked + bash scripts/build-web-crypto.sh + bash scripts/build-web.sh + CARGO_ENCODED_RUSTFLAGS="$(python3 scripts/release-rustflags.py)" cargo build --release -p vibeface -p vibeface-core --locked + .artifacts/native/target/release/vibeface --version + .artifacts/native/target/release/vibeface-core --version - name: Prepare the task simulator's XCTest runner env: AGENT_DEVICE_HOME: ${{ github.workspace }}/.artifacts/native/agent-device @@ -289,6 +331,9 @@ jobs: set -e echo "Native Provider e2e exit code: $result" exit "$result" + - name: Show runner load during the run + if: always() + run: cat .artifacts/native/runner-load.log 2>/dev/null || true - name: Remove only this task simulator and private acceptance state id: native_cleanup if: always() diff --git a/packages/docs/ci.md b/packages/docs/ci.md index 416264a89..f266935a0 100644 --- a/packages/docs/ci.md +++ b/packages/docs/ci.md @@ -306,4 +306,4 @@ GitHub 主分支规则不要求 PR 先更新到最新 base,也不将 `ci-gate` 桌面测试使用打包应用自身的 DevTools 页面,核对真实 Electron 版本、窗口隔离、内置包来源、自有 Core、退出和重启。测试预先用包内 CLI 建立不入全网(`--no-mesh`)的独立 Node,随后由真实启动器启动并持有 Core;首次初始化逻辑另由桌面会话测试覆盖。Windows 另外核对真实 SID/DACL、维护通道、Unicode 路径、Provider 子进程回收和当前用户服务。Unix shell、Unix 权限位及 Linux 证明宿主夹具保留在 Unix 测试中;协调器的协议测试在两端使用各自的私有 IPC。所有 Provider 均为受控夹具,不调用真实模型。 -原生移动端构建可使用 `ci.yml` 的 `mobile_apps=ios|android|both`。`both` 让两个系统并行构建,`mobile-gate` 只验收选中的系统。iOS 设备归档验证不等同于模拟器界面或真机安装验收;现有 `mobile.yml` 保留模拟器界面测试。手动移动端验收按运行编号隔离并行,避免新提交取消尚在验证的专用模拟器任务。缺少 iOS 分发身份时,未签名设备归档的收据必须保留不可安装状态。 +原生移动端构建可使用 `ci.yml` 的 `mobile_apps=ios|android|both`。`both` 让两个系统并行构建,`mobile-gate` 只验收选中的系统。iOS 设备归档验证不等同于模拟器界面或真机安装验收;现有 `mobile.yml` 保留模拟器界面测试。手动移动端验收按运行编号隔离并行,避免新提交取消尚在验证的专用模拟器任务。缺少 iOS 分发身份时,未签名设备归档的收据必须保留不可安装状态。 iOS 模拟器 app 按输入缓存:键包含 runner 镜像版本、rustc 版本和 `apps/mobile`、`packages`、`crates`、`config`、根 `package.json`、`pnpm-workspace.yaml`、lock 文件及 `build-mobile-secure.sh` 的摘要(不含 `packages/docs`),以及 Node 版本;构建后工作树必须干净才写缓存,命中时跳过安全库和 Xcode 构建,仍核对 entitlements。专用模拟器在主机构建前由 simslim v0.14.0 开机并精简:关闭小组件、Spotlight、Siri、健康、家庭、新闻地图、遥测、邮件日历和信息类后台服务,保留相册、推送、钥匙串、链接、互联和资源服务,让首启负载与主机构建重叠;runner 的 Spotlight 索引同时关闭。从安装 simslim 前起,`scripts/ci-runner-load.sh` 每 10 秒记录负载、空闲与压缩内存、swap 和最忙的进程名,结束时打印到日志,用于区分模拟器慢和宿主资源不足。 diff --git a/scripts/ci-runner-load.sh b/scripts/ci-runner-load.sh new file mode 100755 index 000000000..58e635711 --- /dev/null +++ b/scripts/ci-runner-load.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Samples a macOS runner's load every 10 seconds until the job ends, so a slow simulator can be +# told apart from a starved host. Prints only counts and process names. +set -u +printf 'cpus=%s memory_mib=%s\n' "$(sysctl -n hw.ncpu)" "$(( $(sysctl -n hw.memsize) / 1048576 ))" +page=$(sysctl -n hw.pagesize) +while :; do + vm_stat | awk -v page="$page" -v at="$(date -u +%H:%M:%S)" -v load="$(sysctl -n vm.loadavg | awk '{print $2}')" ' + /Pages free/ { free = $3 } + /Pages occupied by compressor/ { compressed = $5 } + /^Swapouts/ { swapouts = $2 } + END { printf "%s load=%s free_mib=%d compressed_mib=%d swapouts=%d", at, load, free * page / 1048576, compressed * page / 1048576, swapouts }' + ps -Ao pcpu=,ucomm= | sort -rn | head -3 | awk '{ cpu = $1; $1 = ""; printf " |%s %s%%", $0, cpu }' + echo + sleep 10 +done