Skip to content

Commit 3b6c6ac

Browse files
committed
update workflows: generalize Android CI to dynamically use matrix-based configuration files across all steps
1 parent 4926e16 commit 3b6c6ac

3 files changed

Lines changed: 40 additions & 18 deletions

File tree

.github/workflows/e2e-android-test.yml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ jobs:
3030
- os: ubuntu-latest # Ubuntu
3131
android-api: 30
3232
arch: x86_64
33+
config_file: experiments/android_x86_64_ci.yaml
3334
# - os: macOS-latest # macOS on Apple Silicon (M1/M2)
3435
# android-api: 30
3536
# arch: arm64
37+
# config_file: experiments/android_example.yaml
3638
runs-on: ${{ matrix.os }}
3739

3840
steps:
@@ -111,12 +113,13 @@ jobs:
111113
rm -rf $HOME/ovmb_cache/models 2>/dev/null || true
112114
fi
113115
114-
# Use x86_64 config for CI
115-
CONFIG_FILE="experiments/android_x86_64_ci.yaml"
116-
echo "📱 Using x86_64 configuration for CI: $CONFIG_FILE"
116+
# Use config file from matrix
117+
echo "📱 Using configuration: ${{ matrix.config_file }}"
118+
echo " Architecture: ${{ matrix.arch }}"
119+
echo " OS: ${{ matrix.os }}"
117120
118121
python -m ovmobilebench.cli setup-android \
119-
-c $CONFIG_FILE \
122+
-c ${{ matrix.config_file }} \
120123
--api ${{ matrix.android-api }} \
121124
--create-avd \
122125
--verbose
@@ -128,8 +131,8 @@ jobs:
128131
# === PREPARE EMULATOR ===
129132
- name: Start Android Emulator
130133
run: |
131-
python tests/e2e/test_emulator_helper.py -c experiments/android_x86_64_ci.yaml start-emulator &
132-
python tests/e2e/test_emulator_helper.py -c experiments/android_x86_64_ci.yaml wait-for-boot
134+
python tests/e2e/test_emulator_helper.py -c ${{ matrix.config_file }} start-emulator &
135+
python tests/e2e/test_emulator_helper.py -c ${{ matrix.config_file }} wait-for-boot
133136
134137
- name: Setup ccache
135138
uses: hendrikmuhs/ccache-action@v1.2
@@ -142,7 +145,7 @@ jobs:
142145

143146
# === PREPARE MODEL ===
144147
- name: Download ResNet-50 model
145-
run: python tests/e2e/test_model_helper.py -c experiments/android_x86_64_ci.yaml download-resnet50
148+
run: python tests/e2e/test_model_helper.py -c ${{ matrix.config_file }} download-resnet50
146149

147150
# === OVMOBILEBENCH PIPELINE ===
148151
- name: List available devices
@@ -151,7 +154,7 @@ jobs:
151154
- name: Build OpenVINO for Android
152155
run: |
153156
python -m ovmobilebench.cli build \
154-
-c experiments/android_x86_64_ci.yaml \
157+
-c ${{ matrix.config_file }} \
155158
--verbose
156159
157160
- name: Show ccache statistics
@@ -162,33 +165,33 @@ jobs:
162165
- name: Package OpenVINO runtime and model
163166
run: |
164167
python -m ovmobilebench.cli package \
165-
-c experiments/android_x86_64_ci.yaml \
168+
-c ${{ matrix.config_file }} \
166169
--verbose
167170
168171
- name: Deploy to Android device
169172
run: |
170173
python -m ovmobilebench.cli deploy \
171-
-c experiments/android_x86_64_ci.yaml \
174+
-c ${{ matrix.config_file }} \
172175
--verbose
173176
174177
- name: Run benchmark on device
175178
run: |
176179
python -m ovmobilebench.cli run \
177-
-c experiments/android_x86_64_ci.yaml \
180+
-c ${{ matrix.config_file }} \
178181
--verbose
179182
180183
- name: Generate benchmark report
181184
run: |
182185
python -m ovmobilebench.cli report \
183-
-c experiments/android_x86_64_ci.yaml \
186+
-c ${{ matrix.config_file }} \
184187
--verbose
185188
186189
# === ALTERNATIVE: Run all stages at once ===
187190
- name: Run complete pipeline (alternative)
188191
if: false # Set to true to use this instead of individual stages
189192
run: |
190193
python -m ovmobilebench.cli all \
191-
-c experiments/android_x86_64_ci.yaml \
194+
-c ${{ matrix.config_file }} \
192195
--verbose
193196
194197
# === VALIDATION ===
@@ -201,7 +204,7 @@ jobs:
201204
# === CLEANUP ===
202205
- name: Stop emulator
203206
if: always()
204-
run: python tests/e2e/test_emulator_helper.py -c experiments/android_x86_64_ci.yaml stop-emulator
207+
run: python tests/e2e/test_emulator_helper.py -c ${{ matrix.config_file }} stop-emulator
205208

