Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 7 additions & 27 deletions .github/actions/setup-android-replay-host/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,15 @@ runs:
run: |
VERSION="$(node -p 'require("./package.json").version')"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "value=${{ hashFiles('android/snapshot-helper/AndroidManifest.xml', 'android/snapshot-helper/debug.keystore', 'android/snapshot-helper/src/**', 'android/ime-helper/AndroidManifest.xml', 'android/ime-helper/res/**', 'android/ime-helper/src/**', 'scripts/build-android-helper.sh', 'scripts/package-android-helper.sh', '.github/actions/setup-android-replay-host/action.yml') }}" >> "$GITHUB_OUTPUT"
echo "value=${{ hashFiles('android/snapshot-helper/AndroidManifest.xml', 'android/snapshot-helper/debug.keystore', 'android/snapshot-helper/src/**', 'android/ime-helper/AndroidManifest.xml', 'android/ime-helper/res/**', 'android/ime-helper/src/**', 'scripts/build-android-helper.sh', 'scripts/package-android-helper.sh', '.github/actions/setup-android-replay-host/action.yml', '.github/actions/setup-android-sdk/action.yml') }}" >> "$GITHUB_OUTPUT"
shell: bash

# The helper build refuses to guess its build-tools version on CI, and that version decides
# the APK bytes, so both cache keys name it as well.
- name: Declare the pinned Android build tools
# the APK bytes, so both cache keys name it as well. The install is skipped when the runner
# already has the pinned packages; the fixture APK steps need them on a cache hit too.
- name: Setup Android SDK
if: inputs.package-helpers == 'true'
id: android-build-tools
run: |
BUILD_TOOLS_VERSION=36.0.0
echo "AGENT_DEVICE_ANDROID_BUILD_TOOLS=$BUILD_TOOLS_VERSION" >> "$GITHUB_ENV"
echo "version=$BUILD_TOOLS_VERSION" >> "$GITHUB_OUTPUT"
shell: bash
uses: ./.github/actions/setup-android-sdk

- name: Restore packaged Android helpers
if: inputs.package-helpers == 'true'
Expand All @@ -58,23 +54,7 @@ runs:
path: |
android/snapshot-helper/dist
android/ime-helper/dist
key: android-helpers-${{ runner.os }}-${{ runner.arch }}-api36-bt${{ steps.android-build-tools.outputs.version }}-v${{ steps.android-helper-source.outputs.version }}-${{ steps.android-helper-source.outputs.value }}

- name: Install Android helper SDK packages
if: inputs.package-helpers == 'true' && steps.android-helpers-cache.outputs.cache-hit != 'true'
run: |
SDK_ROOT="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-/usr/local/lib/android/sdk}}"
SDKMANAGER="$SDK_ROOT/cmdline-tools/latest/bin/sdkmanager"
if [ ! -x "$SDKMANAGER" ]; then
SDKMANAGER="$SDK_ROOT/cmdline-tools/bin/sdkmanager"
fi
if [ ! -x "$SDKMANAGER" ]; then
echo "sdkmanager not found under $SDK_ROOT" >&2
exit 1
fi
yes | "$SDKMANAGER" --licenses >/dev/null || true
"$SDKMANAGER" "platforms;android-36" "build-tools;$AGENT_DEVICE_ANDROID_BUILD_TOOLS"
shell: bash
key: android-helpers-${{ runner.os }}-${{ runner.arch }}-api36-bt${{ env.AGENT_DEVICE_ANDROID_BUILD_TOOLS }}-v${{ steps.android-helper-source.outputs.version }}-${{ steps.android-helper-source.outputs.value }}

- name: Package npm-bundled Android helpers
if: inputs.package-helpers == 'true' && steps.android-helpers-cache.outputs.cache-hit != 'true'
Expand All @@ -97,4 +77,4 @@ runs:
path: |
android/snapshot-helper/dist
android/ime-helper/dist
key: android-helpers-${{ runner.os }}-${{ runner.arch }}-api36-bt${{ steps.android-build-tools.outputs.version }}-v${{ steps.android-helper-source.outputs.version }}-${{ steps.android-helper-source.outputs.value }}
key: android-helpers-${{ runner.os }}-${{ runner.arch }}-api36-bt${{ env.AGENT_DEVICE_ANDROID_BUILD_TOOLS }}-v${{ steps.android-helper-source.outputs.version }}-${{ steps.android-helper-source.outputs.value }}
54 changes: 54 additions & 0 deletions .github/actions/setup-android-sdk/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: 'Setup Android SDK'
description: 'Install the pinned Android platform and build tools, and export the build-tools version'

