Skip to content

Commit 3e19dcf

Browse files
authored
Update android-build1.yml
1 parent bb36fee commit 3e19dcf

File tree

1 file changed

+41
-49
lines changed

1 file changed

+41
-49
lines changed

.github/workflows/android-build1.yml

Lines changed: 41 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,25 @@ on:
33
workflow_dispatch:
44
push:
55
branches:
6-
- AE
7-
- rel-*
6+
- AE
7+
- rel-*
88
pull_request:
9-
109
concurrency:
1110
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1211
cancel-in-progress: true
13-
1412
env:
1513
ORT_NIGHTLY_REST_API: "https://feeds.dev.azure.com/aiinfra/PublicPackages/_apis/packaging/Feeds/ORT-Nightly/packages?packageNameQuery=Microsoft.ML.OnnxRuntime&api-version=6.0-preview.1"
1614
ORT_PACKAGE_NAME: "Microsoft.ML.OnnxRuntime"
1715
ORT_NIGHTLY_SOURCE: "https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ORT-Nightly/nuget/v3/index.json"
16+
# ANDROID_ABI: "arm64-v8a"
1817
ANDROID_ABI: "x86_64"
19-
2018
jobs:
2119
android_x64:
20+
# Note: linux is the only good option for the Android emulator currently.
21+
# it doesn't work on macos-14.
22+
# HVF error: HV_UNSUPPORTED
23+
# it works on macos-13 but with macos-15 being released soon that isn't a long term solution.
2224
runs-on: ubuntu-latest
23-
2425
steps:
2526
- name: Checkout OnnxRuntime GenAI repo
2627
uses: actions/checkout@v4
@@ -39,67 +40,58 @@ jobs:
3940
with:
4041
gradle-version: '8.6'
4142

43+
# Check the NDK that we're using
44+
- name: Check Android NDKs
45+
run: |
46+
set -e -x
47+
uname -m
48+
echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME"
49+
echo "ANDROID_NDK_LATEST_HOME=$ANDROID_NDK_LATEST_HOME"
50+
ls -l $ANDROID_HOME/ndk
51+
# Needed for linux
52+
- name: Install jq
53+
run: |
54+
sudo apt-get install jq
4255
- uses: actions/setup-dotnet@v4
4356
with:
4457
dotnet-version: '8.0.x'
4558

46-
# Install Android SDK components manually
47-
- name: Install Android SDK components
48-
run: |
49-
sudo apt-get update
50-
sudo apt-get install -y wget unzip
51-
mkdir -p $HOME/Android/Sdk
52-
cd $HOME/Android/Sdk
53-
54-
# Download SDK command line tools
55-
wget https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip
56-
unzip commandlinetools-linux-8512546_latest.zip
57-
rm commandlinetools-linux-8512546_latest.zip
58-
59-
# Set environment variables
60-
echo "export ANDROID_HOME=$HOME/Android/Sdk" >> ~/.bashrc
61-
echo "export ANDROID_SDK_ROOT=$HOME/Android/Sdk" >> ~/.bashrc
62-
echo "export PATH=\$PATH:\$ANDROID_HOME/cmdline-tools/latest/bin" >> ~/.bashrc
63-
source ~/.bashrc
64-
65-
# Verify sdkmanager location
66-
echo "sdkmanager location: $(which sdkmanager)"
67-
68-
# Install SDK components
69-
yes | sdkmanager --licenses
70-
sdkmanager --update
71-
sdkmanager "platform-tools" "emulator" "system-images;android-27;default;x86_64" "platforms;android-27"
59+
- name: Checkout OnnxRuntime GenAI repo
60+
uses: actions/checkout@v4
61+
with:
62+
submodules: true
7263

73-
# Verify SDK Tools Installation
74-
- name: Verify SDK Tools Installation
64+
- name: Get the Latest OnnxRuntime Nightly Version
7565
run: |
76-
echo $ANDROID_HOME
77-
sdkmanager --version
78-
sdkmanager --list
79-
80-
# Create Android build
66+
ORT_NIGHTLY_VERSION=$(curl -s "${{ env.ORT_NIGHTLY_REST_API }}" | jq -r '.value[0].versions[0].normalizedVersion')
67+
echo "$ORT_NIGHTLY_VERSION"
68+
echo "ORT_NIGHTLY_VERSION=$ORT_NIGHTLY_VERSION" >> $GITHUB_ENV
69+
# have to create a dummy project to use `add package`
70+
- name: Download OnnxRuntime Nightly
71+
run: |
72+
dotnet new console
73+
dotnet add package ${{ env.ORT_PACKAGE_NAME }} --version ${{ env.ORT_NIGHTLY_VERSION }} --source ${{ env.ORT_NIGHTLY_SOURCE }} --package-directory .
74+
- name: Extract ONNX Runtime AAR
75+
run: |
76+
set -e -x
77+
ls -l
78+
unzip microsoft.ml.onnxruntime/${{ env.ORT_NIGHTLY_VERSION }}/runtimes/android/native/onnxruntime.aar -d ort
79+
ls -lR ort
8180
- name: Create Android build
8281
run: |
8382
set -e -x
8483
rm -rf build
8584
./build.sh --android --android_api=27 --android_ndk_path=${ANDROID_NDK_LATEST_HOME} --config=RelWithDebInfo --android_abi=${{ env.ANDROID_ABI }} --parallel --build_java --update
86-
87-
# Run Android build
8885
- name: Run Android build
8986
run: |
9087
set -e -x
9188
./build.sh --android --android_api=27 --android_ndk_path=${ANDROID_NDK_LATEST_HOME} --config=RelWithDebInfo --android_abi=${{ env.ANDROID_ABI }} --parallel --build_java --build
92-
93-
# Enable KVM group perms so Android emulator can run
94-
- name: Enable KVM group perms
89+
- name: Enable KVM group perms so Android emulator can run
9590
run: |
9691
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
9792
sudo udevadm control --reload-rules
9893
sudo udevadm trigger --name-match=kvm
99-
100-
# Run the Android Emulator
101-
- name: Run Android Emulator
94+
- name: Run Android tests
10295
run: |
10396
set -e -x
104-
$ANDROID_HOME/emulator/emulator -avd test_avd -no-window -no-audio -gpu off &
105-
adb wait-for-device
97+
./build.sh --android --android_api=27 --android_ndk_path=${ANDROID_NDK_LATEST_HOME} --config=RelWithDebInfo --android_abi=${{ env.ANDROID_ABI }} --parallel --build_java --android_run_emulator --test

0 commit comments

Comments
 (0)