|
| 1 | +name: Android CI |
| 2 | +# This workflow is used to build and test on Android Emulator on Linux |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + - rel-* |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + - rel-* |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'workflow_dispatch' }} |
| 17 | + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} |
| 18 | + |
| 19 | +jobs: |
| 20 | + android_nnapi_ep: |
| 21 | + runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"] |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Use jdk 17 |
| 26 | + uses: actions/setup-java@v4 |
| 27 | + with: |
| 28 | + distribution: 'temurin' |
| 29 | + java-version: '17' |
| 30 | + architecture: x64 |
| 31 | + |
| 32 | + - name: Setup Android NDK |
| 33 | + uses: ./.github/actions/setup-android-ndk |
| 34 | + with: |
| 35 | + ndk-version: 27.2.12479018 |
| 36 | + |
| 37 | + - name: Export GitHub Actions cache environment variables |
| 38 | + uses: actions/github-script@v7 |
| 39 | + with: |
| 40 | + script: | |
| 41 | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); |
| 42 | + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); |
| 43 | +
|
| 44 | + - name: NNAPI EP, Build, Test on Android Emulator |
| 45 | + run: >- |
| 46 | + python3 tools/ci_build/build.py |
| 47 | + --enable_lto |
| 48 | + --android |
| 49 | + --build_dir build_nnapi |
| 50 | + --android_sdk_path "$ANDROID_HOME" |
| 51 | + --android_ndk_path "$ANDROID_NDK_HOME" |
| 52 | + --android_abi=x86_64 |
| 53 | + --android_api=29 |
| 54 | + --skip_submodule_sync |
| 55 | + --parallel --use_vcpkg --use_vcpkg_ms_internal_asset_cache |
| 56 | + --use_nnapi |
| 57 | + --build_shared_lib |
| 58 | + --cmake_generator=Ninja |
| 59 | + --build_java |
| 60 | + shell: bash |
| 61 | + |
| 62 | + |
| 63 | + - name: Build Minimal ORT with NNAPI and run tests |
| 64 | + run: tools/ci_build/github/linux/ort_minimal/nnapi_minimal_build_minimal_ort_and_run_tests.sh "$(pwd)" |
| 65 | + shell: bash |
| 66 | + |
| 67 | + - name: Install psutil for emulator shutdown by run_android_emulator.py |
| 68 | + if: always() |
| 69 | + run: python3 -m pip install psutil |
| 70 | + shell: bash |
| 71 | + |
| 72 | + - name: Stop Android Emulator |
| 73 | + if: always() |
| 74 | + run: | |
| 75 | + env | grep ANDROID |
| 76 | + if test -f ${{ github.workspace }}/emulator.pid; then |
| 77 | + echo "Emulator PID:"`cat ${{ github.workspace }}/emulator.pid` |
| 78 | + python3 tools/python/run_android_emulator.py \ |
| 79 | + --android-sdk-root "${ANDROID_SDK_ROOT}" \ |
| 80 | + --stop \ |
| 81 | + --emulator-pid-file ${{ github.workspace }}/emulator.pid |
| 82 | + rm ${{ github.workspace }}/emulator.pid |
| 83 | + else |
| 84 | + echo "Emulator PID file was expected to exist but does not." |
| 85 | + fi |
| 86 | + shell: bash |
| 87 | + |
| 88 | + android_cpu_ep: |
| 89 | + name: Android CI Pipeline |
| 90 | + runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"] |
| 91 | + steps: |
| 92 | + - uses: actions/checkout@v4 |
| 93 | + |
| 94 | + - name: Use jdk 17 |
| 95 | + uses: actions/setup-java@v4 |
| 96 | + with: |
| 97 | + distribution: 'temurin' |
| 98 | + java-version: '17' |
| 99 | + architecture: x64 |
| 100 | + |
| 101 | + - name: Setup Android NDK |
| 102 | + uses: ./.github/actions/setup-android-ndk |
| 103 | + with: |
| 104 | + ndk-version: 27.2.12479018 |
| 105 | + |
| 106 | + - name: Export GitHub Actions cache environment variables |
| 107 | + uses: actions/github-script@v7 |
| 108 | + with: |
| 109 | + script: | |
| 110 | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); |
| 111 | + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); |
| 112 | +
|
| 113 | + - name: CPU EP, Build and Test |
| 114 | + run: >- |
| 115 | + python3 tools/ci_build/build.py |
| 116 | + --enable_lto |
| 117 | + --android |
| 118 | + --build_dir build |
| 119 | + --android_sdk_path $ANDROID_HOME |
| 120 | + --android_ndk_path $ANDROID_NDK_HOME |
| 121 | + --android_abi=x86_64 |
| 122 | + --android_api=30 |
| 123 | + --skip_submodule_sync |
| 124 | + --parallel --use_vcpkg --use_vcpkg_ms_internal_asset_cache |
| 125 | + --cmake_generator=Ninja |
| 126 | + --build_java |
| 127 | + shell: bash |
| 128 | + |
| 129 | + - name: Install psutil for emulator shutdown by run_android_emulator.py |
| 130 | + if: always() |
| 131 | + run: python3 -m pip install psutil |
| 132 | + shell: bash |
| 133 | + |
| 134 | + - name: Stop Android Emulator |
| 135 | + if: always() |
| 136 | + run: | |
| 137 | + if test -f ${{ github.workspace }}/emulator.pid; then |
| 138 | + echo "Emulator PID:"`cat ${{ github.workspace }}/emulator.pid` |
| 139 | + python3 tools/python/run_android_emulator.py \ |
| 140 | + --android-sdk-root "${ANDROID_SDK_ROOT}" \ |
| 141 | + --stop \ |
| 142 | + --emulator-pid-file ${{ github.workspace }}/emulator.pid |
| 143 | + rm ${{ github.workspace }}/emulator.pid |
| 144 | + else |
| 145 | + echo "Emulator PID file was expected to exist but does not." |
| 146 | + fi |
| 147 | + shell: bash |
0 commit comments