forked from microsoft/onnxruntime
-
Notifications
You must be signed in to change notification settings - Fork 0
317 lines (280 loc) · 11.2 KB
/
android.yml
File metadata and controls
317 lines (280 loc) · 11.2 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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
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",
"JobId=AndroidBinarySizeCheckJob_MinimalBaseline-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
]
env:
CCACHE_DIR: ~/.cache/ccache # explicitly set to prevent any fallback to `~/.ccache`
steps:
- name: Checkout repository
uses: actions/checkout@v6
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@8bad63a3c05d448311dfa8e5f531171c97471aa1 # v0.0.12
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 }}
# FUTURE WORK: ccache, vcpkg cache
- 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",
"JobId=android_nnapi_ep-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
]
env:
CCACHE_DIR: ~/.cache/ccache # explicitly set to prevent any fallback to `~/.ccache`
steps:
- uses: actions/checkout@v6
- 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@8bad63a3c05d448311dfa8e5f531171c97471aa1 # v0.0.12
with:
ccache-version: 4.13.1
ccache-hash: 626407a9b81dd86f8ec9867bff396b32dd1f00344f5b323526579a64f6d4104927f83e8d7a05ad9806fd78f4491e0adb4cff73388000a62050cb1b00766214ee
vcpkg-version: '2025.08.27'
vcpkg-hash: '9a4b32849792e13bee1d24726f073b3881acae4165206ddf1a6378e44a4ddd05b3ee93f55ff46d8e8873b3cbcd06606212989e248f0bd615a5bf365070074079'
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: Setup CCache
uses: actions/cache@v5
with:
# Fully qualify by workflow. `actions/cache` does not isolate by workflow, unlike ADO cache actions.
key: ccache | android.yml | android_nnapi_ep
path: ~/.cache/ccache
- name: Setup VCPKG Cache
uses: actions/cache@v5
with:
key: vcpkg-cache | android.yml | android_nnapi_ep
path: ~/.cache/vcpkg
- name: CCache reset stats
run: ccache --zero-stats
shell: bash
- 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_cache
--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: CCache stats
run: ccache --show-stats -vv
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",
"JobId=android_cpu_ep-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
]
env:
CCACHE_DIR: ~/.cache/ccache # explicitly set to prevent any fallback to `~/.ccache`
steps:
- uses: actions/checkout@v6
- 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@8bad63a3c05d448311dfa8e5f531171c97471aa1 # v0.0.12
with:
ccache-version: 4.13.1
ccache-hash: 626407a9b81dd86f8ec9867bff396b32dd1f00344f5b323526579a64f6d4104927f83e8d7a05ad9806fd78f4491e0adb4cff73388000a62050cb1b00766214ee
vcpkg-version: '2025.08.27'
vcpkg-hash: '9a4b32849792e13bee1d24726f073b3881acae4165206ddf1a6378e44a4ddd05b3ee93f55ff46d8e8873b3cbcd06606212989e248f0bd615a5bf365070074079'
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: Setup CCache
uses: actions/cache@v5
with:
# Fully qualify by workflow. `actions/cache` does not isolate by workflow, unlike ADO cache actions.
key: ccache | android.yml | android_cpu_ep
path: ~/.cache/ccache
- name: Setup VCPKG Cache
uses: actions/cache@v5
with:
key: vcpkg-cache | android.yml | android_cpu_ep
path: ~/.cache/vcpkg
- name: CCache reset stats
run: ccache --zero-stats
shell: bash
- 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_cache
--use_vcpkg
--use_vcpkg_ms_internal_asset_cache
--cmake_generator=Ninja
--build_java
--update --build --test
shell: bash
- name: CCache stats
run: ccache --show-stats -vv
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