From 7e7653741f4dccd297a3fb051cee9b40ecd1d597 Mon Sep 17 00:00:00 2001 From: wgqqqqq Date: Fri, 4 Dec 2026 12:14:45 +0800 Subject: [PATCH 1/9] fix(ci): restore NSH package build dependencies and add mobile builds --- .github/workflows/cli-package-manual.yml | 12 ++- .github/workflows/cli-package.yml | 10 ++- .github/workflows/desktop-package.yml | 2 + .github/workflows/linux-binaries.yml | 11 ++- .github/workflows/mobile-nsh-package.yml | 100 +++++++++++++++++++++++ .github/workflows/nightly-artifacts.yml | 2 + src/apps/mobile-nsh/README.md | 5 ++ 7 files changed, 136 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/mobile-nsh-package.yml diff --git a/.github/workflows/cli-package-manual.yml b/.github/workflows/cli-package-manual.yml index 3d8e8f08c8..77c6d49d45 100644 --- a/.github/workflows/cli-package-manual.yml +++ b/.github/workflows/cli-package-manual.yml @@ -151,6 +151,8 @@ jobs: libleptonica-dev \ pkg-config \ build-essential \ + clang \ + llvm \ libxcb1-dev \ libxcb-render0-dev \ libxcb-shape0-dev \ @@ -167,11 +169,17 @@ jobs: shared-key: "cli-manual-v1-${{ matrix.platform.name }}" cache-bin: false + - name: Setup pnpm + uses: pnpm/action-setup@v6 + - name: Setup Node.js uses: actions/setup-node@v5 with: - node-version-file: package.json - package-manager-cache: false + node-version: 22 + cache: pnpm + + - name: Install web UI dependencies + run: pnpm install --frozen-lockfile - name: Build the CLI's web UI # Browsers load the web UI from the device they control, so the CLI diff --git a/.github/workflows/cli-package.yml b/.github/workflows/cli-package.yml index 571d7ad733..d4e9f7891e 100644 --- a/.github/workflows/cli-package.yml +++ b/.github/workflows/cli-package.yml @@ -127,11 +127,17 @@ jobs: shared-key: "cli-v1-${{ matrix.platform.name }}" cache-bin: false + - name: Setup pnpm + uses: pnpm/action-setup@v6 + - name: Setup Node.js uses: actions/setup-node@v5 with: - node-version-file: package.json - package-manager-cache: false + node-version: 22 + cache: pnpm + + - name: Install web UI dependencies + run: pnpm install --frozen-lockfile - name: Build the CLI's web UI # Browsers load the web UI from the device they control, so the CLI diff --git a/.github/workflows/desktop-package.yml b/.github/workflows/desktop-package.yml index 88d993a7cf..bf1560fd19 100644 --- a/.github/workflows/desktop-package.yml +++ b/.github/workflows/desktop-package.yml @@ -268,6 +268,8 @@ jobs: run: | sudo apt-get update sudo apt-get install -y --no-install-recommends \ + clang \ + llvm \ pkg-config \ libglib2.0-dev \ libgtk-4-dev \ diff --git a/.github/workflows/linux-binaries.yml b/.github/workflows/linux-binaries.yml index 695893f2a2..154eff4805 100644 --- a/.github/workflows/linux-binaries.yml +++ b/.github/workflows/linux-binaries.yml @@ -79,11 +79,17 @@ jobs: with: ref: ${{ inputs.checkout_ref }} + - name: Setup pnpm + uses: pnpm/action-setup@v6 + - name: Setup Node.js uses: actions/setup-node@v5 with: - node-version-file: package.json - package-manager-cache: false + node-version: 22 + cache: pnpm + + - name: Install web UI dependencies + run: pnpm install --frozen-lockfile - name: Resolve Bun executable cache id: bun-cache-target @@ -134,6 +140,7 @@ jobs: sudo apt-get install -y --no-install-recommends \ build-essential \ clang \ + llvm \ cmake \ curl \ libxcb1-dev \ diff --git a/.github/workflows/mobile-nsh-package.yml b/.github/workflows/mobile-nsh-package.yml new file mode 100644 index 0000000000..a9def8dea1 --- /dev/null +++ b/.github/workflows/mobile-nsh-package.yml @@ -0,0 +1,100 @@ +name: Mobile NSH Package + +on: + workflow_dispatch: + push: + paths: + - '.github/workflows/mobile-nsh-package.yml' + +permissions: + contents: read + +jobs: + package: + name: Package (${{ matrix.platform }}) + runs-on: ${{ matrix.os }} + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + include: + - platform: android + os: ubuntu-24.04 + rust_targets: aarch64-linux-android,armv7-linux-androideabi + - platform: ios + os: macos-15 + rust_targets: aarch64-apple-ios + + steps: + - uses: actions/checkout@v5 + + - uses: pnpm/action-setup@v6 + + - uses: actions/setup-node@v5 + with: + node-version: 22 + cache: pnpm + + - uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.rust_targets }} + + - name: Cache mobile Rust dependencies + uses: swatinem/rust-cache@v2 + with: + workspaces: src/apps/mobile-nsh/.nsh/rust -> target + shared-key: mobile-nsh-package-${{ matrix.platform }} + cache-bin: false + + - uses: actions/setup-java@v5 + if: matrix.platform == 'android' + with: + distribution: temurin + java-version: '17' + + - name: Check Android SDK and NDK + if: matrix.platform == 'android' + run: | + sdkmanager 'platforms;android-35' 'build-tools;35.0.0' + test -d "$ANDROID_NDK_HOME/toolchains/llvm/prebuilt" + + - name: Select Xcode with the matching iOS simulator runtime + if: matrix.platform == 'ios' + run: | + test -d /Applications/Xcode_26.2.app/Contents/Developer + echo "DEVELOPER_DIR=/Applications/Xcode_26.2.app/Contents/Developer" >> "$GITHUB_ENV" + + - name: Install NSH CLI + run: node scripts/ci/install-nsh.mjs + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build Android APK + if: matrix.platform == 'android' + run: pnpm run mobile-nsh:package:android + + - name: Verify Android APK signature + if: matrix.platform == 'android' + run: | + for apk in target/mobile-nsh/android/*.apk; do + "$ANDROID_HOME/build-tools/35.0.0/apksigner" verify "$apk" + done + + - name: Build unsigned iOS device app + if: matrix.platform == 'ios' + run: pnpm run mobile-nsh:package:ios + + - name: Archive iOS device app + if: matrix.platform == 'ios' + working-directory: target/mobile-nsh/ios + run: tar -czf OpenBitFun-ios-unsigned.app.tar.gz -- *.app + + - uses: actions/upload-artifact@v6 + with: + name: openbitfun-mobile-nsh-${{ matrix.platform }} + path: | + target/mobile-nsh/android/*.apk + target/mobile-nsh/ios/*.app.tar.gz + if-no-files-found: error + retention-days: 7 diff --git a/.github/workflows/nightly-artifacts.yml b/.github/workflows/nightly-artifacts.yml index 4c9c0b3a38..141920c44d 100644 --- a/.github/workflows/nightly-artifacts.yml +++ b/.github/workflows/nightly-artifacts.yml @@ -97,6 +97,8 @@ jobs: run: | sudo apt-get update sudo apt-get install -y --no-install-recommends \ + clang \ + llvm \ pkg-config \ libglib2.0-dev \ libgtk-4-dev \ diff --git a/src/apps/mobile-nsh/README.md b/src/apps/mobile-nsh/README.md index 1d4d293c79..06ce276cf0 100644 --- a/src/apps/mobile-nsh/README.md +++ b/src/apps/mobile-nsh/README.md @@ -110,6 +110,11 @@ The app icon goes through `actool`, which needs a simulator runtime that matches the Xcode SDK (`xcodebuild -downloadPlatform iOS`); with an older runtime only, packaging stops at the asset catalog. +The GitHub Actions [Mobile NSH Package workflow](../../../.github/workflows/mobile-nsh-package.yml) +builds a debug-signed APK with both Android ABIs and an unsigned iOS device +app archive. Download either from the run's artifacts. The iOS archive +requires signing and provisioning before installation on a device. + On Android, where an app gets no environment, `adb shell setprop debug.openbitfun.mesh_disable_p2p 1` turns P2P off (relay only, like `OPENBITFUN_MESH_DISABLE_P2P=1`) from the next start. From 67ce199fed26b0a4db14101b30e5374053e54c08 Mon Sep 17 00:00:00 2001 From: wgqqqqq Date: Fri, 4 Dec 2026 12:23:26 +0800 Subject: [PATCH 2/9] fix(ci): build the CLI web bundle on a compatible runner --- .github/workflows/cli-package-manual.yml | 34 ++++++------- .github/workflows/cli-package.yml | 2 +- .github/workflows/cli-web-ui.yml | 63 ++++++++++++++++++++++++ .github/workflows/linux-binaries.yml | 31 ++++++------ .github/workflows/mobile-nsh-package.yml | 5 +- 5 files changed, 99 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/cli-web-ui.yml diff --git a/.github/workflows/cli-package-manual.yml b/.github/workflows/cli-package-manual.yml index 77c6d49d45..1d9706388b 100644 --- a/.github/workflows/cli-package-manual.yml +++ b/.github/workflows/cli-package-manual.yml @@ -112,10 +112,20 @@ jobs: echo "checkout_ref=$CHECKOUT_REF" >> "$GITHUB_OUTPUT" echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT" + web-ui: + name: CLI Web UI + needs: prepare + uses: ./.github/workflows/cli-web-ui.yml + with: + checkout_ref: ${{ needs.prepare.outputs.checkout_ref }} + artifact_name: cli-manual-web-ui + build: name: Build (${{ matrix.platform.name }}) runs-on: ${{ matrix.platform.os }} - needs: prepare + needs: [prepare, web-ui] + env: + OPENBITFUN_CLI_WEB_UI_DIR: ${{ github.workspace }}/target/cli-release-web-ui strategy: fail-fast: false @@ -151,8 +161,6 @@ jobs: libleptonica-dev \ pkg-config \ build-essential \ - clang \ - llvm \ libxcb1-dev \ libxcb-render0-dev \ libxcb-shape0-dev \ @@ -169,23 +177,11 @@ jobs: shared-key: "cli-manual-v1-${{ matrix.platform.name }}" cache-bin: false - - name: Setup pnpm - uses: pnpm/action-setup@v6 - - - name: Setup Node.js - uses: actions/setup-node@v5 + - name: Download the shared CLI web UI + uses: actions/download-artifact@v7 with: - node-version: 22 - cache: pnpm - - - name: Install web UI dependencies - run: pnpm install --frozen-lockfile - - - name: Build the CLI's web UI - # Browsers load the web UI from the device they control, so the CLI - # embeds the one built from this commit (src/apps/cli/build.rs). - shell: bash - run: node scripts/ci/build-cli-web-ui.mjs + name: cli-manual-web-ui + path: target/cli-release-web-ui - name: Build CLI (Unix) if: runner.os != 'Windows' diff --git a/.github/workflows/cli-package.yml b/.github/workflows/cli-package.yml index d4e9f7891e..ac4f0a6f91 100644 --- a/.github/workflows/cli-package.yml +++ b/.github/workflows/cli-package.yml @@ -133,7 +133,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v5 with: - node-version: 22 + node-version-file: package.json cache: pnpm - name: Install web UI dependencies diff --git a/.github/workflows/cli-web-ui.yml b/.github/workflows/cli-web-ui.yml new file mode 100644 index 0000000000..92e1c47118 --- /dev/null +++ b/.github/workflows/cli-web-ui.yml @@ -0,0 +1,63 @@ +name: CLI Web UI + +on: + workflow_call: + inputs: + checkout_ref: + required: true + type: string + version: + type: string + artifact_name: + required: true + type: string + +permissions: + contents: read + +jobs: + build: + name: Build CLI Web UI + # The pinned NSH CLI requires glibc 2.39. Its output is portable to the + # older Linux runners that compile the CLI and Relay release binaries. + runs-on: ubuntu-24.04 + timeout-minutes: 30 + steps: + - uses: actions/checkout@v5 + with: + ref: ${{ inputs.checkout_ref }} + + - uses: pnpm/action-setup@v6 + + - uses: actions/setup-node@v5 + with: + node-version-file: package.json + cache: pnpm + + - uses: dtolnay/rust-toolchain@stable + with: + targets: wasm32-unknown-unknown + + - name: Install LLVM tools + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends clang llvm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Project build version + if: inputs.version != '' + env: + VERSION: ${{ inputs.version }} + run: node scripts/set-build-version.mjs --version "${VERSION%%+*}" + + - name: Build the CLI's web UI + run: node scripts/ci/build-cli-web-ui.mjs + + - uses: actions/upload-artifact@v6 + with: + name: ${{ inputs.artifact_name }} + path: ${{ env.OPENBITFUN_CLI_WEB_UI_DIR }} + if-no-files-found: error + retention-days: 1 diff --git a/.github/workflows/linux-binaries.yml b/.github/workflows/linux-binaries.yml index 154eff4805..b2dbb9c17d 100644 --- a/.github/workflows/linux-binaries.yml +++ b/.github/workflows/linux-binaries.yml @@ -50,7 +50,16 @@ permissions: contents: read jobs: + web-ui: + name: CLI Web UI + uses: ./.github/workflows/cli-web-ui.yml + with: + checkout_ref: ${{ inputs.checkout_ref }} + version: ${{ inputs.version }} + artifact_name: ${{ inputs.artifact_prefix }}-cli-web-ui + build: + needs: web-ui name: Linux Binaries (${{ matrix.platform.name }}) runs-on: ${{ matrix.platform.os }} timeout-minutes: 90 @@ -79,17 +88,11 @@ jobs: with: ref: ${{ inputs.checkout_ref }} - - name: Setup pnpm - uses: pnpm/action-setup@v6 - - name: Setup Node.js uses: actions/setup-node@v5 with: - node-version: 22 - cache: pnpm - - - name: Install web UI dependencies - run: pnpm install --frozen-lockfile + node-version-file: package.json + package-manager-cache: false - name: Resolve Bun executable cache id: bun-cache-target @@ -140,7 +143,6 @@ jobs: sudo apt-get install -y --no-install-recommends \ build-essential \ clang \ - llvm \ cmake \ curl \ libxcb1-dev \ @@ -188,11 +190,11 @@ jobs: - name: Verify projected Cargo metadata run: cargo metadata --locked --no-deps - - name: Build the CLI's web UI - # Browsers load the web UI from the device they control, so the CLI - # embeds the one built from this commit (src/apps/cli/build.rs). - shell: bash - run: node scripts/ci/build-cli-web-ui.mjs + - name: Download the shared CLI web UI + uses: actions/download-artifact@v7 + with: + name: ${{ inputs.artifact_prefix }}-cli-web-ui + path: target/cli-release-web-ui - name: Build CLI and Relay Server shell: bash @@ -201,6 +203,7 @@ jobs: # mandatory for self-update. Unset on forks, which then fall back to # checksum-only. OPENBITFUN_RELEASE_PUBKEY: ${{ secrets.release_pubkey }} + OPENBITFUN_CLI_WEB_UI_DIR: ${{ github.workspace }}/target/cli-release-web-ui run: | cargo build --locked --release \ --target ${{ matrix.platform.target }} \ diff --git a/.github/workflows/mobile-nsh-package.yml b/.github/workflows/mobile-nsh-package.yml index a9def8dea1..e862bf5e0c 100644 --- a/.github/workflows/mobile-nsh-package.yml +++ b/.github/workflows/mobile-nsh-package.yml @@ -42,7 +42,7 @@ jobs: - name: Cache mobile Rust dependencies uses: swatinem/rust-cache@v2 with: - workspaces: src/apps/mobile-nsh/.nsh/rust -> target + workspaces: src/apps/mobile-nsh/native -> ../.nsh/rust/target shared-key: mobile-nsh-package-${{ matrix.platform }} cache-bin: false @@ -55,7 +55,8 @@ jobs: - name: Check Android SDK and NDK if: matrix.platform == 'android' run: | - sdkmanager 'platforms;android-35' 'build-tools;35.0.0' + test -f "$ANDROID_HOME/platforms/android-35/android.jar" + test -x "$ANDROID_HOME/build-tools/35.0.0/apksigner" test -d "$ANDROID_NDK_HOME/toolchains/llvm/prebuilt" - name: Select Xcode with the matching iOS simulator runtime From 09b059038077551964599719d42ae4ac79915043 Mon Sep 17 00:00:00 2001 From: wgqqqqq Date: Fri, 4 Dec 2026 12:40:25 +0800 Subject: [PATCH 3/9] fix(ci): cache mobile builds from the native workspace --- .github/workflows/mobile-nsh-package.yml | 29 +++++++++++++++--------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/mobile-nsh-package.yml b/.github/workflows/mobile-nsh-package.yml index e862bf5e0c..b1d6515d33 100644 --- a/.github/workflows/mobile-nsh-package.yml +++ b/.github/workflows/mobile-nsh-package.yml @@ -35,17 +35,6 @@ jobs: node-version: 22 cache: pnpm - - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.rust_targets }} - - - name: Cache mobile Rust dependencies - uses: swatinem/rust-cache@v2 - with: - workspaces: src/apps/mobile-nsh/native -> ../.nsh/rust/target - shared-key: mobile-nsh-package-${{ matrix.platform }} - cache-bin: false - - uses: actions/setup-java@v5 if: matrix.platform == 'android' with: @@ -71,6 +60,24 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile + - uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.rust_targets }} + + - name: Cache mobile Rust dependencies + uses: swatinem/rust-cache@v2 + with: + workspaces: src/apps/mobile-nsh/native -> ../../../../target/mobile-nsh-native + shared-key: mobile-nsh-package-${{ matrix.platform }} + cache-bin: false + + - name: Check Android SDK and NDK + if: matrix.platform == 'android' + run: | + test -f "$ANDROID_HOME/platforms/android-35/android.jar" + test -x "$ANDROID_HOME/build-tools/35.0.0/apksigner" + test -d "$ANDROID_NDK_HOME/toolchains/llvm/prebuilt" + - name: Build Android APK if: matrix.platform == 'android' run: pnpm run mobile-nsh:package:android From f48c25dad2c82139140426fa4f7235421c76be4d Mon Sep 17 00:00:00 2001 From: wgqqqqq Date: Fri, 4 Dec 2026 12:42:15 +0800 Subject: [PATCH 4/9] ci(mobile): use the Intel runner for the arm64 device build --- .github/workflows/mobile-nsh-package.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/mobile-nsh-package.yml b/.github/workflows/mobile-nsh-package.yml index b1d6515d33..5a9e3744d6 100644 --- a/.github/workflows/mobile-nsh-package.yml +++ b/.github/workflows/mobile-nsh-package.yml @@ -14,6 +14,8 @@ jobs: name: Package (${{ matrix.platform }}) runs-on: ${{ matrix.os }} timeout-minutes: 60 + env: + CARGO_TARGET_DIR: ${{ github.workspace }}/target/mobile-nsh-native strategy: fail-fast: false matrix: @@ -22,7 +24,7 @@ jobs: os: ubuntu-24.04 rust_targets: aarch64-linux-android,armv7-linux-androideabi - platform: ios - os: macos-15 + os: macos-15-intel rust_targets: aarch64-apple-ios steps: From ab3a0c0f07b7b3213202685fb5e7cab199e85807 Mon Sep 17 00:00:00 2001 From: wgqqqqq Date: Fri, 4 Dec 2026 12:45:26 +0800 Subject: [PATCH 5/9] fix(ci): install dependencies for Windows signing checks --- .github/workflows/windows-signing-checks.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-signing-checks.yml b/.github/workflows/windows-signing-checks.yml index a5cc058a60..1fb1e43f4e 100644 --- a/.github/workflows/windows-signing-checks.yml +++ b/.github/workflows/windows-signing-checks.yml @@ -24,10 +24,13 @@ jobs: timeout-minutes: 5 steps: - uses: actions/checkout@v5 + - uses: pnpm/action-setup@v6 - uses: actions/setup-node@v5 with: node-version: 22 - package-manager-cache: false + cache: pnpm + - name: Install dependencies + run: pnpm install --frozen-lockfile - name: Test native Windows package tooling run: node --test scripts/ci/native-release-tooling.test.mjs - name: Test signing failure handling without credentials From 6d5d92af7f34477c2af38d9fe3e900de572542f8 Mon Sep 17 00:00:00 2001 From: wgqqqqq Date: Fri, 4 Dec 2026 12:49:59 +0800 Subject: [PATCH 6/9] fix(desktop): stamp the Windows icon in clean checkouts --- scripts/ci/native-release-tooling.test.mjs | 14 ++++++++++++++ scripts/desktop-nsh-package-common.mjs | 1 + 2 files changed, 15 insertions(+) diff --git a/scripts/ci/native-release-tooling.test.mjs b/scripts/ci/native-release-tooling.test.mjs index e87b007027..e77851c4a2 100644 --- a/scripts/ci/native-release-tooling.test.mjs +++ b/scripts/ci/native-release-tooling.test.mjs @@ -137,6 +137,20 @@ test('desktop:dev keeps the installed data by default and isolates it on request assert.doesNotMatch(stampCheck.stderr, /unsettled top-level await/i); }); +test('stamps the Windows icon before the dev bundle directory exists', async (t) => { + const { stampDevAppIdentity } = await import('../desktop-nsh-package-common.mjs'); + const work = mkdtempSync(path.join(tmpdir(), 'openbitfun-stamp-dev-')); + t.after(() => rmSync(work, { recursive: true, force: true })); + const appDir = path.join(work, 'target', 'nsh'); + + stampDevAppIdentity(appDir, root, 'win32'); + + assert.deepEqual( + readFileSync(path.join(appDir, 'icon.ico')), + readFileSync(path.join(root, 'src/apps/desktop/icons/openbitfun-app-icon.ico')), + ); +}); + test('install-nsh ensure/postinstall reuses existing versions, skips in CI/opt-out, and links node_modules/.bin', async (t) => { assert.equal(parseNshVersion('nsh 0.6.1 (2f51d86)'), 'v0.6.1'); assert.equal(parseNshVersion('nsh v0.6.1'), 'v0.6.1'); diff --git a/scripts/desktop-nsh-package-common.mjs b/scripts/desktop-nsh-package-common.mjs index 2473be3e96..5280f727bc 100644 --- a/scripts/desktop-nsh-package-common.mjs +++ b/scripts/desktop-nsh-package-common.mjs @@ -352,6 +352,7 @@ export function stampDevAppIdentity(appDir, rootDir = root, platform = process.p const winIcon = join(rootDir, "src", "apps", "desktop", "icons", "openbitfun-app-icon.ico"); const destIcon = join(appDir, "icon.ico"); if (existsSync(winIcon)) { + mkdirSync(appDir, { recursive: true }); copyFileSync(winIcon, destIcon); } } From 29dc39a417307fd8b6d27cb7155db598ef09452a Mon Sep 17 00:00:00 2001 From: wgqqqqq Date: Fri, 4 Dec 2026 13:00:43 +0800 Subject: [PATCH 7/9] ci(mobile): check Android SDK once before packaging --- .github/workflows/mobile-nsh-package.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/mobile-nsh-package.yml b/.github/workflows/mobile-nsh-package.yml index 5a9e3744d6..bf25cd5f83 100644 --- a/.github/workflows/mobile-nsh-package.yml +++ b/.github/workflows/mobile-nsh-package.yml @@ -43,13 +43,6 @@ jobs: distribution: temurin java-version: '17' - - name: Check Android SDK and NDK - if: matrix.platform == 'android' - run: | - test -f "$ANDROID_HOME/platforms/android-35/android.jar" - test -x "$ANDROID_HOME/build-tools/35.0.0/apksigner" - test -d "$ANDROID_NDK_HOME/toolchains/llvm/prebuilt" - - name: Select Xcode with the matching iOS simulator runtime if: matrix.platform == 'ios' run: | From a79a091bdc946ffa9f3dc05846ca5da40677900c Mon Sep 17 00:00:00 2001 From: wgqqqqq Date: Fri, 4 Dec 2026 13:58:33 +0800 Subject: [PATCH 8/9] fix(ci): rebuild incomplete NSH runtime cache --- scripts/nsh-motion-runtime.mjs | 13 ++++++++----- scripts/nsh-motion-runtime.test.mjs | 30 +++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/scripts/nsh-motion-runtime.mjs b/scripts/nsh-motion-runtime.mjs index a01bcd93c2..6b3ef04471 100644 --- a/scripts/nsh-motion-runtime.mjs +++ b/scripts/nsh-motion-runtime.mjs @@ -28,13 +28,14 @@ const checksum = { }; const sha256 = bytes => createHash('sha256').update(bytes).digest('hex'); -function prepare(name, inputs, build) { +export function prepare(name, inputs, build, { cacheDir = cache, isComplete = existsSync } = {}) { const hash = createHash('sha256').update(readFileSync(fileURLToPath(import.meta.url))); for (const input of inputs) hash.update(readFileSync(input)); - const dest = path.join(cache, `${name}-${hash.digest('hex').slice(0, 20)}`); - if (!existsSync(dest)) { - mkdirSync(cache, { recursive: true }); - const stage = mkdtempSync(path.join(cache, `.${name}-`)); + const dest = path.join(cacheDir, `${name}-${hash.digest('hex').slice(0, 20)}`); + if (!isComplete(dest)) { + rmSync(dest, { recursive: true, force: true }); + mkdirSync(cacheDir, { recursive: true }); + const stage = mkdtempSync(path.join(cacheDir, `.${name}-`)); try { build(stage); try { renameSync(stage, dest); } @@ -184,6 +185,8 @@ export function webRuntimeEnv(env, development = false) { cpSync(source, web, { recursive: true }); applyPatch(web, patch); buildWebModule(web, development, env); + }, { + isComplete: runtime => existsSync(path.join(runtime, 'web', 'nsh.js')) && existsSync(path.join(runtime, 'web', module)), }); return { ...env, NSH_RUNTIME: runtime }; } diff --git a/scripts/nsh-motion-runtime.test.mjs b/scripts/nsh-motion-runtime.test.mjs index 3852d47a8b..2dde4d562f 100644 --- a/scripts/nsh-motion-runtime.test.mjs +++ b/scripts/nsh-motion-runtime.test.mjs @@ -1,12 +1,12 @@ import assert from 'node:assert/strict'; import { execFileSync } from 'node:child_process'; -import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; +import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; import path from 'node:path'; import test from 'node:test'; import { fileURLToPath } from 'node:url'; -import { applyPatch } from './nsh-motion-runtime.mjs'; +import { applyPatch, prepare } from './nsh-motion-runtime.mjs'; const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); @@ -62,6 +62,32 @@ test('applyPatch reports the failing patch path on mismatch', () => { } }); +test('prepare rebuilds an incomplete cached runtime', () => { + const cacheDir = mkdtempSync(path.join(tmpdir(), 'openbitfun-nsh-runtime-')); + let builds = 0; + const build = (stage) => { + builds += 1; + writeFileSync(path.join(stage, 'complete'), 'runtime'); + }; + const options = { + cacheDir, + isComplete: (runtime) => existsSync(path.join(runtime, 'complete')), + }; + + try { + const runtime = prepare('web', [], build, options); + rmSync(path.join(runtime, 'complete')); + + const rebuiltRuntime = prepare('web', [], build, options); + + assert.equal(rebuiltRuntime, runtime); + assert.equal(builds, 2); + assert.equal(existsSync(path.join(rebuiltRuntime, 'complete')), true); + } finally { + rmSync(cacheDir, { recursive: true, force: true }); + } +}); + test('.gitattributes pins patch files and patches/ assets to LF', () => { const checked = [ 'patches/nsh-0.8.0/web.patch', From e946c4fa9ed076898ae8c7ee5ec43cff93601ff3 Mon Sep 17 00:00:00 2001 From: wgqqqqq Date: Fri, 4 Dec 2026 15:48:42 +0800 Subject: [PATCH 9/9] ci: allow more time for mobile packaging --- .github/workflows/mobile-nsh-package.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/mobile-nsh-package.yml b/.github/workflows/mobile-nsh-package.yml index bf25cd5f83..e8cae6081e 100644 --- a/.github/workflows/mobile-nsh-package.yml +++ b/.github/workflows/mobile-nsh-package.yml @@ -13,7 +13,9 @@ jobs: package: name: Package (${{ matrix.platform }}) runs-on: ${{ matrix.os }} - timeout-minutes: 60 + # The unsigned iOS device build can exceed one hour on a cold macOS + # runner while compiling the Rust native bridge and NSH runtime. + timeout-minutes: 120 env: CARGO_TARGET_DIR: ${{ github.workspace }}/target/mobile-nsh-native strategy: