Skip to content

Commit 16e91a3

Browse files
Copilotkirklandsign
andcommitted
Add CI workflow for DL3 instrumentation tests
Co-authored-by: kirklandsign <107070759+kirklandsign@users.noreply.github.com>
1 parent 8371735 commit 16e91a3

3 files changed

Lines changed: 139 additions & 4 deletions

File tree

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
name: DL3 Android Emulator
8+
9+
on:
10+
pull_request:
11+
branches: [main]
12+
paths:
13+
- 'dl3/android/**'
14+
- '.github/workflows/android-emulator.yml'
15+
workflow_dispatch:
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
instrumentation-test:
22+
runs-on: 8-core-ubuntu
23+
env:
24+
API_LEVEL: 34
25+
ARCH: x86_64
26+
27+
name: Instrumentation Test DL3
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
32+
- name: Enable KVM group perms
33+
run: |
34+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
35+
sudo udevadm control --reload-rules
36+
sudo udevadm trigger --name-match=kvm
37+
38+
- name: Set up JDK 17
39+
uses: actions/setup-java@v4
40+
with:
41+
java-version: '17'
42+
distribution: 'temurin'
43+
44+
- name: Setup Gradle
45+
uses: gradle/actions/setup-gradle@v4
46+
47+
- name: AVD cache
48+
uses: actions/cache@v4
49+
id: avd-cache
50+
with:
51+
path: |
52+
~/.android/avd/*
53+
~/.android/adb*
54+
key: avd-${{ env.API_LEVEL }}-${{ env.ARCH }}-ram8G-disk8G-dl3-v1
55+
56+
- name: Create AVD and generate snapshot for caching
57+
if: steps.avd-cache.outputs.cache-hit != 'true'
58+
uses: reactivecircus/android-emulator-runner@v2
59+
with:
60+
api-level: ${{ env.API_LEVEL }}
61+
arch: ${{ env.ARCH }}
62+
ram-size: 8192M
63+
disk-size: 8192M
64+
force-avd-creation: true
65+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot-save -memory 8192
66+
disable-animations: false
67+
working-directory: dl3/android/DeepLabV3Demo
68+
script: echo "Generated AVD snapshot for caching."
69+
70+
- name: Run instrumentation tests
71+
uses: reactivecircus/android-emulator-runner@v2
72+
with:
73+
api-level: ${{ env.API_LEVEL }}
74+
arch: ${{ env.ARCH }}
75+
ram-size: 8192M
76+
disk-size: 8192M
77+
force-avd-creation: true
78+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot-save -memory 8192
79+
disable-animations: true
80+
working-directory: dl3/android/DeepLabV3Demo
81+
script: bash ./scripts/run-ci-tests.sh
82+
83+
- name: Upload logcat
84+
if: always()
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: logcat-dl3
88+
path: /tmp/logcat-dl3.txt
89+
retention-days: 7

dl3/android/DeepLabV3Demo/app/src/androidTest/java/org/pytorch/executorchexamples/dl3/UIWorkflowTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* UI workflow test that simulates the image segmentation workflow.
3333
*
3434
* Prerequisites:
35-
* - Push a .pte model file to app's private storage or ensure model can be downloaded
35+
* - Model will be downloaded automatically by the app during the test
3636
*
3737
* This test validates:
3838
* - Model download/loading workflow
@@ -41,9 +41,9 @@
4141
* - Reset image button functionality
4242
* - Inference time display after segmentation
4343
*
44-
* Note: This test assumes the model is already present or can be downloaded automatically.
45-
* For CI/CD, you may need to push the model file before running tests:
46-
* adb push dl3_xnnpack_fp32.pte /data/local/tmp/
44+
* Note: The test downloads the model from the same URL as MainActivity uses,
45+
* storing it in the app's private storage (package storage), not /data/local/tmp.
46+
* This ensures the test mimics the actual user workflow.
4747
*/
4848
@RunWith(AndroidJUnit4.class)
4949
@LargeTest
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
# CI test script for running DL3 instrumentation tests
9+
# The model will be downloaded automatically by the app during the test
10+
11+
set -ex
12+
13+
echo "=== Test Configuration ==="
14+
echo "DL3 Demo - Model will be downloaded by the app"
15+
16+
echo "=== Emulator Memory Info ==="
17+
adb shell cat /proc/meminfo | head -5
18+
19+
echo "=== Emulator Disk Space ==="
20+
adb shell df -h /data
21+
22+
# Start logcat capture
23+
adb logcat -c
24+
adb logcat > /tmp/logcat-dl3.txt &
25+
LOGCAT_PID=$!
26+
27+
echo "=== Starting Gradle ==="
28+
./gradlew connectedCheck
29+
TEST_EXIT_CODE=$?
30+
31+
# Stop logcat
32+
if [ -n "$LOGCAT_PID" ]; then
33+
kill $LOGCAT_PID 2>/dev/null || true
34+
fi
35+
36+
echo "=== Test completion status ==="
37+
if [ $TEST_EXIT_CODE -eq 0 ]; then
38+
echo "✅ Tests passed successfully"
39+
else
40+
echo "❌ Tests failed with exit code $TEST_EXIT_CODE"
41+
fi
42+
43+
echo "=== Checking for test results in logcat ==="
44+
grep "UIWorkflowTest" /tmp/logcat-dl3.txt || echo "No UIWorkflowTest logs found"
45+
46+
exit $TEST_EXIT_CODE

0 commit comments

Comments
 (0)