Skip to content

Use workflow dispatch on a android/release tag for now #3633

Use workflow dispatch on a android/release tag for now

Use workflow dispatch on a android/release tag for now #3633

Workflow file for this run

name: Android
on:
push:
branches:
- main
- release/*
tags:
- ciflow/android/*
pull_request:
paths:
- .ci/docker/**
- .github/workflows/android.yml
- build/*android*.sh
- install_requirements.sh
- examples/demo-apps/android/**
- extension/android/**
- extension/module/**
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
cancel-in-progress: true
jobs:
build-aar:
name: build-aar
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
with:
runner: linux.2xlarge
docker-image: executorch-ubuntu-22.04-clang12-android
submodules: 'true'
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
timeout: 90
upload-artifact: android-apps
upload-artifact-to-s3: true
script: |
set -eux
# The generic Linux job chooses to use base env, not the one setup by the image
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
conda activate "${CONDA_ENV}"
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh buck2
export ARTIFACTS_DIR_NAME=artifacts-to-be-uploaded
# Build LLM Demo for Android
bash build/build_android_llm_demo.sh ${ARTIFACTS_DIR_NAME}
shasum -a 256 "${ARTIFACTS_DIR_NAME}/llm_demo/executorch.aar"
upload-release-aar:
name: upload-release-aar
needs: build-aar
if: ${{ startsWith(github.ref, 'refs/tags/android/release') }}
runs-on: ubuntu-22.04
timeout-minutes: 10
permissions:
id-token: write
contents: read
steps:
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v1.7.0
with:
role-to-assume: arn:aws:iam::308535385114:role/gha_executorch_upload-frameworks-android
aws-region: us-east-1
- name: Upload AAR to RC if ciflow/android/release tag is present
shell: bash
run: |
wget https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/llm_demo/executorch.aar
shasum -a 256 executorch.aar > executorch.aar.sha256sums
pip install awscli==1.32.18
AWS_CMD="aws s3 cp"
VERSION_NAME="$(date +'%Y%m%d')"
${AWS_CMD} executorch.aar s3://ossci-android/executorch/release/${VERSION_NAME}/executorch.aar --acl public-read
${AWS_CMD} executorch.aar.sha256sums s3://ossci-android/executorch/release/${VERSION_NAME}/executorch.aar.sha256sums --acl public-read
# Running Android emulator directly on the runner and not using Docker
run-emulator:
needs: build-aar
# NB: Use metal install for KVM support to run the emulator faster
runs-on: linux.24xl.spr-metal
env:
ANDROID_NDK_VERSION: r26c
API_LEVEL: 34
steps:
- name: Setup SSH (Click me for login details)
uses: pytorch/test-infra/.github/actions/setup-ssh@main
with:
github-secret: ${{ secrets.GITHUB_TOKEN }}
instructions: |
This is used to run Android emulators, ANDROID_HOME is installed at /opt/android/sdk
- uses: actions/checkout@v3
with:
submodules: false
- name: Setup conda
uses: pytorch/test-infra/.github/actions/setup-miniconda@main
with:
python-version: '3.10'
- name: Install Android dependencies
shell: bash
run: |
set -eux
# Reuse the script that install Android on ET Docker image
sudo -E bash .ci/docker/common/install_android.sh
- name: Gradle cache
uses: gradle/actions/setup-gradle@v3
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ env.API_LEVEL }}
# NB: It takes about 10m to cold boot the emulator here
- name: Run Android emulator
env:
ANDROID_HOME: /opt/android/sdk
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.API_LEVEL }}
arch: x86_64
script: ./build/run_android_emulator.sh
# NB: This is to boot the emulator faster following the instructions on
# https://github.com/ReactiveCircus/android-emulator-runner. The max number
# of cores we can set is 6, any higher number will be reduced to 6.
cores: 6
ram-size: 12288M
force-avd-creation: false
disable-animations: true
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
# This is to make sure that the job doesn't fail flakily
emulator-boot-timeout: 900