Skip to content

Commit 2475175

Browse files
committed
Split LlamaDemo Android workflow into separate file
Move LlamaDemo build and instrumentation tests to llm-android.yml with pull_request trigger. Keep android-build.yml for nightly builds of both LlamaDemo and DeepLabV3Demo on schedule only.
1 parent 504158e commit 2475175

2 files changed

Lines changed: 124 additions & 70 deletions

File tree

.github/workflows/android-build.yml

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
name: Android Build
88

99
on:
10-
pull_request:
11-
branches: [main]
1210
schedule:
1311
# Run nightly at midnight UTC
1412
- cron: '0 0 * * *'
@@ -69,71 +67,3 @@ jobs:
6967
name: ${{ matrix.name }}-apk
7068
path: ${{ matrix.path }}/app/build/outputs/apk/
7169
if-no-files-found: warn
72-
73-
instrumentation-test:
74-
runs-on: ubuntu-latest
75-
strategy:
76-
fail-fast: false
77-
matrix:
78-
include:
79-
- name: LlamaDemo
80-
path: llm/android/LlamaDemo
81-
env:
82-
API_LEVEL: 34
83-
ARCH: x86_64
84-
EMULATOR_OPTIONS: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
85-
86-
name: Instrumentation Test ${{ matrix.name }}
87-
steps:
88-
- name: Checkout repository
89-
uses: actions/checkout@v4
90-
91-
- name: Enable KVM group perms
92-
run: |
93-
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
94-
sudo udevadm control --reload-rules
95-
sudo udevadm trigger --name-match=kvm
96-
97-
- name: Set up JDK 17
98-
uses: actions/setup-java@v4
99-
with:
100-
java-version: '17'
101-
distribution: 'temurin'
102-
103-
- name: Setup Gradle
104-
uses: gradle/actions/setup-gradle@v4
105-
106-
- name: AVD cache
107-
uses: actions/cache@v4
108-
id: avd-cache
109-
with:
110-
path: |
111-
~/.android/avd/*
112-
~/.android/adb*
113-
key: avd-${{ env.API_LEVEL }}-${{ env.ARCH }}
114-
115-
- name: Create AVD and generate snapshot for caching
116-
if: steps.avd-cache.outputs.cache-hit != 'true'
117-
uses: reactivecircus/android-emulator-runner@v2
118-
with:
119-
api-level: ${{ env.API_LEVEL }}
120-
arch: ${{ env.ARCH }}
121-
force-avd-creation: false
122-
ram-size: 16384M
123-
emulator-options: ${{ env.EMULATOR_OPTIONS }}
124-
disable-animations: false
125-
working-directory: ${{ matrix.path }}
126-
script: echo "Generated AVD snapshot for caching."
127-
128-
- name: Run instrumentation tests
129-
uses: reactivecircus/android-emulator-runner@v2
130-
with:
131-
api-level: ${{ env.API_LEVEL }}
132-
arch: ${{ env.ARCH }}
133-
force-avd-creation: false
134-
ram-size: 6144M
135-
emulator-options: -no-snapshot-save ${{ env.EMULATOR_OPTIONS }}
136-
disable-animations: true
137-
working-directory: ${{ matrix.path }}
138-
script: |
139-
./gradlew connectedCheck

.github/workflows/llm-android.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
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: LlamaDemo Android
8+
9+
on:
10+
pull_request:
11+
branches: [main]
12+
paths:
13+
- 'llm/android/**'
14+
- '.github/workflows/llm-android.yml'
15+
workflow_dispatch:
16+
inputs:
17+
local_aar:
18+
description: 'URL to download a local AAR file. When set, the workflow will download the AAR and use it instead of the Maven dependency.'
19+
required: false
20+
type: string
21+
22+
permissions:
23+
contents: read
24+
25+
jobs:
26+
build:
27+
runs-on: ubuntu-latest
28+
name: Build LlamaDemo
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
33+
- name: Set up JDK 17
34+
uses: actions/setup-java@v4
35+
with:
36+
java-version: '17'
37+
distribution: 'temurin'
38+
39+
- name: Setup Gradle
40+
uses: gradle/actions/setup-gradle@v4
41+
42+
- name: Download local AAR
43+
if: ${{ inputs.local_aar }}
44+
run: |
45+
mkdir -p llm/android/LlamaDemo/app/libs
46+
curl -fL -o llm/android/LlamaDemo/app/libs/executorch.aar "${{ inputs.local_aar }}"
47+
48+
- name: Build with Gradle
49+
working-directory: llm/android/LlamaDemo
50+
run: |
51+
if [ -n "${{ inputs.local_aar }}" ]; then
52+
./gradlew build --no-daemon -PuseLocalAar=true
53+
else
54+
./gradlew build --no-daemon
55+
fi
56+
57+
- name: Upload build artifacts
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: LlamaDemo-apk
61+
path: llm/android/LlamaDemo/app/build/outputs/apk/
62+
if-no-files-found: warn
63+
64+
instrumentation-test:
65+
runs-on: ubuntu-latest
66+
env:
67+
API_LEVEL: 34
68+
ARCH: x86_64
69+
EMULATOR_OPTIONS: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
70+
71+
name: Instrumentation Test LlamaDemo
72+
steps:
73+
- name: Checkout repository
74+
uses: actions/checkout@v4
75+
76+
- name: Enable KVM group perms
77+
run: |
78+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
79+
sudo udevadm control --reload-rules
80+
sudo udevadm trigger --name-match=kvm
81+
82+
- name: Set up JDK 17
83+
uses: actions/setup-java@v4
84+
with:
85+
java-version: '17'
86+
distribution: 'temurin'
87+
88+
- name: Setup Gradle
89+
uses: gradle/actions/setup-gradle@v4
90+
91+
- name: AVD cache
92+
uses: actions/cache@v4
93+
id: avd-cache
94+
with:
95+
path: |
96+
~/.android/avd/*
97+
~/.android/adb*
98+
key: avd-${{ env.API_LEVEL }}-${{ env.ARCH }}
99+
100+
- name: Create AVD and generate snapshot for caching
101+
if: steps.avd-cache.outputs.cache-hit != 'true'
102+
uses: reactivecircus/android-emulator-runner@v2
103+
with:
104+
api-level: ${{ env.API_LEVEL }}
105+
arch: ${{ env.ARCH }}
106+
force-avd-creation: false
107+
ram-size: 16384M
108+
emulator-options: ${{ env.EMULATOR_OPTIONS }}
109+
disable-animations: false
110+
working-directory: llm/android/LlamaDemo
111+
script: echo "Generated AVD snapshot for caching."
112+
113+
- name: Run instrumentation tests
114+
uses: reactivecircus/android-emulator-runner@v2
115+
with:
116+
api-level: ${{ env.API_LEVEL }}
117+
arch: ${{ env.ARCH }}
118+
force-avd-creation: false
119+
ram-size: 6144M
120+
emulator-options: -no-snapshot-save ${{ env.EMULATOR_OPTIONS }}
121+
disable-animations: true
122+
working-directory: llm/android/LlamaDemo
123+
script: |
124+
./gradlew connectedCheck

0 commit comments

Comments
 (0)