Skip to content

Commit 9564ed1

Browse files
authored
Migrate "Linux CPU Minimal Build E2E CI Pipeline" to Github Actions (#24534)
1. Migrate "Linux CPU Minimal Build E2E CI Pipeline" and "onnxruntime-binary-size-checks-ci-pipeline" to Github Action 2. Add the support for building ONNX Runtime minimal build with vcpkg. 3. Auto format the yaml files with ruamel.yaml 4. Update vcpkg to the latest release.
1 parent a9a3ad2 commit 9564ed1

File tree

19 files changed

+1709
-1499
lines changed

19 files changed

+1709
-1499
lines changed

.github/actions/locate-vcvarsall-and-setup-env/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ runs:
1414
steps:
1515

1616
- name: Setup VCPKG
17-
uses: microsoft/onnxruntime-github-actions/[email protected].5
17+
uses: microsoft/onnxruntime-github-actions/[email protected].6
1818
with:
19-
vcpkg-version: '2025.03.19'
20-
vcpkg-hash: '17e96169cd3f266c4716fcdc1bb728e6a64f103941ece463a2834d50694eba4fb48f30135503fd466402afa139abc847ef630733c442595d1c34979f261b0114'
19+
vcpkg-version: '2025.04.09'
20+
vcpkg-hash: '31a28b58854b7c7b503db99bb2eb41582d9f835b401adf3bd0f680ef329faa4ab4278b987b586a2a6141e2c98f007833266a4e3b60c3164226a3905466a082ce'
2121
cmake-version: '3.31.6'
2222
cmake-hash: '0f1584e8666cf4a65ec514bd02afe281caabf1d45d2c963f3151c41484f457386aa03273ab25776a670be02725354ce0b46f3a5121857416da37366342a833a0'
2323
add-cmake-to-path: 'true'

.github/workflows/android.yml

Lines changed: 106 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,108 @@ concurrency:
1616
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.sha }}
1717
cancel-in-progress: true
1818

