Skip to content

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.

ci(android): the emulator action runs script line by line, so use a file

esengined6f2bc11b910
diff --git a/.github/workflows/android-compat.yml b/.github/workflows/android-compat.yml
index d865e452e..970793ebd 100644
--- a/.github/workflows/android-compat.yml
+++ b/.github/workflows/android-compat.yml
@@ -60,6 +60,13 @@ on:
permissions:
contents: read
+# One matrix per PR at a time. `paths` on a pull_request matches the PR's whole
+# diff, not the latest push, so every push re-runs all eight emulators — three
+# pushes queued twenty-four of them before this was here.
+concurrency:
+ group: android-compat-${{ github.event.pull_request.number || github.ref }}
+ cancel-in-progress: true
+
env:
# Android 10. The manifest claims 26, which is a wider promise than anything
# here checks — raising this floor is a decision about what we support, so it is
@@ -304,27 +311,11 @@ jobs:
arch: x86_64
profile: ${{ env.ANDROID_PROFILE }}
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -camera-front none -memory 4096 -cores 2
- # POSIX sh, not bash: this action runs `script` through /usr/bin/sh, so
- # `set -o pipefail` aborts the whole thing on its first line — which it
- # did, on all eight versions, before a single app was installed.
- script: |
- set -eu
- mkdir -p build/compat
- rc=0
- for apk in apks/*.apk; do
- name=$(basename "$apk" .apk)
- label="api${{ matrix.api }}-$name"
- echo "::group::$label"
- # --no-frame-judge: the frame is for a human. The gate here is
- # install + `ready` + no recorded error.
- node tools/verify-native-boot.mjs \
- --platform android --apk "$apk" \
- --label "$label" --no-frame-judge \
- --out build/compat \
- --metrics-out "build/compat/$label.json" || rc=$?
- echo "::endgroup::"
- done
- exit $rc
+ # ONE line, because this action runs `script` as a separate `sh -c` per
+ # line: a loop written here arrives split and dies on its own `do`, and
+ # nothing set on one line is visible on the next. The work lives in a
+ # file that can also be run by hand.
+ script: bash tools/android-compat-run.sh ${{ matrix.api }}
- name: Keep the frame, the record and the numbers
if: always()
diff --git a/tools/android-compat-run.sh b/tools/android-compat-run.sh
new file mode 100755
index 000000000..ee6be64ca
--- /dev/null
+++ b/tools/android-compat-run.sh
@@ -0,0 +1,54 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: Apache-2.0
+# SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+#
+# Install and measure every packaged canary on the emulator that is already up.
+#
+# This is a FILE, and not the workflow's `script:` input, because
+# reactivecircus/android-emulator-runner executes that input one line at a time
+# as separate `sh -c` invocations. A loop cannot survive it — `for apk in ...; do`
+# arrives alone and dies with "end of file unexpected (expecting done)" — and
+# nothing assigned on one line is visible on the next. The one-line workarounds
+# (a folded `>-` scalar, or `sh -c` with an embedded newline) both put shell
+# syntax somewhere it cannot be run or tested; a file can be run by hand.
+#
+# tools/android-compat-run.sh <api-level>
+#
+# Every APK is attempted even after one fails, because which versions work is the
+# entire output: stopping at the first break would report the oldest failure and
+# hide every version above it.
+set -euo pipefail
+
+API="${1:?usage: android-compat-run.sh <api-level> [out-dir]}"
+
+# Resolved from this file, not from the caller's cwd: being runnable by hand is
+# the reason it is a file at all, and a relative `tools/...` only works from the
+# repository root.
+ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
+OUT="${2:-$ROOT/build/compat}"
+
+mkdir -p "$OUT"
+
+shopt -s nullglob
+APKS=("$ROOT"/apks/*.apk)
+if [ ${#APKS[@]} -eq 0 ]; then
+ echo "::error::no APKs in $ROOT/apks — the packaging job produced nothing to install"
+ exit 1
+fi
+
+rc=0
+for apk in "${APKS[@]}"; do
+ name=$(basename "$apk" .apk)
+ label="api${API}-${name}"
+ echo "::group::${label}"
+ # --no-frame-judge: the frame is for a human to look at. The gate is install +
+ # `ready` + no recorded error.
+ node "$ROOT/tools/verify-native-boot.mjs" \
+ --platform android --apk "$apk" \
+ --label "$label" --no-frame-judge \
+ --out "$OUT" \
+ --metrics-out "${OUT}/${label}.json" || rc=$?
+ echo "::endgroup::"
+done
+
+exit "$rc"