mirror of
https://github.com/callstack/agent-device.git
synced 2026-09-14 20:06:34 +08:00
e3880f10c8
build-android-helper.sh compiled with whichever build-tools directory was newest on the image while every lane that builds a helper installs exactly build-tools;36.0.0. That selection feeds d8 and aapt2, so a newer package on the runner changed the helper's bytecode and resources rather than just its packaging, and nothing said so. The script now takes the version as an input, its last positional or AGENT_DEVICE_ANDROID_BUILD_TOOLS, resolves it under $SDK_ROOT/build-tools, and checks the four tools the build actually runs instead of aapt2 alone. An unpinned build is a hard failure on CI; locally the newest-installed fallback stays and is announced on stderr. Each lane that builds a helper declares the version it installs and interpolates that same value into its sdkmanager line and the build environment, so an install and a build inside one lane cannot drift. setup-android-replay-host exports it to the packaging gate and names it in both helper cache keys, which are keyed on APK bytes; size.yml and release-android-snapshot-helper.yml declare it at job level. The fixture-repack cluster keeps its own pin: a different command family that ships no helper APK. Closes #2527
124 lines
4.3 KiB
YAML
124 lines
4.3 KiB
YAML
name: Size
|
|
|
|
on:
|
|
pull_request:
|
|
paths-ignore:
|
|
- 'docs/**'
|
|
- 'website/**'
|
|
- 'README.md'
|
|
- 'AGENTS.md'
|
|
- 'CHANGELOG.md'
|
|
- 'CONTEXT.md'
|
|
- 'CONTRIBUTING.md'
|
|
- 'LICENSE'
|
|
- 'SECURITY.md'
|
|
- '.github/actions/build-docs/action.yml'
|
|
- '.github/workflows/deploy.yml'
|
|
- '.github/workflows/pr-preview.yml'
|
|
- '.github/workflows/pr-preview-cleanup.yml'
|
|
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
|
|
concurrency:
|
|
group: size-${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
bundle-size:
|
|
name: Bundle Size
|
|
if: github.event.pull_request.head.repo.full_name == github.repository
|
|
runs-on: ubuntu-latest
|
|
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: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup toolchain
|
|
uses: ./.github/actions/setup-node-pnpm
|
|
|
|
- name: Preserve report scripts
|
|
run: |
|
|
mkdir -p /tmp/agent-device-size-report
|
|
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"
|
|
|
|
# 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
|
|
# runner so the base/PR comparison stays same-machine.
|
|
- name: Restore base dist cache
|
|
id: base-dist-cache
|
|
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.2.3
|
|
with:
|
|
path: dist
|
|
key: size-base-dist-${{ github.event.pull_request.base.sha }}
|
|
|
|
- name: Measure base size
|
|
run: |
|
|
git checkout --detach "${{ github.event.pull_request.base.sha }}"
|
|
cp scripts/size-report-package.mjs /tmp/agent-device-size-report/
|
|
pnpm install --frozen-lockfile
|
|
if [ "${{ steps.base-dist-cache.outputs.cache-hit }}" != "true" ]; then
|
|
pnpm build
|
|
fi
|
|
node /tmp/agent-device-size-report/size-report.mjs \
|
|
--startup-runs 7 \
|
|
--json /tmp/agent-device-size-base.json
|
|
|
|
# Save immediately: the job-end dist belongs to the PR head, not the base.
|
|
- name: Save base dist cache
|
|
if: steps.base-dist-cache.outputs.cache-hit != 'true'
|
|
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.2.3
|
|
with:
|
|
path: dist
|
|
key: size-base-dist-${{ github.event.pull_request.base.sha }}
|
|
|
|
- name: Measure PR size
|
|
run: |
|
|
git checkout --detach "${{ github.event.pull_request.head.sha }}"
|
|
pnpm install --frozen-lockfile
|
|
pnpm build
|
|
pnpm size \
|
|
--compare /tmp/agent-device-size-base.json \
|
|
--startup-runs 7 \
|
|
--json .tmp/size-report.json \
|
|
--markdown .tmp/size-report.md
|
|
cp /tmp/agent-device-size-base.json .tmp/size-report-base.json
|
|
|
|
- name: Upload detailed size reports
|
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
with:
|
|
name: size-report
|
|
path: .tmp/size-report*.json
|
|
include-hidden-files: true
|
|
if-no-files-found: error
|
|
|
|
- name: Add job summary
|
|
run: cat .tmp/size-report.md >> "$GITHUB_STEP_SUMMARY"
|
|
|
|
- name: Comment on PR
|
|
env:
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
run: pnpm size --post-comment .tmp/size-report.md
|