diff --git a/.github/workflows/llm-android.yml b/.github/workflows/llm-android.yml index 789ba0f266..1177c9c7eb 100644 --- a/.github/workflows/llm-android.yml +++ b/.github/workflows/llm-android.yml @@ -32,6 +32,10 @@ on: description: 'Custom URL for tokenizer file (only used when model_preset is custom)' required: false type: string + local_aar: + description: 'URL to download a local AAR file. When set, the workflow will download the AAR and use it instead of the Maven dependency.' + required: false + type: string permissions: contents: read @@ -74,6 +78,12 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 + - name: Download local AAR + if: ${{ inputs.local_aar }} + run: | + mkdir -p llm/android/LlamaDemo/app/libs + curl -fL -o llm/android/LlamaDemo/app/libs/executorch.aar "${{ inputs.local_aar }}" + - name: AVD cache uses: actions/cache@v4 id: avd-cache @@ -145,6 +155,7 @@ jobs: uses: reactivecircus/android-emulator-runner@v2 env: MODEL_PRESET: ${{ inputs.model_preset || 'stories' }} + USE_LOCAL_AAR: ${{ inputs.local_aar != '' }} with: api-level: ${{ env.API_LEVEL }} arch: ${{ env.ARCH }} @@ -154,7 +165,7 @@ jobs: emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot-save -memory 16384 disable-animations: true working-directory: llm/android/LlamaDemo - script: bash ./scripts/run-ci-tests.sh "$MODEL_PRESET" "$MODEL_FILE" "$TOKENIZER_FILE" + script: bash ./scripts/run-ci-tests.sh "$MODEL_PRESET" "$MODEL_FILE" "$TOKENIZER_FILE" "$USE_LOCAL_AAR" - name: Add model response to summary if: always() diff --git a/llm/android/LlamaDemo/scripts/run-ci-tests.sh b/llm/android/LlamaDemo/scripts/run-ci-tests.sh index a26ecbbc49..cfe6f8d662 100755 --- a/llm/android/LlamaDemo/scripts/run-ci-tests.sh +++ b/llm/android/LlamaDemo/scripts/run-ci-tests.sh @@ -6,7 +6,7 @@ # LICENSE file in the root directory of this source tree. # CI test script for running instrumentation tests with pre-downloaded models -# Usage: ./run-ci-tests.sh +# Usage: ./run-ci-tests.sh [use_local_aar] # # This script is designed for CI environments where models are pre-downloaded # to /tmp/llama_models/ before the emulator starts. @@ -16,11 +16,13 @@ set -ex MODEL_PRESET="$1" MODEL_FILE="$2" TOKENIZER_FILE="$3" +USE_LOCAL_AAR="${4:-false}" echo "=== Test Configuration ===" echo "MODEL_PRESET: $MODEL_PRESET" echo "MODEL_FILE: $MODEL_FILE" echo "TOKENIZER_FILE: $TOKENIZER_FILE" +echo "USE_LOCAL_AAR: $USE_LOCAL_AAR" echo "=== Emulator Memory Info ===" adb shell cat /proc/meminfo | head -5 @@ -90,9 +92,11 @@ adb logcat > /tmp/logcat.txt & LOGCAT_PID=$! echo "=== Starting Gradle ===" -./gradlew connectedCheck \ - -PskipModelDownload=true \ - -PmodelPreset="$MODEL_PRESET" +GRADLE_ARGS="-PskipModelDownload=true -PmodelPreset=\"$MODEL_PRESET\"" +if [ "$USE_LOCAL_AAR" = "true" ]; then + GRADLE_ARGS="$GRADLE_ARGS -PuseLocalAar=true" +fi +eval ./gradlew connectedCheck "$GRADLE_ARGS" TEST_EXIT_CODE=$? echo "=== Model directory after Gradle ==="