forked from microsoft/onnxruntime
-
Notifications
You must be signed in to change notification settings - Fork 1
239 lines (209 loc) · 8.14 KB
/
Copy pathandroid.yml
File metadata and controls
239 lines (209 loc) · 8.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
name: Android CI
# This workflow is used to build and test on Android Emulator on Linux
on:
push:
branches:
- main
- rel-*
pull_request:
branches:
- main
- rel-*
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.sha }}
cancel-in-progress: true
permissions:
contents: read
packages: write
attestations: write
id-token: write
jobs:
AndroidBinarySizeCheckJob_MinimalBaseline:
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
submodules: false
- name: Setup Android NDK
uses: ./.github/actions/setup-android-ndk
with:
ndk-version: 28.0.13004108
- name: Get Docker Image using Action
uses: microsoft/onnxruntime-github-actions/build-docker-image@v0.0.9
id: build_docker_image_step
with:
dockerfile: ${{ github.workspace }}/tools/ci_build/github/linux/docker/inference/x86_64/default/cpu/Dockerfile
image-name: ghcr.io/microsoft/onnxruntime/onnxruntimecpubuildcix64
push: true
azure-container-registry-name: onnxruntimebuildcache
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set variables from config file
id: set_vars
run: |
import json, os
config_file_path = "tools/ci_build/github/linux/ort_minimal/build_check_binsize_config/android_minimal_baseline.config"
with open(config_file_path, mode="r") as config_file:
config = json.load(config_file)
def set_var(name, value):
print(f"Setting variable: {name} = '{value}'")
# Use GITHUB_ENV for setting environment variables
with open(os.environ['GITHUB_ENV'], 'a') as f:
f.write(f"{name}={value}\n")
set_var("BuildConfigType", config["type"])
set_var("BuildConfigOs", config["os"])
shell: python
working-directory: ${{ github.workspace }}
- name: 1a. Build onnxruntime
run: |
set -e -x
BINARY_SIZE_THRESHOLD_ARGS=""
echo "Binary size threshold in bytes: 1436672"
BINARY_SIZE_THRESHOLD_ARGS="--threshold_size_in_bytes 1436672"
# Ensure ANDROID_NDK_HOME is available and get its real path
if [ -z "$ANDROID_NDK_HOME" ]; then
echo "ANDROID_NDK_HOME is not set."
exit 1
fi
NDK_HOME_REALPATH=$(realpath $ANDROID_NDK_HOME)
# Ensure ANDROID_HOME is available
if [ -z "$ANDROID_HOME" ]; then
echo "ANDROID_HOME is not set. Using default /usr/local/lib/android/sdk"
export ANDROID_HOME=/usr/local/lib/android/sdk
fi
docker run -e SYSTEM_COLLECTIONURI --rm \
--volume ${{ github.workspace }}:/onnxruntime_src \
--volume ${{ runner.temp }}:/build \
--volume $ANDROID_HOME:/android_home \
--volume $NDK_HOME_REALPATH:/ndk_home \
-w /onnxruntime_src \
-e ALLOW_RELEASED_ONNX_OPSET_ONLY=1 \
-e NIGHTLY_BUILD=1 \
-e BUILD_BUILDNUMBER=${{ github.run_number }} \
-e BUILD_SOURCEVERSION=${{ github.sha }} \
-e BUILD_ID=${{ github.run_id }} \
-e BUILD_REASON=${{ github.event_name }} \
-e BUILD_BRANCH=${{ github.ref }} \
-e RUNNER_TEMP=/build \
${{ steps.build_docker_image_step.outputs.full-image-name }} \
bash -c "python3 -m pip install -r /onnxruntime_src/tools/ci_build/requirements/pybind/requirements.txt && \
python3 tools/ci_build/github/linux/ort_minimal/build_ort_and_check_binary_size.py \
--build_dir /build/1a \
${BINARY_SIZE_THRESHOLD_ARGS} \
tools/ci_build/github/linux/ort_minimal/build_check_binsize_config/android_minimal_baseline.config"
shell: bash
android_nnapi_ep:
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
steps:
- uses: actions/checkout@v5
- name: Use jdk 17
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'
architecture: x64
- uses: microsoft/onnxruntime-github-actions/setup-build-tools@v0.0.9
with:
vcpkg-version: '2025.06.13'
vcpkg-hash: '735923258c5187966698f98ce0f1393b8adc6f84d44fd8829dda7db52828639331764ecf41f50c8e881e497b569f463dbd02dcb027ee9d9ede0711102de256cc'
cmake-version: '3.31.6'
cmake-hash: '42395e20b10a8e9ef3e33014f9a4eed08d46ab952e02d2c1bbc8f6133eca0d7719fb75680f9bbff6552f20fcd1b73d86860f7f39388d631f98fb6f622b37cf04'
add-cmake-to-path: 'true'
disable-terrapin: 'true'
- name: Setup Android NDK
uses: ./.github/actions/setup-android-ndk
with:
ndk-version: 28.0.13004108
- name: NNAPI EP, Build, Test on Android Emulator
run: >-
python3 tools/ci_build/build.py
--enable_lto
--android
--build_dir build_nnapi
--android_sdk_path "$ANDROID_HOME"
--android_ndk_path "$ANDROID_NDK_HOME"
--android_abi=x86_64
--android_api=29
--skip_submodule_sync
--parallel --use_vcpkg --use_vcpkg_ms_internal_asset_cache
--use_nnapi
--build_shared_lib
--cmake_generator=Ninja
--build_java
--update --build --test
shell: bash
- name: Build Minimal ORT with NNAPI and run tests
run:
tools/ci_build/github/linux/ort_minimal/nnapi_minimal_build_minimal_ort_and_run_tests.sh
"$(pwd)"
shell: bash
- name: Install psutil for emulator shutdown by run_android_emulator.py
if: always()
run: python3 -m pip install psutil
shell: bash
- name: Stop Android Emulator
if: always()
run: |
env | grep ANDROID
if test -f ${{ github.workspace }}/emulator.pid; then
echo "Emulator PID:"`cat ${{ github.workspace }}/emulator.pid`
python3 tools/python/run_android_emulator.py \
--android-sdk-root "${ANDROID_SDK_ROOT}" \
--stop \
--emulator-pid-file ${{ github.workspace }}/emulator.pid
rm ${{ github.workspace }}/emulator.pid
else
echo "Emulator PID file was expected to exist but does not."
fi
shell: bash
android_cpu_ep:
name: Android CI Pipeline
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
steps:
- uses: actions/checkout@v5
- name: Use jdk 17
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'
architecture: x64
- name: Setup Android NDK
uses: ./.github/actions/setup-android-ndk
with:
ndk-version: 28.0.13004108
- name: CPU EP, Build and Test
run: >-
python3 tools/ci_build/build.py
--enable_lto
--android
--build_dir build
--android_sdk_path $ANDROID_HOME
--android_ndk_path $ANDROID_NDK_HOME
--android_abi=x86_64
--android_api=30
--skip_submodule_sync
--parallel --use_vcpkg --use_vcpkg_ms_internal_asset_cache
--cmake_generator=Ninja
--build_java
--update --build --test
shell: bash
- name: Install psutil for emulator shutdown by run_android_emulator.py
if: always()
run: python3 -m pip install psutil
shell: bash
- name: Stop Android Emulator
if: always()
run: |
if test -f ${{ github.workspace }}/emulator.pid; then
echo "Emulator PID:"`cat ${{ github.workspace }}/emulator.pid`
python3 tools/python/run_android_emulator.py \
--android-sdk-root "${ANDROID_SDK_ROOT}" \
--stop \
--emulator-pid-file ${{ github.workspace }}/emulator.pid
rm ${{ github.workspace }}/emulator.pid
else
echo "Emulator PID file was expected to exist but does not."
fi
shell: bash