Skip to content

Commit fd2844c

Browse files
authored
Add Android instrumentation test on emulator (#6364)
Collect artifacts from previous job and run validation Pull Request resolved: #6364
1 parent fbb0acf commit fd2844c

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

.github/workflows/_android.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ jobs:
6666
# avoid permission issue
6767
sudo chown -R "${USER}" /opt/android
6868
69+
- name: Download Artifacts
70+
shell: bash
71+
run: |
72+
set -eux
73+
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/llm_demo/app-debug.apk
74+
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/llm_demo/app-debug-androidTest.apk
75+
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/fp32-xnnpack-custom/model.zip
76+
unzip model.zip
77+
mv *.pte model.pte
78+
6979
- name: Gradle cache
7080
uses: gradle/actions/setup-gradle@v3
7181

.github/workflows/pull.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ jobs:
9999
submodules: 'true'
100100
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
101101
timeout: 900
102+
upload-artifact: android-models
103+
upload-artifact-to-s3: true
102104
script: |
103105
# The generic Linux job chooses to use base env, not the one setup by the image
104106
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
@@ -107,13 +109,15 @@ jobs:
107109
DTYPE=${{ matrix.dtype }}
108110
BUILD_TOOL="cmake"
109111
MODE=${{ matrix.mode }}
112+
ARTIFACTS_DIR_NAME="artifacts-to-be-uploaded/${DTYPE}-${MODE}"
113+
ARTIFACTS_DIR_NAME="${ARTIFACTS_DIR_NAME/+/-}"
110114
111115
# Setup executorch
112116
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
113117
# Install requirements for export_llama
114118
PYTHON_EXECUTABLE=python bash examples/models/llama/install_requirements.sh
115119
# Test llama2
116-
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh stories110M "${BUILD_TOOL}" "${DTYPE}" "${MODE}"
120+
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh stories110M "${BUILD_TOOL}" "${DTYPE}" "${MODE}" "${ARTIFACTS_DIR_NAME}"
117121
118122
test-llama-runner-linux-android:
119123
name: test-llama-runner-linux-android
@@ -320,6 +324,7 @@ jobs:
320324
321325
android:
322326
uses: ./.github/workflows/_android.yml
327+
needs: test-llama-runner-linux
323328

324329
unittest:
325330
uses: ./.github/workflows/_unittest.yml

build/run_android_emulator.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,10 @@ $ADB_PATH wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; d
1818
echo "List all running emulators"
1919
$ADB_PATH devices
2020

21-
# TODO: Run tests on emulator here, atm the script only boots up the emulator
22-
# and exits without doing anything yet
21+
adb install -t app-debug.apk
22+
adb install -t app-debug-androidTest.apk
23+
24+
adb shell mkdir -p /data/local/tmp/llama
25+
adb push model.pte /data/local/tmp/llama
26+
adb push tokenizer.bin /data/local/tmp/llama
27+
adb shell am instrument -w -r com.example.executorchllamademo.test/androidx.test.runner.AndroidJUnitRunner

0 commit comments

Comments
 (0)