|
| 1 | +name: "Android x64 Build" |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - AE |
| 7 | + - rel-* |
| 8 | + pull_request: |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 11 | + cancel-in-progress: true |
| 12 | +env: |
| 13 | + 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" |
| 14 | + ORT_PACKAGE_NAME: "Microsoft.ML.OnnxRuntime" |
| 15 | + ORT_NIGHTLY_SOURCE: "https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ORT-Nightly/nuget/v3/index.json" |
| 16 | + ANDROID_ABI: "x86_64" |
| 17 | +jobs: |
| 18 | + android_x64: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Checkout OnnxRuntime GenAI repo |
| 22 | + uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + submodules: true |
| 25 | + |
| 26 | + - name: Setup Java 17 |
| 27 | + uses: actions/setup-java@v4 |
| 28 | + with: |
| 29 | + java-version: '17' |
| 30 | + distribution: 'temurin' |
| 31 | + cache: 'gradle' |
| 32 | + |
| 33 | + - name: Setup Gradle |
| 34 | + uses: gradle/actions/setup-gradle@v3 |
| 35 | + with: |
| 36 | + gradle-version: '8.6' |
| 37 | + |
| 38 | + - name: Install jq |
| 39 | + run: | |
| 40 | + sudo apt-get install jq |
| 41 | +
|
| 42 | + - uses: actions/setup-dotnet@v4 |
| 43 | + with: |
| 44 | + dotnet-version: '8.0.x' |
| 45 | + |
| 46 | + - name: Get the Latest OnnxRuntime Nightly Version |
| 47 | + run: | |
| 48 | + ORT_NIGHTLY_VERSION=$(curl -s "${{ env.ORT_NIGHTLY_REST_API }}" | jq -r '.value[0].versions[0].normalizedVersion') |
| 49 | + echo "$ORT_NIGHTLY_VERSION" |
| 50 | + echo "ORT_NIGHTLY_VERSION=$ORT_NIGHTLY_VERSION" >> $GITHUB_ENV |
| 51 | +
|
| 52 | + - name: Download OnnxRuntime Nightly |
| 53 | + run: | |
| 54 | + dotnet new console |
| 55 | + dotnet add package ${{ env.ORT_PACKAGE_NAME }} --version ${{ env.ORT_NIGHTLY_VERSION }} --source ${{ env.ORT_NIGHTLY_SOURCE }} --package-directory . |
| 56 | +
|
| 57 | + - name: Extract ONNX Runtime AAR |
| 58 | + run: | |
| 59 | + set -e -x |
| 60 | + unzip microsoft.ml.onnxruntime/${{ env.ORT_NIGHTLY_VERSION }}/runtimes/android/native/onnxruntime.aar -d ort |
| 61 | + ls -lR ort |
| 62 | +
|
| 63 | + - name: Install Android SDK and Emulator |
| 64 | + run: | |
| 65 | + sudo apt-get update |
| 66 | + sudo apt-get install -y unzip wget |
| 67 | + wget https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip -P $HOME |
| 68 | + unzip $HOME/commandlinetools-linux-7583922_latest.zip -d $HOME/Android |
| 69 | + yes | $HOME/Android/cmdline-tools/bin/sdkmanager --sdk_root=$HOME/Android --install "platform-tools" "emulator" "system-images;android-27;default;x86_64" |
| 70 | +
|
| 71 | + - name: Set Android SDK path |
| 72 | + run: | |
| 73 | + echo "ANDROID_HOME=$HOME/Android" >> $GITHUB_ENV |
| 74 | + echo "ANDROID_SDK_ROOT=$HOME/Android" >> $GITHUB_ENV |
| 75 | + echo "PATH=$PATH:$HOME/Android/platform-tools:$HOME/Android/emulator" >> $GITHUB_ENV |
| 76 | +
|
| 77 | + - name: Verify Android Emulator installation |
| 78 | + run: | |
| 79 | + ls -l $HOME/Android/emulator |
| 80 | +
|
| 81 | + - name: Start Android Emulator |
| 82 | + run: | |
| 83 | + $ANDROID_HOME/emulator/emulator -avd test_avd -no-window -no-audio -gpu off & |
| 84 | + adb wait-for-device |
| 85 | +
|
| 86 | + - name: Create Android build |
| 87 | + run: | |
| 88 | + ./build.sh --android --android_api=27 --android_ndk_path=${ANDROID_NDK_LATEST_HOME} --config=RelWithDebInfo --android_abi=${{ env.ANDROID_ABI }} --parallel --build_java --update |
| 89 | +
|
| 90 | + - name: Run Android build |
| 91 | + run: | |
| 92 | + ./build.sh --android --android_api=27 --android_ndk_path=${ANDROID_NDK_LATEST_HOME} --config=RelWithDebInfo --android_abi=${{ env.ANDROID_ABI }} --parallel --build_java --build |
| 93 | +
|
| 94 | + - name: Run Android tests |
| 95 | + run: | |
| 96 | + ./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