19+
permissions:
20+
contents: read
21+
packages: write
22+
attestations: write
23+
id-token: write
24+
1925
jobs:
26+
AndroidBinarySizeCheckJob_MinimalBaseline:
27+
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
with:
32+
submodules: false
33+
34+
- name: Setup Android NDK
35+
uses: ./.github/actions/setup-android-ndk
36+
with:
37+
ndk-version: 28.0.13004108
38+
39+
- name: Get Docker Image using Action
40+
uses: microsoft/onnxruntime-github-actions/[email protected]
41+
id: build_docker_image_step
42+
with:
43+
dockerfile: ${{ github.workspace }}/tools/ci_build/github/linux/docker/inference/x86_64/default/cpu/Dockerfile
44+
image-name: ghcr.io/microsoft/onnxruntime/onnxruntimecpubuildcix64
45+
push: true
46+
azure-container-registry-name: onnxruntimebuildcache
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Set variables from config file
51+
id: set_vars
52+
run: |
53+
import json, os
54+
55+
config_file_path = "tools/ci_build/github/linux/ort_minimal/build_check_binsize_config/android_minimal_baseline.config"
56+
with open(config_file_path, mode="r") as config_file:
57+
config = json.load(config_file)
58+
59+
def set_var(name, value):
60+
print(f"Setting variable: {name} = '{value}'")
61+
# Use GITHUB_ENV for setting environment variables
62+
with open(os.environ['GITHUB_ENV'], 'a') as f:
63+
f.write(f"{name}={value}\n")
64+
65+
set_var("BuildConfigType", config["type"])
66+
set_var("BuildConfigOs", config["os"])
67+
shell: python
68+
working-directory: ${{ github.workspace }}
69+
70+
- name: Export GitHub Actions cache environment variables
71+
uses: actions/github-script@v7
72+
with:
73+
script: |
74+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
75+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
76+
77+
- name: 1a. Build onnxruntime
78+
run: |
79+
set -e -x
80+
BINARY_SIZE_THRESHOLD_ARGS=""
81+
echo "Binary size threshold in bytes: 1306224"
82+
BINARY_SIZE_THRESHOLD_ARGS="--threshold_size_in_bytes 1306224"
83+
84+
# Ensure ANDROID_NDK_HOME is available and get its real path
85+
if [ -z "$ANDROID_NDK_HOME" ]; then
86+
echo "ANDROID_NDK_HOME is not set."
87+
exit 1
88+
fi
89+
NDK_HOME_REALPATH=$(realpath $ANDROID_NDK_HOME)
90+
91+
# Ensure ANDROID_HOME is available
92+
if [ -z "$ANDROID_HOME" ]; then
93+
echo "ANDROID_HOME is not set. Using default /usr/local/lib/android/sdk"
94+
export ANDROID_HOME=/usr/local/lib/android/sdk
95+
fi
96+
97+
docker run -e SYSTEM_COLLECTIONURI --rm \
98+
--volume ${{ github.workspace }}:/onnxruntime_src \
99+
--volume ${{ runner.temp }}:/build \
100+
--volume $ANDROID_HOME:/android_home \
101+
--volume $NDK_HOME_REALPATH:/ndk_home \
102+
-w /onnxruntime_src \
103+
-e ALLOW_RELEASED_ONNX_OPSET_ONLY=1 \
104+
-e NIGHTLY_BUILD=1 \
105+
-e BUILD_BUILDNUMBER=${{ github.run_number }} \
106+
-e BUILD_SOURCEVERSION=${{ github.sha }} \
107+
-e BUILD_ID=${{ github.run_id }} \
108+
-e BUILD_REASON=${{ github.event_name }} \
109+
-e BUILD_BRANCH=${{ github.ref }} \
110+
-e ACTIONS_CACHE_URL \
111+
-e ACTIONS_RUNTIME_TOKEN \
112+
-e RUNNER_TEMP=/build \
113+
${{ steps.build_docker_image_step.outputs.full-image-name }} \
114+
bash -c "python3 -m pip install -r /onnxruntime_src/tools/ci_build/requirements/pybind/requirements.txt && \
115+
python3 tools/ci_build/github/linux/ort_minimal/build_ort_and_check_binary_size.py \
116+
--build_dir /build/1a \
117+
${BINARY_SIZE_THRESHOLD_ARGS} \
118+
tools/ci_build/github/linux/ort_minimal/build_check_binsize_config/android_minimal_baseline.config"
119+
shell: bash
120+
20121
android_nnapi_ep:
21122
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
22123
steps:
@@ -32,8 +133,8 @@ jobs:
32133

33134
- uses: microsoft/onnxruntime-github-actions/[email protected]
34135
with:
35-
vcpkg-version: '2025.03.19'
36-
vcpkg-hash: '17e96169cd3f266c4716fcdc1bb728e6a64f103941ece463a2834d50694eba4fb48f30135503fd466402afa139abc847ef630733c442595d1c34979f261b0114'
136+
vcpkg-version: '2025.04.09'
137+
vcpkg-hash: '31a28b58854b7c7b503db99bb2eb41582d9f835b401adf3bd0f680ef329faa4ab4278b987b586a2a6141e2c98f007833266a4e3b60c3164226a3905466a082ce'
37138
cmake-version: '3.31.6'
38139
cmake-hash: '42395e20b10a8e9ef3e33014f9a4eed08d46ab952e02d2c1bbc8f6133eca0d7719fb75680f9bbff6552f20fcd1b73d86860f7f39388d631f98fb6f622b37cf04'
39140
add-cmake-to-path: 'true'
@@ -71,7 +172,9 @@ jobs:
71172

72173

73174
- name: Build Minimal ORT with NNAPI and run tests
74-
run: tools/ci_build/github/linux/ort_minimal/nnapi_minimal_build_minimal_ort_and_run_tests.sh "$(pwd)"
175+
run:
176+
tools/ci_build/github/linux/ort_minimal/nnapi_minimal_build_minimal_ort_and_run_tests.sh
177+
"$(pwd)"
75178
shell: bash
76179

77180
- name: Install psutil for emulator shutdown by run_android_emulator.py

0 commit comments

Comments
 (0)