A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
ci(android): wrap the released template unless the PR changes the host
esengine6733f3f96183
diff --git a/.github/workflows/android-compat.yml b/.github/workflows/android-compat.ymlindex 1bb70b5bd..902746a0a 100644--- a/.github/workflows/android-compat.yml+++ b/.github/workflows/android-compat.yml@@ -50,6 +50,12 @@ on:required: falsedefault: '29'type: string+ template-source:+ description: 'Which runtime template to wrap: the latest release, this branch (~35 min), or decide from what the PR touches.'+ required: false+ default: auto+ type: choice+ options: [auto, release, head]permissions:contents: read@@ -109,33 +115,89 @@ jobs:# ---------------------------------------------------------------------------apk:- name: Build the APK once+ name: Package the canary example(s)runs-on: ubuntu-latesttimeout-minutes: 120+ permissions:+ contents: read+ pull-requests: read # to see which files the PR touches+ outputs:+ # Reported alongside the numbers: "the shipped binary" and "a build of this+ # branch" are different claims, and a table that does not say which it made+ # is a table nobody can act on.+ template-from: ${{ steps.src.outputs.from }}steps:- # The host links box2d, spine and glm out of third_party; a checkout without- # submodules fails at configure on a directory with no CMakeLists.txt.+ # Submodules only matter to a from-source build; the released template+ # carries its libraries already. Fetched unconditionally because a+ # conditional checkout is a second way for the two paths to diverge.- uses: actions/checkout@v7with:submodules: recursive- uses: ./.github/actions/setup- # Compiled INTO the host binary, which is why the template is matched to the- # editor version that ships with it.+ # The SDK bundle is compiled INTO the host binary, so a template built here+ # needs it — and the export bundles the game against it either way.- name: Build SDKrun: pnpm --filter ./sdk build+ # Building the host takes ~35 minutes (Dawn, once per ABI) and produces+ # something byte-for-byte irrelevant unless the host source actually changed.+ # A released template was already built, on a machine that did nothing else,+ # and it has the stronger claim besides: it is the binary users installed, so+ # a crash reproduced against it is THE crash rather than a rebuild of it.+ #+ # So: from source only when this PR touches the host, and from the release+ # otherwise. Getting this backwards is silent — a native fix "verified"+ # against a template that predates it — hence the decision is logged.+ - name: Decide where the template comes from+ id: src+ env:+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ run: |+ set -euo pipefail+ WANT='${{ inputs.template-source }}'+ if [ -z "$WANT" ] || [ "$WANT" = 'auto' ]; then+ if [ "$GITHUB_EVENT_NAME" = 'pull_request' ]; then+ CHANGED=$(gh pr diff '${{ github.event.pull_request.number }}' --name-only)+ if echo "$CHANGED" | grep -qE '^(native/|toolchain\.manifest\.json)'; then+ WANT=head+ echo "this PR touches the native host — the template must be built from it"+ else+ WANT=release+ echo "this PR touches no native host source — using the released template"+ fi+ else+ WANT=release+ fi+ fi+ echo "from=$WANT" >> "$GITHUB_OUTPUT"++ - name: Take the template from the latest release+ if: steps.src.outputs.from == 'release'+ env:+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ run: |+ set -euo pipefail+ TAG=$(gh release view --repo "$GITHUB_REPOSITORY" --json tagName -q .tagName)+ echo "template from $TAG"+ mkdir -p artifacts+ gh release download "$TAG" --repo "$GITHUB_REPOSITORY" \+ -p 'estella-native-android-*.zip' -D artifacts+- name: Read the native dependency pins+ if: steps.src.outputs.from == 'head'id: pinsrun: |node -e "const p=require('./toolchain.manifest.json').native;\console.log('dawn='+p.dawn.commit);console.log('quickjs='+p.quickjs.commit)" >> "$GITHUB_OUTPUT"- # Shares the release pipeline's cache key exactly, so a PR that does not move- # the pins reuses the Dawn build the last release produced instead of- # spending two hours reproducing it.+ # restore-keys without the pins, because a Dawn build for a DIFFERENT pin is+ # still most of this one's object files. Note the release pipeline's own cache+ # is written from a tag ref and is therefore unreachable from any branch —+ # see the PR discussion; warming this from master is separate work.- name: Cache the pinned checkouts + Dawn builds+ if: steps.src.outputs.from == 'head'uses: actions/cache@v4with:path: build/native-deps@@ -143,21 +205,27 @@ jobs:restore-keys: native-deps-android-- name: Set up the Android NDK+ if: steps.src.outputs.from == 'head'uses: nttld/setup-ndk@v1id: ndkwith:ndk-version: r28- name: Fetch Dawn + QuickJS at their pinned commits+ if: steps.src.outputs.from == 'head'run: node build-tools/cli.js native --fetch-deps- # x86_64 only: every emulator in the matrix is x86_64, and arm64 would double- # the build for a slice nothing here installs. The API-level surface a- # compatibility run is looking for is in the host's source, not in its ABI.- - name: Build the Android runtime template (x86_64)+ # BOTH ABIs, even though every emulator here is x86_64: ANDROID_ABIS names+ # arm64-v8a and x86_64 as what a template must carry, and the emitter refuses+ # an incomplete one. An x86_64-only build fails at the emit step, not at the+ # compile — which is exactly how this was found.+ - name: Build the Android runtime template from this branch+ if: steps.src.outputs.from == 'head'env:ANDROID_NDK_HOME: ${{ steps.ndk.outputs.ndk-path }}- run: node build-tools/cli.js native --abi x86_64 --template-out artifacts+ run: |+ node build-tools/cli.js native --abi arm64-v8a+ node build-tools/cli.js native --abi x86_64 --template-out artifacts- name: Unpack the templaterun: |@@ -165,9 +233,9 @@ jobs:mkdir -p templateunzip -q artifacts/*.zip -d template- # Packaged the way the editor's Package dialog does it. Built here and only- # here: every version in the matrix installs the identical file, so a- # difference between two rows cannot be a difference between two builds.+ # Packaged the way the editor's Package dialog does it, once: every version+ # in the matrix installs the identical file, so a difference between two rows+ # cannot be a difference between two builds.- name: Package the canary example(s)run: |set -euo pipefail@@ -266,7 +334,7 @@ jobs:# ---------------------------------------------------------------------------report:name: Report into the PR- needs: [versions, compat]+ needs: [versions, apk, compat]# always(): the versions that FAILED are the rows this report exists to show.# A summariser that only runs on success reports exactly the case nobody needs.if: always() && needs.versions.result == 'success'@@ -341,6 +409,7 @@ jobs:run: |node tools/android-compat-report.mjs \--dir build/compat \+ --template-source '${{ needs.apk.outputs.template-from }}' \${{ steps.shots.outputs.base && format('--shots-base {0}', steps.shots.outputs.base) || '' }} \--out compat-comment.mdcat compat-comment.md >> "$GITHUB_STEP_SUMMARY"diff --git a/tools/android-compat-report.mjs b/tools/android-compat-report.mjsindex 844bc0bd9..107750ace 100644--- a/tools/android-compat-report.mjs+++ b/tools/android-compat-report.mjs@@ -102,6 +102,15 @@ const named = apps.filter((a) => a !== '—');out.push(`${perApp ? `${named.length} 个包` : '同一个包'}${named.length ? `(${named.join('、')})` : ''},`+ `在 ${versions.size} 个 Android 版本上各跑一台模拟器,每个版本装的是同一个构建产物。`);out.push('');+// Which template was wrapped changes what a red row means: against the released+// one it is the binary users installed, against a branch build it is a proposed+// fix. Stated because the table is read without the workflow next to it.+if (opts.templateSource === 'release') {+ out.push('运行时模板取自**最新 release** —— 也就是用户实际装到手机上的那个二进制。');+} else if (opts.templateSource === 'head') {+ out.push('运行时模板**从这个分支构建** —— 测的是这里改的代码,不是已发布的版本。');+}+out.push('');out.push(`| Android | API ${perApp ? '| app ' : ''}| ready | 首帧上屏 | am start | PSS | Graphics | CPU | 帧间隔 中位/p95 | 结果 |`);out.push(`|---|---|${perApp ? '---|' : ''}---|---|---|---|---|---|---|---|`);out.push(...rows);