|
| 1 | +name: Android |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + workflow_dispatch: |
| 6 | + |
| 7 | +concurrency: |
| 8 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }} |
| 9 | + cancel-in-progress: true |
| 10 | + |
| 11 | +jobs: |
| 12 | + build-llm-demo: |
| 13 | + name: build-llm-demo |
| 14 | + uses: pytorch/test-infra/.github/workflows/linux_job.yml@main |
| 15 | + with: |
| 16 | + runner: linux.2xlarge |
| 17 | + docker-image: executorch-ubuntu-22.04-clang12-android |
| 18 | + submodules: 'true' |
| 19 | + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} |
| 20 | + timeout: 90 |
| 21 | + upload-artifact: android-apps |
| 22 | + upload-artifact-to-s3: true |
| 23 | + script: | |
| 24 | + set -eux |
| 25 | +
|
| 26 | + # The generic Linux job chooses to use base env, not the one setup by the image |
| 27 | + CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]") |
| 28 | + conda activate "${CONDA_ENV}" |
| 29 | + PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh buck2 |
| 30 | + export ARTIFACTS_DIR_NAME=artifacts-to-be-uploaded |
| 31 | +
|
| 32 | + # Build LLM Demo for Android |
| 33 | + bash build/build_android_llm_demo.sh ${ARTIFACTS_DIR_NAME} |
| 34 | +
|
| 35 | + # Running Android emulator directly on the runner and not using Docker |
| 36 | + run-emulator: |
| 37 | + needs: build-llm-demo |
| 38 | + # NB: Use metal install for KVM support to run the emulator faster |
| 39 | + runs-on: linux.24xl.spr-metal |
| 40 | + env: |
| 41 | + ANDROID_NDK_VERSION: r27b |
| 42 | + API_LEVEL: 34 |
| 43 | + steps: |
| 44 | + - name: Setup SSH (Click me for login details) |
| 45 | + uses: pytorch/test-infra/.github/actions/setup-ssh@main |
| 46 | + with: |
| 47 | + github-secret: ${{ secrets.GITHUB_TOKEN }} |
| 48 | + instructions: | |
| 49 | + This is used to run Android emulators, ANDROID_HOME is installed at /opt/android/sdk |
| 50 | +
|
| 51 | + - uses: actions/checkout@v3 |
| 52 | + with: |
| 53 | + submodules: false |
| 54 | + |
| 55 | + - name: Setup conda |
| 56 | + uses: pytorch/test-infra/.github/actions/setup-miniconda@main |
| 57 | + with: |
| 58 | + python-version: '3.10' |
| 59 | + |
| 60 | + - name: Install Android dependencies |
| 61 | + shell: bash |
| 62 | + run: | |
| 63 | + set -eux |
| 64 | +
|
| 65 | + # Reuse the script that install Android on ET Docker image |
| 66 | + sudo -E bash .ci/docker/common/install_android.sh |
| 67 | +
|
| 68 | + # After https://github.com/ReactiveCircus/android-emulator-runner/releases/tag/v2.33.0 release, |
| 69 | + # it seems that we need to chown the Android setup to the current user instead of root to |
| 70 | + # avoid permission issue |
| 71 | + sudo chown -R "${USER}" /opt/android |
| 72 | +
|
| 73 | + - name: Gradle cache |
| 74 | + uses: gradle/actions/setup-gradle@v3 |
| 75 | + |
| 76 | + - name: AVD cache |
| 77 | + uses: actions/cache@v4 |
| 78 | + id: avd-cache |
| 79 | + with: |
| 80 | + path: | |
| 81 | + ~/.android/avd/* |
| 82 | + ~/.android/adb* |
| 83 | + key: avd-${{ env.API_LEVEL }} |
| 84 | + |
| 85 | + # NB: It takes about 10m to cold boot the emulator here |
| 86 | + - name: Run Android emulator |
| 87 | + env: |
| 88 | + ANDROID_HOME: /opt/android/sdk |
| 89 | + uses: reactivecircus/android-emulator-runner@v2 |
| 90 | + with: |
| 91 | + api-level: ${{ env.API_LEVEL }} |
| 92 | + arch: x86_64 |
| 93 | + script: ./build/run_android_emulator.sh |
| 94 | + # NB: This is to boot the emulator faster following the instructions on |
| 95 | + # https://github.com/ReactiveCircus/android-emulator-runner. The max number |
| 96 | + # of cores we can set is 6, any higher number will be reduced to 6. |
| 97 | + cores: 6 |
| 98 | + ram-size: 12288M |
| 99 | + force-avd-creation: false |
| 100 | + disable-animations: true |
| 101 | + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none |
| 102 | + # This is to make sure that the job doesn't fail flakily |
| 103 | + emulator-boot-timeout: 900 |
0 commit comments