-
Notifications
You must be signed in to change notification settings - Fork 2
257 lines (219 loc) Β· 8.56 KB
/
e2e-android-test.yml
File metadata and controls
257 lines (219 loc) Β· 8.56 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
name: E2E Android Test - Full Pipeline Example
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
# schedule:
# - cron: '0 2 * * *' # Daily at 2 AM UTC
workflow_dispatch:
inputs:
clear_cache:
description: 'Clear all caches and rebuild from scratch'
required: false
default: 'false'
type: choice
options:
- 'false'
- 'true'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
e2e-android-pipeline:
strategy:
matrix:
include:
- os: ubuntu-latest # Ubuntu
android-api: 30
arch: x86_64
config_file: experiments/android_x86_64_ci.yaml
# - os: macOS-latest # macOS on Apple Silicon (M1/M2)
# android-api: 30
# arch: arm64-v8a # Android ARM64 architecture
# config_file: experiments/android_example.yaml
runs-on: ${{ matrix.os }}
steps:
# === SETUP PHASE ===
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: |
requirements.txt
setup.py
- name: Install OVMobileBench
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
- name: Install build tools
run: |
if [ "${{ runner.os }}" = "Linux" ]; then
sudo apt-get update
sudo apt-get install -y ccache ninja-build
elif [ "${{ runner.os }}" = "macOS" ]; then
# Check if already installed to save time
brew list ccache &>/dev/null || brew install ccache
brew list ninja &>/dev/null || brew install ninja
fi
- name: Setup Java for Android
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Enable KVM for Android emulator (Linux only)
if: runner.os == 'Linux'
run: bash helpers/scripts/setup_kvm_linux.sh
- name: Enable Hypervisor.framework for Android emulator (macOS only)
if: runner.os == 'macOS'
run: bash helpers/scripts/setup_hypervisor_macos.sh
- name: Cache Android SDK
uses: actions/cache@v4
id: android-sdk-cache
with:
path: ovmb_cache/android-sdk
key: android-sdk-${{ runner.os }}-${{ matrix.android-api }}-${{ matrix.arch }}-v1${{
github.event.inputs.clear_cache == 'true' && '-nocache' || '' }}
restore-keys: |
android-sdk-${{ runner.os }}-${{ matrix.android-api }}-${{ matrix.arch }}-
android-sdk-${{ runner.os }}-${{ matrix.android-api }}-
android-sdk-${{ runner.os }}-
- name: Cache Models
uses: actions/cache@v4
id: models-cache
with:
path: ovmb_cache/models
key: models-${{ runner.os }}-${{ hashFiles('helpers/model_helper.py') }}-v1
restore-keys: |
models-${{ runner.os }}-
models-
- name: Setup Android SDK/NDK via OVMobileBench
run: |
# Check if cache was forced to be cleared
if [ "${{ github.event.inputs.clear_cache }}" = "true" ]; then
echo "π§Ή Cache clearing was requested - installing from scratch"
rm -rf $PWD/ovmb_cache/android-sdk 2>/dev/null || true
rm -rf $PWD/ovmb_cache/models 2>/dev/null || true
fi
# Use config file from matrix
echo "π± Using configuration: ${{ matrix.config_file }}"
echo " Architecture: ${{ matrix.arch }}"
echo " OS: ${{ matrix.os }}"
# Set Android environment variables for AVD location
export ANDROID_HOME=$PWD/ovmb_cache/android-sdk
export ANDROID_SDK_ROOT=$PWD/ovmb_cache/android-sdk
export ANDROID_SDK_HOME=$PWD/ovmb_cache/android-sdk
export ANDROID_AVD_HOME=$PWD/ovmb_cache/android-sdk/.android/avd
# Export to GitHub Environment for subsequent steps
echo "ANDROID_HOME=$ANDROID_HOME" >> $GITHUB_ENV
echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" >> $GITHUB_ENV
echo "ANDROID_SDK_HOME=$ANDROID_SDK_HOME" >> $GITHUB_ENV
echo "ANDROID_AVD_HOME=$ANDROID_AVD_HOME" >> $GITHUB_ENV
echo "π Environment variables set:"
echo " ANDROID_HOME=$ANDROID_HOME"
echo " ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT"
echo " ANDROID_SDK_HOME=$ANDROID_SDK_HOME"
echo " ANDROID_AVD_HOME=$ANDROID_AVD_HOME"
python -m ovmobilebench.cli setup-android \
-c ${{ matrix.config_file }} \
--api ${{ matrix.android-api }} \
--arch ${{ matrix.arch }} \
--create-avd \
--verbose
# Display cache stats
echo "π Android SDK setup complete:"
echo " Cache size: $(du -sh $PWD/ovmb_cache 2>/dev/null || echo 'calculating...')"
# List created AVDs
echo "π± Created AVDs:"
ls -la $ANDROID_AVD_HOME 2>/dev/null || echo "AVD directory not found"
# === PREPARE EMULATOR ===
- name: Start Android Emulator
run: |
# Environment variables should already be set from previous step
echo "π Starting emulator with environment:"
echo " ANDROID_AVD_HOME=$ANDROID_AVD_HOME"
echo "π± Available AVDs:"
ls -la $ANDROID_AVD_HOME 2>/dev/null || echo "No AVDs found"
python helpers/emulator_helper.py -c ${{ matrix.config_file }} start-emulator &
# Give emulator a moment to start before checking
sleep 10
python helpers/emulator_helper.py -c ${{ matrix.config_file }} wait-for-boot
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ runner.os }}-${{ matrix.arch }}-android
create-symlink: true
max-size: 2G
# Models are already in ovmb_cache, no separate cache needed
# === PREPARE MODEL ===
- name: Download ResNet-50 model
run: python helpers/model_helper.py -c ${{ matrix.config_file }} download-resnet50
# === OVMOBILEBENCH PIPELINE ===
- name: List available devices
run: python -m ovmobilebench.cli list-devices
- name: Build OpenVINO for Android
run: |
python -m ovmobilebench.cli build \
-c ${{ matrix.config_file }} \
--verbose
- name: Show ccache statistics
run: |
echo "π ccache statistics:"
ccache --show-stats
- name: Package OpenVINO runtime and model
run: |
python -m ovmobilebench.cli package \
-c ${{ matrix.config_file }} \
--verbose
- name: Deploy to Android device
run: |
python -m ovmobilebench.cli deploy \
-c ${{ matrix.config_file }} \
--verbose
- name: Run benchmark on device
run: |
python -m ovmobilebench.cli run \
-c ${{ matrix.config_file }} \
--verbose
- name: Generate benchmark report
run: |
python -m ovmobilebench.cli report \
-c ${{ matrix.config_file }} \
--verbose
# === ALTERNATIVE: Run all stages at once ===
- name: Run complete pipeline (alternative)
if: false # Set to true to use this instead of individual stages
run: |
python -m ovmobilebench.cli all \
-c ${{ matrix.config_file }} \
--verbose
# === VALIDATION ===
- name: Validate results
run: python helpers/validate_results.py
- name: Display benchmark results
run: python helpers/display_results.py
# === CLEANUP ===
- name: Stop emulator
if: always()
run: |
# Environment variables should already be set from setup step
python helpers/emulator_helper.py -c ${{ matrix.config_file }} stop-emulator
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: benchmark-results-${{ matrix.os }}-api${{ matrix.android-api }}
path: |
artifacts/
retention-days: 7
# === REPORT TO PR ===
- name: Post results to PR
if: github.event_name == 'pull_request'
run: |
python helpers/pr_comment.py \
--api ${{ matrix.android-api }} \
--pr ${{ github.event.pull_request.number }}