55 workflow_dispatch :
66
77jobs :
8- build-llm-demo :
9- name : build-llm-demo
10- uses : pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
8+ build-android :
9+ name : build-android
10+ runs-on : 16-core-ubuntu
1111 permissions :
1212 id-token : write
1313 contents : read
14- with :
15- runner : linux.2xlarge
16- docker-image : ci-image:executorch-ubuntu-22.04-clang12-android
17- submodules : ' recursive'
18- ref : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
19- timeout : 90
20- upload-artifact : android-apps
21- upload-artifact-to-s3 : true
22- script : |
23- set -eux
14+ env :
15+ PYTHON_EXECUTABLE : python3
16+ steps :
17+ - uses : actions/checkout@v4
18+ with :
19+ submodules : recursive
2420
25- # Use sccache for NDK compiler as well
26- export CMAKE_CXX_COMPILER_LAUNCHER=sccache
27- export CMAKE_C_COMPILER_LAUNCHER=sccache
21+ - name : Setup Python
22+ uses : actions/setup-python@v5
23+ with :
24+ python-version : ' 3.11'
2825
29- # The generic Linux job chooses to use base env, not the one setup by the image
30- CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
31- conda activate "${CONDA_ENV}"
32- PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool buck2
33- export ARTIFACTS_DIR_NAME=artifacts-to-be-uploaded
34- mkdir -p ${ARTIFACTS_DIR_NAME}/
26+ - name : Install Python dependencies
27+ run : |
28+ pip install torch executorch
3529
36- # Build LLM Demo for Android
37- export BUILD_AAR_DIR=aar-out
38- mkdir -p $BUILD_AAR_DIR
39- bash scripts/build_android_library.sh
40- cp ${BUILD_AAR_DIR}/executorch.aar $ARTIFACTS_DIR_NAME
30+ - name : Set up Android NDK
31+ run : |
32+ # Use the pre-installed NDK from the GH runner
33+ ANDROID_NDK=$(ls -d "$ANDROID_HOME/ndk/"*/ 2>/dev/null | sort -V | tail -1)
34+ if [ -z "$ANDROID_NDK" ]; then
35+ echo "No Android NDK found at $ANDROID_HOME/ndk/"
36+ exit 1
37+ fi
38+ ANDROID_NDK="${ANDROID_NDK%/}"
39+ echo "Using Android NDK: $ANDROID_NDK"
40+ echo "ANDROID_NDK=$ANDROID_NDK" >> "$GITHUB_ENV"
41+
42+ - name : Build Android library
43+ run : |
44+ set -eux
45+ export BUILD_AAR_DIR=aar-out
46+ mkdir -p $BUILD_AAR_DIR
47+ bash scripts/build_android_library.sh
4148
42- mkdir -p ${ARTIFACTS_DIR_NAME}/library_test_dir
43- bash extension/android/executorch_android/android_test_setup.sh
44- (cd extension/android; ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew :executorch_android:assembleAndroidTest)
45- cp extension/android/executorch_android/build/outputs/apk/androidTest/debug/executorch_android-debug-androidTest.apk "${ARTIFACTS_DIR_NAME}/library_test_dir"
49+ - name : Build Android test APK
50+ run : |
51+ set -eux
52+ bash extension/android/executorch_android/android_test_setup.sh
53+ cd extension/android
54+ ANDROID_HOME="${ANDROID_HOME}" ./gradlew :executorch_android:assembleAndroidTest
4655
47- mkdir -p ${ARTIFACTS_DIR_NAME}/fp32-xnnpack-custom
48- bash examples/models/llama/install_requirements.sh
49- bash ".ci/scripts/test_llama.sh" -model stories110M -build_tool cmake -dtype fp16 -mode portable -upload ${ARTIFACTS_DIR_NAME}/fp32-xnnpack-custom
56+ - name : Upload artifacts
57+ uses : actions/upload-artifact@v4
58+ with :
59+ name : android-apps
60+ path : |
61+ aar-out/executorch.aar
62+ extension/android/executorch_android/build/outputs/apk/androidTest/debug/executorch_android-debug-androidTest.apk
5063
5164 # Running Android emulator directly on the runner and not using Docker
5265 run-emulator :
53- needs : build-llm-demo
66+ needs : build-android
5467 # NB: This job runs on the shared 8-core-ubuntu runner; KVM / bare-metal assumptions no longer apply
5568 runs-on : 8-core-ubuntu
5669 env :
57- ANDROID_NDK_VERSION : r28c
5870 API_LEVEL : 34
5971 steps :
6072 - name : Setup SSH (Click me for login details)
6173 uses : pytorch/test-infra/.github/actions/setup-ssh@main
6274 with :
6375 github-secret : ${{ secrets.GITHUB_TOKEN }}
6476 instructions : |
65- This is used to run Android emulators, ANDROID_HOME is installed at /opt/android/sdk
77+ This is used to run Android emulators
6678
67- - uses : actions/checkout@v3
79+ - uses : actions/checkout@v4
6880 with :
6981 submodules : false
7082
71- - name : Setup conda
72- uses : pytorch/test-infra/.github/ actions/setup-miniconda@main
83+ - name : Download Artifacts
84+ uses : actions/download-artifact@v4
7385 with :
74- python-version : ' 3.10'
75-
76- - name : Install Android dependencies
77- shell : bash
78- run : |
79- set -eux
86+ name : android-apps
8087
81- # Reuse the script that install Android on ET Docker image
82- sudo -E bash .ci/docker/common/install_android.sh
83-
84- # After https://github.com/ReactiveCircus/android-emulator-runner/releases/tag/v2.33.0 release,
85- # it seems that we need to chown the Android setup to the current user instead of root to
86- # avoid permission issue
87- sudo chown -R "${USER}" /opt/android
88-
89- - name : Download Artifacts
90- shell : bash
88+ - name : Prepare test APK
9189 run : |
92- set -eux
93- curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/fp32-xnnpack-custom/model.zip
94- curl -o android-test-debug-androidTest.apk https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/library_test_dir/executorch_android-debug-androidTest.apk
95- unzip model.zip
96- mv *.pte model.pte
97-
98- - name : Gradle cache
99- uses : gradle/actions/setup-gradle@v3
90+ cp extension/android/executorch_android/build/outputs/apk/androidTest/debug/executorch_android-debug-androidTest.apk android-test-debug-androidTest.apk
10091
10192 - name : AVD cache
10293 uses : actions/cache@v4
@@ -109,21 +100,15 @@ jobs:
109100
110101 # NB: It takes about 10m to cold boot the emulator here
111102 - name : Run Android emulator
112- env :
113- ANDROID_HOME : /opt/android/sdk
114103 uses : reactivecircus/android-emulator-runner@v2
115104 with :
116105 api-level : ${{ env.API_LEVEL }}
117106 arch : x86_64
118107 script : ./scripts/run_android_emulator.sh
119- # NB: This is to boot the emulator faster following the instructions on
120- # https://github.com/ReactiveCircus/android-emulator-runner. The max number
121- # of cores we can set is 6, any higher number will be reduced to 6.
122108 cores : 6
123109 ram-size : 16384M
124110 heap-size : 12288M
125111 force-avd-creation : false
126112 disable-animations : true
127113 emulator-options : -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
128- # This is to make sure that the job doesn't fail flakily
129114 emulator-boot-timeout : 900
0 commit comments