onnxruntime/tools/ci_build/github/azure-pipelines/mac-ios-packaging-pipeline.yml
Jian Chen e0022d061f
Set web-ci-pipeline.yml only triggered when related fields are updated (#17148)
- 'js/web'
    - 'js/node'
    - 'onnxruntime/core/providers/js'
    is updated

### Description
<!-- Describe your changes. -->



### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
2023-08-17 12:55:35 -07:00

146 lines
4.1 KiB
YAML

trigger:
branches:
include:
- main
- rel-*
paths:
exclude:
- docs/**
- README.md
- CONTRIBUTING.md
- BUILD.md
- 'js/web'
- 'onnxruntime/core/providers/js'
pr:
branches:
include:
- main
- rel-*
paths:
exclude:
- docs/**
- README.md
- CONTRIBUTING.md
- BUILD.md
- 'js/web'
- 'onnxruntime/core/providers/js'
parameters:
- name: buildType
displayName: |-
Type of build.
"release": A release build to be published for an official ONNX Runtime release.
"normal": A normal build. This can be published as a pre-release build for validation prior to release.
type: string
values:
- release
- normal
default: normal
name: "$(Date:yyyyMMdd)$(Rev:rrr)" # build number format
stages:
- stage: IosPackaging_SetCommonVariables
dependsOn: []
variables:
skipComponentGovernanceDetection: true
jobs:
- job: j
displayName: "Set common variables"
pool:
vmImage: "macOS-13"
timeoutInMinutes: 5
steps:
- bash: |
set -e
BUILD_TYPE="${{ parameters.buildType }}"
BASE_VERSION="$(cat ./VERSION_NUMBER)"
SHORT_COMMIT_HASH="$(git rev-parse --short HEAD)"
DEV_VERSION="${BASE_VERSION}-dev+$(Build.BuildNumber).${SHORT_COMMIT_HASH}"
case "${BUILD_TYPE}" in
("release")
VERSION="${BASE_VERSION}" ;;
("normal")
VERSION="${DEV_VERSION}" ;;
(*)
echo "Invalid build type: ${BUILD_TYPE}"; exit 1 ;;
esac
# Do not output ##vso[] commands with `set -x` or they may be parsed again and include a trailing quote.
set +x
set_var() {
local VAR_NAME=${1:?}
local VAR_VALUE=${2:?}
echo "##vso[task.setvariable variable=${VAR_NAME};isoutput=true;isreadonly=true]${VAR_VALUE}"
echo "${VAR_NAME}: ${VAR_VALUE}"
}
set_var "ORT_POD_VERSION" "${VERSION}"
displayName: "Set common variables"
name: SetCommonVariables
- template: templates/stages/mac-ios-packaging-build-stage.yml
parameters:
packageVariant: Mobile
- template: templates/stages/mac-ios-packaging-build-stage.yml
parameters:
packageVariant: Full
- template: templates/stages/mac-ios-packaging-build-stage.yml
parameters:
packageVariant: Training
- stage: IosPackaging_TestPackageSwift_Full
dependsOn:
- IosPackaging_SetCommonVariables
- IosPackaging_Build_Full
jobs:
- job: j
displayName: "Test Package.swift with full package"
pool:
vmImage: "macOS-13"
variables:
xcodeVersion: "14.3"
ortPodVersion: $[stageDependencies.IosPackaging_SetCommonVariables.j.outputs['SetCommonVariables.ORT_POD_VERSION']]
skipComponentGovernanceDetection: true
timeoutInMinutes: 10
steps:
- template: templates/use-xcode-version.yml
parameters:
xcodeVersion: ${{ variables.xcodeVersion }}
- download: current
artifact: ios_packaging_artifacts_full
displayName: "Download full build artifacts"
- script: |
set -e -x
shasum -a 256 "$(Pipeline.Workspace)/ios_packaging_artifacts_full/pod-archive-onnxruntime-c-$(ortPodVersion).zip"
displayName: "Print ORT iOS Pod checksum"
# copy the pod archive to a path relative to Package.swift and set the env var required by Package.swift to use that.
# xcodebuild will implicitly use Package.swift and build/run the .testTarget (tests in swift/onnxTests).
# once that's done cleanup the copy of the pod zip file
- script: |
set -e -x
SIMULATOR_DEVICE_ID=$(set -o pipefail; python3 tools/ci_build/github/apple/get_simulator_device_info.py | jq --raw-output '.device_udid')
cp "$(Pipeline.Workspace)/ios_packaging_artifacts_full/pod-archive-onnxruntime-c-$(ortPodVersion).zip" swift/
export ORT_IOS_POD_LOCAL_PATH="swift/pod-archive-onnxruntime-c-$(ortPodVersion).zip"
xcodebuild test -scheme onnxruntime -destination "platform=iOS Simulator,id=${SIMULATOR_DEVICE_ID}"
rm swift/pod-archive-onnxruntime-c-$(ortPodVersion).zip
displayName: "Test Package.swift usage"