Skip to content

Commit 323c87a

Browse files
authored
Major Refactoring of Azure DevOps Pipelines (#26008)
This pull request introduces a significant refactoring of the Azure Pipelines CI/CD infrastructure. The primary goals of these changes are to: 1. Solve the problem that vcpkg/cmake version can get changed when the CI build machine image changes, which can make pipeline suddenly broken and interrupt our release process. 2. Reduce the `Zip-Nuget-Java-Nodejs Packaging Pipeline`'s running time by changing how macOS universal2 binaries are built. 3. Add the support for RC releases for Java packages. #### Key Changes: **1. Standardized Build Tool Setup (`setup-build-tools.yml`)** A new reusable template, `setup-build-tools.yml`, has been created to centralize the setup of essential build tools. * **Pinned Dependencies:** This new template allows us to pin specific versions of `cmake` and `vcpkg`, which was not previously possible. This ensures a more stable and predictable build environment across all pipelines. * **Reduced Redundancy:** By consolidating the setup logic into a single template, we have significantly reduced code duplication across numerous pipeline files, making them cleaner and easier to maintain. Currently this file is only used in macOS and Windows pipelines since most Linux pipelines use docker to manage their environment. **2. Reworked macOS Universal Binary Build Process** The methodology for building macOS `universal2` binaries has been fundamentally changed to improve reliability and flexibility. * **Python Packaging:** The Python packaging pipeline will no longer produce `universal2` wheels. Instead, it will generate separate wheels for `x86_64` and `arm64` architectures. * **NuGet C-API Packaging:** The NuGet C-API pipeline has been updated to first build the `x86_64` and `arm64` binaries independently. These single-architecture binaries are then combined to create the final universal package, rather than building a `universal2` package in a single pass. The change is made mainly because: - Building for both ARCHs in a single pass is too slow, which may take about 5 hours in the ADO machine pool. - A lot of MLAS features are disabled when ORT is built in such a way. **3. Java Packaging and Testing Overhaul** The Download_Java_Tools stage in "Zip-Nuget-Java-Nodejs Packaging Pipeline" is deleted because it is no longer used. Previously it was added to reduce the times of downloading the same java packages again and again , which was to reduce download errors. Now we have setup a private ADO feed for this. Besides, there are some major changes to the pipeline that: 1. MD5 and SHA1 checksum files are provided along with the java package files instead of SHA256. This is because Sonatype's official docs says MD5/SHA1 checkcums are required while the others are optional. See: https://central.sonatype.org/publish/requirements/#supply-javadoc-and-sources . Now the publishing would fail if we don't have the MD5/SHA1 checksum files. 2. The format of the checksum files is changed. Previously we used Linux's sha256sum command to generate such files, so each checksum file contains a hash value and a filename in the file content. However, it was not the expected format. Sonatype expects that the file only contains a hash value. This PR fixes the issue. 3. A few powershell scripts were rewritten in python to improve error check and robustness 4. Added the support for generating RC packages. Previously we had to manually modify the version numbers and manually do GPG sign. 5. Two new files `jar-packaging.yml` and `setup-maven.yml` were added. We will use maven to fetch dependent packages(instead of directly HTTP fetching) to improve supply chain security, because maven allows us using a private feed to do so. **4. Dockerfile Enhancements** The Dockerfiles used in the CI have been updated to use a `BASEIMAGE` argument. This makes them more flexible, allowing the base image to be specified at build time, which simplifies maintenance and updates. It will allow us to using different base image repos in different CI environments. In the future we will change the Github Actions to only fetch base images from public docker repos. Meanwhile, ADO packaging pipelines will continue to use private repos. **5. Improved Release Management** The run_packaging_pipelines.py script has been updated to provide more robust and explicit control over the package versioning for different build scenarios. This clarifies the process for generating nightly, release candidate (RC), and final release packages. The script now handles three distinct cases for package versioning: * Nightly Packages: For regular CI builds (e.g., on the main branch), the script triggers the packaging pipelines in "nightly" mode. This sets the IsReleaseBuild parameter to false and results in packages with a development version suffix (e.g., 1.2.3-dev-20250909-abcdef). * Release Candidate (RC) Builds: To create a pre-release or RC build, the script is run with the --build-mode release flag, along with the --pre-release-suffix-string (e.g., rc) and --pre-release-suffix-number (e.g., 1) arguments. This sets the IsReleaseBuild parameter to true and passes the suffix information to the pipelines, resulting in a semantically versioned pre-release package (e.g., 1.2.3-rc.1). * Final Release Builds: For a final release, the script is run with --build-mode release without any pre-release suffix arguments. This sets IsReleaseBuild to true, and the resulting package will have a clean, final version number (e.g., 1.2.3) based on the VERSION_NUMBER file. Please note: - Java packages still only support the second and third mode. - Python packages only support the first and the last mode.
1 parent f9209ff commit 323c87a

File tree

65 files changed

+2304
-1143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2304
-1143
lines changed

java/build.gradle

Lines changed: 31 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ plugins {
44
id 'signing'
55
id 'jacoco'
66
id "com.diffplug.spotless" version "6.25.0"
7-
id "net.linguica.maven-settings" version "0.5"
87
}
98

109
allprojects {
@@ -14,17 +13,9 @@ allprojects {
1413
}
1514

1615
project.group = "com.microsoft.onnxruntime"
17-
version = rootProject.file('../VERSION_NUMBER').text.trim()
18-
1916
// cmake runs will inform us of the build directory of the current run
2017
def cmakeBuildDir = System.properties['cmakeBuildDir']
2118
def useCUDA = System.properties['USE_CUDA']
22-
def useROCM = System.properties['USE_ROCM']
23-
24-
def adoArtifact = project.findProperty('adoArtifact')
25-
def adoAccessToken = project.findProperty('adoAccessToken')
26-
// Only publish to ADO feed if all two properties are set
27-
def publishToAdo = adoArtifact != null && adoAccessToken != null
2819

2920
boolean enableTrainingApis = (System.properties['ENABLE_TRAINING_APIS'] ?: "0") == "1"
3021
def cmakeJavaDir = "${cmakeBuildDir}/java"
@@ -33,21 +24,14 @@ def cmakeNativeJniDir = "${cmakeJavaDir}/native-jni"
3324
def cmakeNativeTestDir = "${cmakeJavaDir}/native-test"
3425
def cmakeBuildOutputDir = "${cmakeJavaDir}/build"
3526

36-
def mavenUser = System.properties['mavenUser']
37-
def mavenPwd = System.properties['mavenPwd']
38-
3927
def tmpArtifactId = enableTrainingApis ? project.name + "-training" : project.name
40-
def mavenArtifactId = (useCUDA == null && useROCM == null) ? tmpArtifactId : tmpArtifactId + "_gpu"
28+
def mavenArtifactId = (useCUDA == null) ? tmpArtifactId : tmpArtifactId + "_gpu"
4129

4230
def defaultDescription = 'ONNX Runtime is a performance-focused inference engine for ONNX (Open Neural Network Exchange) models.'
4331
def trainingDescription = 'ONNX Runtime Training is a training and inference package for ONNX ' +
4432
'(Open Neural Network Exchange) models. This package is targeted for Learning on The Edge aka On-Device Training ' +
4533
'See https://github.com/microsoft/onnxruntime-training-examples/tree/master/on_device_training for more details.'
4634

47-
// We need to have a custom settings.xml so codeql can bypass the need for settings.security.xml
48-
mavenSettings {
49-
userSettingsFileName = "${projectDir}/settings.xml"
50-
}
5135

5236
java {
5337
sourceCompatibility = JavaVersion.VERSION_17
@@ -202,16 +186,27 @@ test {
202186
systemProperties System.getProperties().subMap([
203187
'ENABLE_TRAINING_APIS',
204188
'JAVA_FULL_TEST',
189+
'USE_ACL',
190+
'USE_ARMNN',
191+
'USE_AZURE',
192+
'USE_CANN',
205193
'USE_COREML',
206194
'USE_CUDA',
207195
'USE_DML',
208196
'USE_DNNL',
197+
'USE_MIGRAPHX',
198+
'USE_NNAPI',
199+
'USE_NV',
209200
'USE_OPENVINO',
210-
'USE_ROCM',
211-
'USE_TENSORRT',
212201
'USE_QNN',
213-
'USE_XNNPACK',
202+
'USE_RKNPU',
203+
'USE_SNPE',
204+
'USE_TENSORRT',
205+
'USE_VITISAI',
206+
'USE_VSINPU',
214207
'USE_WEBGPU',
208+
'USE_WEBNN',
209+
'USE_XNNPACK',
215210
])
216211
testLogging {
217212
events "passed", "skipped", "failed"
@@ -233,13 +228,9 @@ publishing {
233228
publications {
234229
maven(MavenPublication) {
235230
groupId = project.group
236-
if(publishToAdo) {
237-
artifactId = 'onnxruntime_gpu'
238-
artifact (adoArtifact)
239-
} else {
240-
artifactId = mavenArtifactId
241-
from components.java
242-
}
231+
artifactId = mavenArtifactId
232+
from components.java
233+
243234
version = project.version
244235
pom {
245236
name = enableTrainingApis ? 'onnxruntime-training' : 'onnx-runtime'
@@ -270,42 +261,24 @@ publishing {
270261
}
271262
}
272263
}
273-
repositories {
274-
if (publishToAdo) {
275-
maven {
276-
url "https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/${System.getenv('ADOFeedName')}/maven/v1"
277-
name System.getenv('ADOFeedName')
278-
authentication {
279-
basic(BasicAuthentication)
280-
}
281-
credentials {
282-
username 'aiinfra'
283-
password "${project.findProperty('adoAccessToken')}"
284-
}
285-
}
286-
} else {
287-
maven {
288-
url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
289-
credentials {
290-
username mavenUser
291-
password mavenPwd
292-
}
293-
}
294-
}
295-
}
296264
}
297265
// Generates a task signMavenPublication that will
298266
// build all artifacts.
299267
signing {
300268
// Queries env vars:
301269
// ORG_GRADLE_PROJECT_signingKey
302270
// ORG_GRADLE_PROJECT_signingPassword but can be changed to properties
303-
def signingKey = findProperty("signingKey")
304-
def signingPassword = findProperty("signingPassword")
305-
// Skip signing if no key is provided
306-
if (signingKey != null && signingPassword != null) {
307-
useInMemoryPgpKeys(signingKey, signingPassword)
308-
sign publishing.publications.maven
309-
sign publishing.publications.mavenAdo
310-
}
271+
def signingKey = findProperty("signingKey")
272+
def signingPassword = findProperty("signingPassword")
273+
// Skip signing if no key is provided
274+
if (signingKey != null && signingPassword != null) {
275+
useInMemoryPgpKeys(signingKey, signingPassword)
276+
sign publishing.publications.maven
277+
}
278+
}
279+
280+
tasks.named('generatePomFileForMavenPublication') {
281+
doFirst {
282+
println "AGENT_LOG: Generating POM for version: ${project.version}"
283+
}
311284
}

java/src/test/java/ai/onnxruntime/InferenceTest.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -693,12 +693,6 @@ public void testCUDA() throws OrtException {
693693
runProvider(OrtProvider.CUDA);
694694
}
695695

696-
@Test
697-
@EnabledIfSystemProperty(named = "USE_ROCM", matches = "1")
698-
public void testROCM() throws OrtException {
699-
runProvider(OrtProvider.ROCM);
700-
}
701-
702696
@Test
703697
@EnabledIfSystemProperty(named = "USE_TENSORRT", matches = "1")
704698
public void testTensorRT() throws OrtException {
@@ -725,6 +719,18 @@ public void testDNNL() throws OrtException {
725719
runProvider(OrtProvider.DNNL);
726720
}
727721

722+
@Test
723+
@EnabledIfSystemProperty(named = "USE_MIGRAPHX", matches = "1")
724+
public void testMIGRAPHX() throws OrtException {
725+
runProvider(OrtProvider.MI_GRAPH_X);
726+
}
727+
728+
@Test
729+
@EnabledIfSystemProperty(named = "USE_NNAPI", matches = "1")
730+
public void testNNAPI() throws OrtException {
731+
runProvider(OrtProvider.NNAPI);
732+
}
733+
728734
@Test
729735
@EnabledIfSystemProperty(named = "USE_XNNPACK", matches = "1")
730736
public void testXNNPACK() throws OrtException {

tools/ci_build/github/azure-pipelines/build-perf-test-binaries-pipeline.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ parameters:
77
default: true
88

99
stages:
10-
1110
# build binaries for Android
1211
- ${{ if parameters.BuildAndroidBinaries }}:
1312
- stage: BuildAndroidBinaries

tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,29 +122,23 @@ extends:
122122
PreReleaseVersionSuffixString: ${{ parameters.PreReleaseVersionSuffixString }}
123123
PreReleaseVersionSuffixNumber: ${{ parameters.PreReleaseVersionSuffixNumber }}
124124

125-
- template: stages/download-java-tools-stage.yml
126-
127125
- template: templates/c-api-cpu.yml
128126
parameters:
129127
RunOnnxRuntimeTests: ${{ parameters.RunOnnxRuntimeTests }}
130128
IsReleaseBuild: ${{ parameters.IsReleaseBuild }}
129+
PreReleaseVersionSuffixString: ${{ parameters.PreReleaseVersionSuffixString }}
130+
PreReleaseVersionSuffixNumber: ${{ parameters.PreReleaseVersionSuffixNumber }}
131131
${{ if eq(parameters.NugetPackageSuffix, 'NONE') }}:
132132
OrtNugetPackageId: 'Microsoft.ML.OnnxRuntime'
133133
${{ else }}:
134134
OrtNugetPackageId: 'Microsoft.ML.OnnxRuntime${{ parameters.NugetPackageSuffix }}'
135135
AdditionalBuildFlags: ''
136136
AdditionalWinBuildFlags: '--enable_onnx_tests ${{parameters.AdditionalBuildFlag}}'
137137
BuildVariant: 'default'
138-
SpecificArtifact: ${{ parameters.SpecificArtifact }}
139-
BuildId: ${{ parameters.BuildId }}
140138
QnnSDKVersion: ${{ parameters.QnnSdk }}
141139
is1ES: true
142140

143141
- template: stages/java-cuda-packaging-stage.yml
144-
parameters:
145-
CudaVersion: 12.2
146-
SpecificArtifact: ${{ parameters.SpecificArtifact }}
147-
BuildId: ${{ parameters.BuildId }}
148142

149143
- template: stages/nuget-combine-cuda-stage.yml
150144
parameters:
@@ -159,6 +153,8 @@ extends:
159153
buildNodejs: true
160154
SpecificArtifact: ${{ parameters.SpecificArtifact }}
161155
BuildId: ${{ parameters.BuildId }}
156+
PreReleaseVersionSuffixString: ${{ parameters.PreReleaseVersionSuffixString }}
157+
PreReleaseVersionSuffixNumber: ${{ parameters.PreReleaseVersionSuffixNumber }}
162158

163159
- template: stages/nodejs-win-packaging-stage.yml
164160
parameters:

tools/ci_build/github/azure-pipelines/c-api-noopenmp-test-pipelines.yml

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ stages:
175175
artifact: 'Windows_Packaging_cuda_build_artifacts'
176176
displayName: 'Download Windows GPU Packages Build'
177177

178+
- template: templates/setup-build-tools.yml
179+
178180
- task: CmdLine@2
179181
inputs:
180182
script: |
@@ -188,17 +190,6 @@ stages:
188190
jdkArchitectureOption: x64
189191
jdkSourceOption: 'PreInstalled'
190192

191-
- task: UsePythonVersion@0
192-
inputs:
193-
versionSpec: '3.12'
194-
addToPath: true
195-
architecture: x64
196-
197-
- task: PipAuthenticate@1
198-
displayName: 'Pip Authenticate'
199-
inputs:
200-
artifactFeeds: 'Lotus'
201-
202193
- task: PythonScript@0
203194
displayName: 'Update CTest Path References'
204195
inputs:
@@ -207,10 +198,6 @@ stages:
207198
"$(Build.BinariesDirectory)/RelWithDebInfo/CTestTestfile.cmake"
208199
"$(Build.BinariesDirectory)/RelWithDebInfo"
209200
210-
- task: NodeTool@0
211-
inputs:
212-
versionSpec: '22.x'
213-
214201
- template: templates/jobs/download_win_gpu_library.yml
215202
parameters:
216203
CudaVersion: 12.2
@@ -223,12 +210,6 @@ stages:
223210
scriptPath: '$(Build.SourcesDirectory)\tools\ci_build\build.py'
224211
arguments: '--config RelWithDebInfo --use_binskim_compliant_compile_flags --enable_lto --disable_rtti --build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --test --enable_onnx_tests'
225212
workingDirectory: '$(Build.BinariesDirectory)'
226-
# Previous stage only assembles the java binaries, testing will be done in this stage with GPU machine
227-
- template: templates/make_java_win_binaries.yml
228-
parameters:
229-
msbuildPlatform: x64
230-
java_artifact_id: onnxruntime_gpu
231-
buildOnly: false
232213

233214
- stage: Windows_Packaging_Tensorrt_Testing
234215
dependsOn: Setup
@@ -242,12 +223,13 @@ stages:
242223
- checkout: self
243224
clean: true
244225
submodules: none
245-
246-
226+
247227
- download: build
248228
artifact: 'Windows_Packaging_tensorrt_build_artifacts'
249229
displayName: 'Download Windows GPU Packages Build'
250230

231+
- template: templates/setup-build-tools.yml
232+
251233
- task: CmdLine@2
252234
inputs:
253235
script: |
@@ -260,18 +242,7 @@ stages:
260242
versionSpec: "17"
261243
jdkArchitectureOption: x64
262244
jdkSourceOption: 'PreInstalled'
263-
264-
- task: UsePythonVersion@0
265-
inputs:
266-
versionSpec: '3.12'
267-
addToPath: true
268-
architecture: x64
269-
270-
- task: PipAuthenticate@1
271-
displayName: 'Pip Authenticate'
272-
inputs:
273-
artifactFeeds: 'Lotus'
274-
245+
275246
- task: PythonScript@0
276247
displayName: 'Update CTest Path References'
277248
inputs:
@@ -280,10 +251,6 @@ stages:
280251
"$(Build.BinariesDirectory)/RelWithDebInfo/CTestTestfile.cmake"
281252
"$(Build.BinariesDirectory)/RelWithDebInfo"
282253
283-
- task: NodeTool@0
284-
inputs:
285-
versionSpec: '22.x'
286-
287254
- template: templates/jobs/download_win_gpu_library.yml
288255
parameters:
289256
CudaVersion: 12.2
@@ -295,10 +262,4 @@ stages:
295262
inputs:
296263
scriptPath: '$(Build.SourcesDirectory)\tools\ci_build\build.py'
297264
arguments: '--config RelWithDebInfo --use_binskim_compliant_compile_flags --enable_lto --disable_rtti --build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --test --enable_onnx_tests'
298-
workingDirectory: '$(Build.BinariesDirectory)'
299-
# Previous stage only assembles the java binaries, testing will be done in this stage with GPU machine
300-
- template: templates/make_java_win_binaries.yml
301-
parameters:
302-
msbuildPlatform: x64
303-
java_artifact_id: onnxruntime_gpu
304-
buildOnly: false
265+
workingDirectory: '$(Build.BinariesDirectory)'

tools/ci_build/github/azure-pipelines/cuda-packaging-pipeline.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,9 @@ extends:
123123
buildNodejs: false
124124
SpecificArtifact: ${{ parameters.SpecificArtifact }}
125125
BuildId: ${{ parameters.BuildId }}
126+
PreReleaseVersionSuffixString: ${{ parameters.PreReleaseVersionSuffixString }}
127+
PreReleaseVersionSuffixNumber: ${{ parameters.PreReleaseVersionSuffixNumber }}
126128

127129
- template: stages/download-java-tools-stage.yml
128130

129131
- template: stages/java-cuda-packaging-stage.yml
130-
parameters:
131-
CudaVersion: ${{ parameters.CudaVersion }}
132-
SpecificArtifact: ${{ parameters.SpecificArtifact }}
133-
BuildId: ${{ parameters.BuildId }}

tools/ci_build/github/azure-pipelines/custom-nuget-packaging-pipeline.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ extends:
9292

9393
- template: templates/win-ci.yml
9494
parameters:
95+
PreReleaseVersionSuffixString: ${{ parameters.PreReleaseVersionSuffixString }}
96+
PreReleaseVersionSuffixNumber: ${{ parameters.PreReleaseVersionSuffixNumber }}
9597
ort_build_pool_name: 'onnxruntime-Win2022-GPU-A10'
9698
DoCompliance: false
9799
DoEsrp: true
@@ -124,7 +126,6 @@ extends:
124126
- template: templates/mac-cpu-packaging-pipeline.yml
125127
parameters:
126128
AllowReleasedOpsetOnly: 1
127-
BuildForAllArchs: true
128129
AdditionalBuildFlags: '--use_webgpu --skip_tests'
129130
DoEsrp: true
130131

0 commit comments

Comments
 (0)