# The one owner of the pinned build-tools version. d8 and aapt2 come from build-tools, so the
# version decides the helper APK bytes. Later steps read it from AGENT_DEVICE_ANDROID_BUILD_TOOLS.

inputs:
build-tools:
description: 'Android build-tools version to install'
required: false
default: '36.0.0'

outputs:
build-tools-dir:
description: 'Absolute path of the installed build-tools directory'
value: ${{ steps.install.outputs.build-tools-dir }}

runs:
using: 'composite'
steps:
- name: Install Android platform and build tools
id: install
shell: bash
env:
BUILD_TOOLS_VERSION: ${{ inputs.build-tools }}
run: |
set -euo pipefail
SDK_ROOT="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-/usr/local/lib/android/sdk}}"
BUILD_TOOLS_DIR="$SDK_ROOT/build-tools/$BUILD_TOOLS_VERSION"
# Every build-tools binary a caller runs: the helper build (aapt2, d8, zipalign,
# apksigner) and the fixture APK scripts (aapt, apksigner).
INSTALLED=true
for BUILD_TOOL in aapt aapt2 d8 zipalign apksigner; do
[ -x "$BUILD_TOOLS_DIR/$BUILD_TOOL" ] || INSTALLED=false
done
[ -f "$SDK_ROOT/platforms/android-36/android.jar" ] || INSTALLED=false
if [ "$INSTALLED" != true ]; then
SDKMANAGER="$SDK_ROOT/cmdline-tools/latest/bin/sdkmanager"
if [ ! -x "$SDKMANAGER" ]; then
SDKMANAGER="$SDK_ROOT/cmdline-tools/bin/sdkmanager"
fi
if [ ! -x "$SDKMANAGER" ]; then
echo "::error::sdkmanager not found under $SDK_ROOT." >&2
exit 1
fi
# `yes` dies of SIGPIPE when sdkmanager stops reading. Without pipefail the pipe
# reports sdkmanager's own status, so a real licence failure still stops the step.
set +o pipefail
yes | "$SDKMANAGER" --licenses >/dev/null
set -o pipefail
"$SDKMANAGER" "platforms;android-36" "build-tools;$BUILD_TOOLS_VERSION"
fi
echo "AGENT_DEVICE_ANDROID_BUILD_TOOLS=$BUILD_TOOLS_VERSION" >> "$GITHUB_ENV"
echo "build-tools-dir=$BUILD_TOOLS_DIR" >> "$GITHUB_OUTPUT"
23 changes: 1 addition & 22 deletions .github/actions/setup-fixture-app/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,7 @@ runs:
# must not make artifact inspection/repacking depend on the runner image.
- name: Ensure Android artifact build tools
if: inputs.platform == 'android'
shell: bash
run: |
# sdkmanager intentionally closes stdin after accepting licenses; disable
# the runner's inherited pipefail only around that benign SIGPIPE.
set -eu
SDK_ROOT="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-/usr/local/lib/android/sdk}}"
BUILD_TOOLS="$SDK_ROOT/build-tools/36.0.0"
if [ -x "$BUILD_TOOLS/aapt" ] && [ -x "$BUILD_TOOLS/apksigner" ]; then
exit 0
fi
SDKMANAGER="$SDK_ROOT/cmdline-tools/latest/bin/sdkmanager"
if [ ! -x "$SDKMANAGER" ]; then
SDKMANAGER="$SDK_ROOT/cmdline-tools/bin/sdkmanager"
fi
if [ ! -x "$SDKMANAGER" ]; then
echo "::error::sdkmanager not found under $SDK_ROOT." >&2
exit 1
fi
set +o pipefail
yes | "$SDKMANAGER" --licenses >/dev/null
set -o pipefail
"$SDKMANAGER" "platforms;android-36" "build-tools;36.0.0"
uses: ./.github/actions/setup-android-sdk

