forked from pytorch/executorch
-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (100 loc) · 3.44 KB
/
_android.yml
File metadata and controls
114 lines (100 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: Android
on:
workflow_call:
workflow_dispatch:
jobs:
build-android:
name: build-android
runs-on: 16-core-ubuntu
permissions:
id-token: write
contents: read
env:
PYTHON_EXECUTABLE: python3
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Python dependencies
run: |
pip install torch executorch
- name: Set up Android NDK
run: |
# Use the pre-installed NDK from the GH runner
ANDROID_NDK=$(ls -d "$ANDROID_HOME/ndk/"*/ 2>/dev/null | sort -V | tail -1)
if [ -z "$ANDROID_NDK" ]; then
echo "No Android NDK found at $ANDROID_HOME/ndk/"
exit 1
fi
ANDROID_NDK="${ANDROID_NDK%/}"
echo "Using Android NDK: $ANDROID_NDK"
echo "ANDROID_NDK=$ANDROID_NDK" >> "$GITHUB_ENV"
- name: Build Android library
run: |
set -eux
export BUILD_AAR_DIR=aar-out
mkdir -p $BUILD_AAR_DIR
bash scripts/build_android_library.sh
- name: Build Android test APK
run: |
set -eux
bash extension/android/executorch_android/android_test_setup.sh
cd extension/android
ANDROID_HOME="${ANDROID_HOME}" ./gradlew :executorch_android:assembleAndroidTest
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: android-apps
path: |
aar-out/executorch.aar
extension/android/executorch_android/build/outputs/apk/androidTest/debug/executorch_android-debug-androidTest.apk
# Running Android emulator directly on the runner and not using Docker
run-emulator:
needs: build-android
# NB: This job runs on the shared 8-core-ubuntu runner; KVM / bare-metal assumptions no longer apply
runs-on: 8-core-ubuntu
env:
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
- uses: actions/checkout@v4
with:
submodules: false
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: android-apps
- name: Prepare test APK
run: |
cp extension/android/executorch_android/build/outputs/apk/androidTest/debug/executorch_android-debug-androidTest.apk android-test-debug-androidTest.apk
- 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
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.API_LEVEL }}
arch: x86_64
script: ./scripts/run_android_emulator.sh
cores: 6
ram-size: 16384M
heap-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
emulator-boot-timeout: 900