206209
- name: Upload artifacts
207210
if: always()

ovmobilebench/cli.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ def setup_android(
220220
"experiments/android_example.yaml", "-c", "--config", help="Path to configuration file"
221221
),
222222
api_level: int = typer.Option(None, "--api", help="Android API level (overrides config)"),
223+
arch: str = typer.Option(
224+
None, "--arch", help="Architecture (x86_64, arm64-v8a) (overrides config)"
225+
),
223226
create_avd: bool = typer.Option(
224227
None, "--create-avd", help="Create AVD for emulator (overrides config)"
225228
),
@@ -233,7 +236,7 @@ def setup_android(
233236
):
234237
"""Setup Android SDK/NDK for OVMobileBench."""
235238
from ovmobilebench.android.installer.api import ensure_android_tools, verify_installation
236-
from ovmobilebench.android.installer.types import NdkSpec
239+
from ovmobilebench.android.installer.types import Arch, NdkSpec
237240
from ovmobilebench.config.loader import load_experiment
238241

239242
# Load config
@@ -244,6 +247,12 @@ def setup_android(
244247
api_level = (
245248
experiment.device.api_level if hasattr(experiment.device, "api_level") else 30
246249
)
250+
if arch is None:
251+
# Get architecture from openvino.toolchain.abi in config
252+
if hasattr(experiment, "openvino") and hasattr(experiment.openvino, "toolchain"):
253+
arch = experiment.openvino.toolchain.abi
254+
else:
255+
arch = "x86_64" # Default for CI
247256
if create_avd is None:
248257
# Default: create AVD only if no physical devices specified in config
249258
create_avd = (
@@ -261,6 +270,8 @@ def setup_android(
261270
console.print(f"[yellow]Warning: Could not load config: {e}[/yellow]")
262271
if api_level is None:
263272
api_level = 30
273+
if arch is None:
274+
arch = "x86_64" # Default for CI
264275
if create_avd is None:
265276
create_avd = False
266277
if sdk_root is None:
@@ -283,7 +294,7 @@ def setup_android(
283294
system_images = verification_result.get("system_images", [])
284295
ndk_versions = verification_result.get("ndk_versions", [])
285296

286-
required_system_image = f"system-images;android-{api_level};google_apis;arm64-v8a"
297+
required_system_image = f"system-images;android-{api_level};google_apis;{arch}"
287298
has_system_image = any(required_system_image in img for img in system_images)
288299

289300
# Check what needs to be installed
@@ -327,11 +338,13 @@ def setup_android(
327338
console.print("Using latest available NDK version")
328339

329340
try:
341+
# Cast arch to proper type
342+
arch_typed: Arch = arch # type: ignore
330343
result = ensure_android_tools(
331344
sdk_root=sdk_root,
332345
api=api_level,
333346
target="google_apis",
334-
arch="arm64-v8a",
347+
arch=arch_typed,
335348
ndk=NdkSpec(alias=ndk_alias),
336349
install_platform_tools=True,
337350
install_emulator=True,

tests/e2e/test_emulator_helper.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,13 @@ def start_emulator(avd_name: str = None, api_level: int = 30):
119119
elif platform.system() == "Darwin": # macOS
120120
cmd.extend(["-accel", "on"])
121121

122-
subprocess.Popen(cmd)
122+
# Set environment variables for AVD location
123+
env = os.environ.copy()
124+
env["ANDROID_SDK_ROOT"] = ANDROID_HOME
125+
env["ANDROID_HOME"] = ANDROID_HOME
126+
env["ANDROID_AVD_HOME"] = str(Path(ANDROID_HOME) / "avd")
127+
128+
subprocess.Popen(cmd, env=env)
123129
logger.info("Emulator started in background")
124130

125131

0 commit comments

Comments
 (0)