- name: Fetch the cached Release binary
id: fetch
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup-fixture-app/locate-android-apk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -euo pipefail

DEST="${1:?fixture directory is required}"
SDK_ROOT="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-/usr/local/lib/android/sdk}}"
BUILD_TOOLS="$SDK_ROOT/build-tools/36.0.0"
BUILD_TOOLS="$SDK_ROOT/build-tools/${AGENT_DEVICE_ANDROID_BUILD_TOOLS:?AGENT_DEVICE_ANDROID_BUILD_TOOLS must name the build-tools version setup-android-sdk installed}"

APKS=()
while IFS= read -r apk; do
Expand Down
14 changes: 13 additions & 1 deletion .github/actions/setup-fixture-app/repack-android-apk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@ set -euo pipefail
APK="${1:?source APK is required}"
OUT="${2:?output APK is required}"
SDK_ROOT="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-/usr/local/lib/android/sdk}}"
BUILD_TOOLS="$SDK_ROOT/build-tools/36.0.0"
# CI names the version setup-android-sdk installed. A local repack may take the newest installed.
BUILD_TOOLS_VERSION="${AGENT_DEVICE_ANDROID_BUILD_TOOLS:-}"
if [ -z "$BUILD_TOOLS_VERSION" ]; then
if [ "${CI:-}" = "true" ]; then
echo "::error::AGENT_DEVICE_ANDROID_BUILD_TOOLS must name the build-tools version setup-android-sdk installed." >&2
exit 1
fi
NEWEST_BUILD_TOOLS_DIR="$(
find "$SDK_ROOT/build-tools" -maxdepth 1 -mindepth 1 -type d 2>/dev/null | sort -V | tail -n 1
Comment thread
thymikee marked this conversation as resolved.
Resolved
)" || true
BUILD_TOOLS_VERSION="${NEWEST_BUILD_TOOLS_DIR##*/}"
fi
BUILD_TOOLS="$SDK_ROOT/build-tools/$BUILD_TOOLS_VERSION"
if [ ! -x "$BUILD_TOOLS/aapt" ] || [ ! -x "$BUILD_TOOLS/apksigner" ]; then
echo "::error::Android build tools were not found at $BUILD_TOOLS." >&2
exit 1
Expand Down
19 changes: 3 additions & 16 deletions .github/workflows/release-android-snapshot-helper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ jobs:
name: Publish Android Snapshot Helper
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 30
env:
# The helper build refuses to guess its build-tools version on CI.
AGENT_DEVICE_ANDROID_BUILD_TOOLS: 36.0.0
steps:
- name: Checkout
uses: useblacksmith/checkout@2b9fe87d796feea153b455ec2f3125b471a7b0e7 # v1.8.2
Expand All @@ -41,19 +38,9 @@ jobs:
with:
node-version: '24.13'

- name: Install Android SDK packages
run: |
SDK_ROOT="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-/usr/local/lib/android/sdk}}"
SDKMANAGER="$SDK_ROOT/cmdline-tools/latest/bin/sdkmanager"
if [ ! -x "$SDKMANAGER" ]; then
SDKMANAGER="$SDK_ROOT/cmdline-tools/bin/sdkmanager"
fi
if [ ! -x "$SDKMANAGER" ]; then
echo "sdkmanager not found under $SDK_ROOT" >&2
exit 1
fi
yes | "$SDKMANAGER" --licenses >/dev/null
"$SDKMANAGER" "platforms;android-36" "build-tools;$AGENT_DEVICE_ANDROID_BUILD_TOOLS"
# Exports AGENT_DEVICE_ANDROID_BUILD_TOOLS, which the helper build requires on CI.
- name: Setup Android SDK
uses: ./.github/actions/setup-android-sdk

- name: Check Java toolchain
run: |
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ jobs:
permissions:
contents: read
env:
# The helper build refuses to guess its build-tools version on CI.
AGENT_DEVICE_ANDROID_BUILD_TOOLS: 36.0.0
VERSION: ${{ needs.plan.outputs.version }}
steps:
- name: Checkout
Expand All @@ -89,12 +87,9 @@ jobs:
with:
cache-store: 'false'

- name: Install Android helper toolchain
run: |
set -euo pipefail
SDKMANAGER="$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager"
yes | "$SDKMANAGER" --licenses >/dev/null || true
"$SDKMANAGER" "platforms;android-36" "build-tools;$AGENT_DEVICE_ANDROID_BUILD_TOOLS"
# Exports AGENT_DEVICE_ANDROID_BUILD_TOOLS, which the helper build requires on CI.
- name: Setup Android SDK
uses: ./.github/actions/setup-android-sdk

- name: Stamp release version
run: node scripts/release-version.mjs stamp "$VERSION"
Expand Down
19 changes: 3 additions & 16 deletions .github/workflows/size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ jobs:
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 10
env:
# The helper build refuses to guess its build-tools version on CI.
AGENT_DEVICE_ANDROID_BUILD_TOOLS: 36.0.0
steps:
- name: Checkout
uses: useblacksmith/checkout@2b9fe87d796feea153b455ec2f3125b471a7b0e7 # v1.8.2
Expand All @@ -44,19 +41,9 @@ jobs:
cp scripts/size-report*.mjs /tmp/agent-device-size-report/
cp scripts/prepare-publish-assets.mjs /tmp/agent-device-size-report/

- name: Install Android helper toolchain
run: |
SDK_ROOT="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-/usr/local/lib/android/sdk}}"
SDKMANAGER="$SDK_ROOT/cmdline-tools/latest/bin/sdkmanager"
if [ ! -x "$SDKMANAGER" ]; then
SDKMANAGER="$SDK_ROOT/cmdline-tools/bin/sdkmanager"
fi
if [ ! -x "$SDKMANAGER" ]; then
echo "sdkmanager not found under $SDK_ROOT" >&2
exit 1
fi
yes | "$SDKMANAGER" --licenses >/dev/null || true
"$SDKMANAGER" "platforms;android-36" "build-tools;$AGENT_DEVICE_ANDROID_BUILD_TOOLS"
# Exports AGENT_DEVICE_ANDROID_BUILD_TOOLS, which the helper build requires on CI.
- name: Setup Android SDK
uses: ./.github/actions/setup-android-sdk

# dist is fully determined by the base commit, so reuse it across PR runs
# against the same base. Startup medians are still measured fresh on this
Expand Down
18 changes: 2 additions & 16 deletions .github/workflows/test-app-build-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,23 +162,9 @@ jobs:
--no-bundler \
--output "${{ github.workspace }}/.tmp/test-app-build"

# Deliberately no `set -o pipefail`: `yes` is killed by SIGPIPE once
# sdkmanager stops reading, and pipefail would report that 141 as the
# step's own failure.
- name: Install Android SDK packages
- name: Setup Android SDK
if: matrix.platform == 'android' && matrix.build
run: |
SDK_ROOT="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-/usr/local/lib/android/sdk}}"
SDKMANAGER="$SDK_ROOT/cmdline-tools/latest/bin/sdkmanager"
if [ ! -x "$SDKMANAGER" ]; then
SDKMANAGER="$SDK_ROOT/cmdline-tools/bin/sdkmanager"
fi
if [ ! -x "$SDKMANAGER" ]; then
echo "sdkmanager not found under $SDK_ROOT" >&2
exit 1
fi
yes | "$SDKMANAGER" --licenses >/dev/null
"$SDKMANAGER" "platforms;android-36" "build-tools;36.0.0"
uses: ./.github/actions/setup-android-sdk

# CNG's generated Android project exposes the ordinary Gradle Release task;
# it builds and packages every ABI without device resolution. Installation
Expand Down
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ when a running daemon needs to pick up a new TypeScript build.

That Android leg needs `AGENT_DEVICE_ANDROID_BUILD_TOOLS` naming the build-tools version to compile
with. An unpinned build takes the newest version installed on the machine, which CI refuses to do,
so name the version the CI lanes install and the published helper matches the CI-built one.
so name the version `.github/actions/setup-android-sdk` installs and the published helper matches
the CI-built one.

`pnpm package:npm` is a release guard, not a routine development command. Use the specific commands
above while iterating.
Expand Down
Loading
Loading