|
1 |
| -# Xcode |
2 |
| -# Build, test, and archive an Xcode workspace on macOS. |
3 |
| -# Add steps that install certificates, test, sign, and distribute an app, save build artifacts, and more: |
4 |
| -# https://docs.microsoft.com/azure/devops/pipelines/languages/xcode |
5 |
| - |
6 |
| -trigger: |
7 |
| - branches: |
8 |
| - include: |
9 |
| - - dev |
10 |
| - |
| 1 | +# Pipeline will be triggered for PR & any updates on the PR on all branches |
11 | 2 | pr:
|
12 | 3 | autoCancel: true
|
13 | 4 | branches:
|
14 | 5 | include:
|
15 | 6 | - '*'
|
16 | 7 | drafts: true
|
17 | 8 |
|
18 |
| -pool: |
19 |
| - name: 'Azure Pipelines' |
20 |
| - |
21 |
| -resources: |
22 |
| - repositories: |
23 |
| - - repository: azure-activedirectory-tokenbroker-for-objc |
24 |
| - type: github |
25 |
| - endpoint: 'MSAL ObjC Service Connection' |
26 |
| - name: AzureAD/azure-activedirectory-tokenbroker-for-objc |
27 |
| - |
28 |
| - - repository: WorkplaceJoin-for-iOS |
29 |
| - type: github |
30 |
| - endpoint: 'MSAL ObjC Service Connection' |
31 |
| - name: AzureAD/WorkplaceJoin-for-iOS |
| 9 | +# Trigger CI for only main/release branches |
| 10 | +trigger: |
| 11 | + branches: |
| 12 | + include: |
| 13 | + - main |
| 14 | + - release/* |
| 15 | + exclude: |
| 16 | + - '*' |
32 | 17 |
|
| 18 | +# Define parallel jobs that run build script for specified targets |
33 | 19 | jobs:
|
| 20 | +- job: 'PRAssistant' |
| 21 | + pool: |
| 22 | + vmImage: 'ubuntu-latest' |
| 23 | + timeOutInMinutes: 10 |
| 24 | + displayName: Invoke pipeline PRAssistantInvoker to trigger copilot code review |
| 25 | + steps: |
| 26 | + - bash: | |
| 27 | + echo "Source branch : $(System.PullRequest.SourceBranch) Target branch : $(System.PullRequest.targetBranchName)" |
| 28 | + az pipelines run --project 'IDDP' --id 2728 --branch dev --organization 'https://dev.azure.com/IdentityDivision' --variables source_branch=$(System.PullRequest.SourceBranch) target_branch=$(System.PullRequest.targetBranchName) |
| 29 | + displayName: 'Invoke pipeline PRAssistantInvoker' |
| 30 | + env: |
| 31 | + AZURE_DEVOPS_EXT_PAT: $(System.AccessToken) |
| 32 | + failOnStderr: false |
34 | 33 | - job: 'Validate_Pull_Request'
|
| 34 | + strategy: |
| 35 | + maxParallel: 3 |
| 36 | + matrix: |
| 37 | + IOS_FRAMEWORK: |
| 38 | + target: "iosFramework iosTestApp sampleIosApp sampleIosAppSwift" |
| 39 | + MAC_FRAMEWORK: |
| 40 | + target: "macFramework" |
| 41 | + VISION_FRAMEWORK: |
| 42 | + target: "visionOSFramework" |
35 | 43 | displayName: Validate Pull Request
|
36 | 44 | pool:
|
37 | 45 | vmImage: 'macOS-14'
|
38 | 46 | timeOutInMinutes: 30
|
39 | 47 |
|
40 | 48 | steps:
|
41 |
| - - checkout: azure-activedirectory-tokenbroker-for-objc |
42 |
| - displayName: 'Checkout Broker' |
43 |
| - clean: false |
44 |
| - submodules: false |
45 |
| - fetchTags: true |
46 |
| - persistCredentials: true |
47 |
| - |
| 49 | + - script: | |
| 50 | + /bin/bash -c "sudo xcode-select -s /Applications/Xcode_15.4.app" |
| 51 | + displayName: 'Switch to use Xcode 15.4' |
| 52 | + - task: CmdLine@2 |
| 53 | + displayName: Uninstalling xcpretty v0.4.0 |
| 54 | + inputs: |
| 55 | + script: | |
| 56 | + gem uninstall xcpretty -I --version 0.4.0 |
| 57 | + failOnStderr: false |
| 58 | + - task: CmdLine@2 |
| 59 | + displayName: Installing xcpretty v0.3.0 |
| 60 | + inputs: |
| 61 | + script: | |
| 62 | + gem install xcpretty -N -v 0.3.0 |
| 63 | + failOnStderr: true |
| 64 | + - task: CmdLine@2 |
| 65 | + displayName: Installing dependencies |
| 66 | + inputs: |
| 67 | + script: | |
| 68 | + gem install slather bundler -N |
| 69 | + failOnStderr: true |
48 | 70 | - checkout: self
|
49 |
| - displayName: 'Checkout MSAL' |
50 |
| - clean: false |
51 |
| - submodules: false |
52 |
| - fetchTags: true |
53 |
| - path: 's/azure-activedirectory-tokenbroker-for-objc/ADAuthenticationBroker/Frameworks/microsoft-authentication-library-for-objc' |
54 |
| - persistCredentials: true |
55 |
| - |
| 71 | + clean: true |
| 72 | + submodules: true |
| 73 | + fetchDepth: 1 |
| 74 | + persistCredentials: false |
56 | 75 | - task: Bash@3
|
57 |
| - displayName: 'Checkout MSAL submodules + ADAL' |
| 76 | + displayName: Removing any lingering codecov files. These can cause issues when the xcode version changes |
58 | 77 | inputs:
|
59 |
| - workingDirectory: $(Pipeline.Workspace)/s |
60 | 78 | targetType: 'inline'
|
61 | 79 | script: |
|
62 |
| - cd azure-activedirectory-tokenbroker-for-objc |
63 |
| - git submodule update --init --recursive ADAuthenticationBroker/Frameworks/adal |
64 |
| - cd ADAuthenticationBroker/Frameworks/microsoft-authentication-library-for-objc |
65 |
| - git submodule update --init --recursive |
66 |
| -
|
67 |
| - - checkout: WorkplaceJoin-for-iOS |
68 |
| - displayName: 'Checkout WPJ' |
69 |
| - clean: false |
70 |
| - submodules: false |
71 |
| - fetchTags: true |
72 |
| - path: 's/azure-activedirectory-tokenbroker-for-objc/ADAuthenticationBroker/Frameworks/WorkplaceJoin-for-iOS' |
73 |
| - persistCredentials: true |
74 |
| - |
75 |
| - - task: AzureCLI@2 |
| 80 | + find . -name "*.gcda" -print0 | xargs -0 rm |
| 81 | + - task: ComponentGovernanceComponentDetection@0 |
76 | 82 | inputs:
|
77 |
| - azureSubscription: 'AuthSdkResourceManager' |
78 |
| - scriptType: 'pscore' |
79 |
| - scriptLocation: 'inlineScript' |
80 |
| - inlineScript: | |
81 |
| - # if this fails, check out this bash script that includes diagnostics: |
82 |
| - # https://gist.github.com/johnterickson/19f80a3e969e39f1000d118739176e62 |
83 |
| - # uncomment these for more debugging spew |
84 |
| - # GIT_TRACE=1 |
85 |
| - # GIT_CURL_VERBOSE=1 |
86 |
| - |
87 |
| - # Note that the resoruce is specified to limit the token to Azure DevOps |
88 |
| - $token = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv |
89 |
| - Write-Host "##vso[task.setvariable variable=aadToken;issecret=true]$token" |
| 83 | + alertWarningLevel: Low |
| 84 | +# The following is needed to install the visionOS SDK on macos-14 vm image which |
| 85 | +# doesn't have visionOS installed by default. |
| 86 | +# TODO: Remove when macos-14-arm64 is supported on ADO. |
90 | 87 | - task: Bash@3
|
91 |
| - displayName: 'Checkout NGC Submodules' |
92 |
| - env: |
93 |
| - AccessToken: $(MSAzureToken_encoded) |
| 88 | + displayName: download visionOS SDK |
94 | 89 | inputs:
|
95 |
| - workingDirectory: $(Pipeline.Workspace)/s |
96 | 90 | targetType: 'inline'
|
97 | 91 | script: |
|
98 |
| - cd azure-activedirectory-tokenbroker-for-objc/ADAuthenticationBroker/Frameworks |
99 |
| - git -c http.https://msazure.visualstudio.com/DefaultCollection/One/_git/AD-MFA-NGCAuthentication.extraheader="AUTHORIZATION: bearer $(aadToken)" submodule update --init AD-MFA-NGCAuthentication |
100 |
| - cd AD-MFA-NGCAuthentication |
101 |
| - git -c http.https://msazure.visualstudio.com/DefaultCollection/One/_git/AD-MFA-NGCKeyProvider-ios.extraheader="AUTHORIZATION: bearer $(aadToken)" submodule update --init NGCKeyProvider |
102 |
| - git -c http.https://msazure.visualstudio.com/DefaultCollection/One/_git/AD-MFA-MSAuthNetworking.extraheader="AUTHORIZATION: bearer $(aadToken)" submodule update --init MSAuthNetworking |
103 |
| -
|
| 92 | + echo $(target) |
| 93 | + if [ $(target) == 'visionOSFramework' ]; then |
| 94 | + echo "Downloading simulator for visionOS" |
| 95 | + sudo xcode-select -s /Applications/Xcode_15.4.app/Contents/Developer |
| 96 | + defaults write com.apple.dt.Xcode AllowUnsupportedVisionOSHost -bool YES |
| 97 | + defaults write com.apple.CoreSimulator AllowUnsupportedVisionOSHost -bool YES |
| 98 | + xcodebuild -downloadPlatform visionOS |
| 99 | + else |
| 100 | + echo "Not visionOS job, no download needed" |
| 101 | + fi |
| 102 | + failOnStderr: false |
104 | 103 | - task: Bash@3
|
105 |
| - displayName: 'Checkout WPJ openssl-msft submodule' |
| 104 | + displayName: Run Build script & check for Errors |
106 | 105 | inputs:
|
107 |
| - workingDirectory: $(Pipeline.Workspace)/s |
108 | 106 | targetType: 'inline'
|
109 | 107 | script: |
|
110 |
| - cd azure-activedirectory-tokenbroker-for-objc/ADAuthenticationBroker/Frameworks/WorkplaceJoin-for-iOS |
111 |
| - git -c http.https://msazure.visualstudio.com/DefaultCollection/PlatformCrypto/_git/openssl-msft.extraheader="AUTHORIZATION: bearer $(aadToken)" submodule update --init Frameworks/openssl-msft |
112 |
| -
|
| 108 | + { output=$(./build.py --target $(target) 2>&1 1>&3-) ;} 3>&1 |
| 109 | + final_status=$(<./build/status.txt) |
| 110 | + echo "FINAL STATUS = ${final_status}" |
| 111 | + echo "POSSIBLE ERRORS: ${output}" |
| 112 | + |
| 113 | + if [ $final_status != "0" ]; then |
| 114 | + echo "Build & Testing Failed! \n ${output}" >&2 |
| 115 | + fi |
| 116 | + failOnStderr: true |
113 | 117 | - task: Bash@3
|
114 |
| - displayName: 'Update WPJ submodules' |
| 118 | + condition: always() |
| 119 | + displayName: Cleanup |
115 | 120 | inputs:
|
116 |
| - workingDirectory: $(Pipeline.Workspace)/s |
117 | 121 | targetType: 'inline'
|
118 | 122 | script: |
|
119 |
| - cd azure-activedirectory-tokenbroker-for-objc/ADAuthenticationBroker/Frameworks/WorkplaceJoin-for-iOS |
120 |
| - git submodule update --init --recursive Frameworks/microsoft-authentication-library-for-objc |
121 |
| - |
122 |
| - - script: 'gem uninstall xcpretty -I --version 0.4.0' |
123 |
| - displayName: 'Uninstall xcpretty v0.4.0' |
| 123 | + rm -rf ./build/status.txt |
| 124 | + - task: PublishTestResults@2 |
| 125 | + condition: always() |
| 126 | + displayName: Publish Test Report |
| 127 | + inputs: |
| 128 | + testResultsFormat: 'JUnit' |
| 129 | + testResultsFiles: '$(Agent.BuildDirectory)/s/build/reports/*' |
| 130 | + failTaskOnFailedTests: true |
| 131 | + testRunTitle: 'Test Run - $(target)' |
| 132 | + |
| 133 | +- job: fetch_pr_labels |
| 134 | + displayName: 'Check for PR Label' |
| 135 | + timeoutInMinutes: 5 |
| 136 | + pool: |
| 137 | + vmImage: 'macOS-14' |
| 138 | + steps: |
| 139 | + - script: | |
| 140 | + url="https://api.github.com/repos/$BUILD_REPOSITORY_ID/issues/$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER/labels" |
| 141 | +
|
| 142 | + echo "Fetching labels from $url " |
| 143 | +
|
| 144 | + # Temporary file to store the raw response |
| 145 | + temp_file=$(mktemp) |
| 146 | +
|
| 147 | + # Store the response code and the raw response in separate variables |
| 148 | + response_code=$(curl -s -w "%{http_code}" -o "$temp_file" "$url") |
| 149 | + response_content=$(cat "$temp_file") |
| 150 | +
|
| 151 | + echo "Response code: $response_code" |
| 152 | + echo "Raw response: $response_content" |
| 153 | +
|
| 154 | + if [[ "$response_code" -eq 200 ]]; then |
| 155 | + label_names=$(echo $response_content | jq -r '.[].name' | paste -sd ', ' -) |
| 156 | + echo "##vso[task.setvariable variable=PR_LABELS;isOutput=true]$label_names" |
| 157 | + [ -z "$label_names" ] && echo "PR labels: <empty>" || echo "PR labels: $label_names" |
| 158 | + else |
| 159 | + echo "Request failed with status code: $response_code - Skipping Native Auth E2E tests as a preventive measure" |
| 160 | + echo "##vso[task.setvariable variable=PR_LABELS;isOutput=true]'skip-native-auth-e2e-tests'" |
| 161 | + fi |
| 162 | +
|
| 163 | + name: fetchPrLabels |
| 164 | +
|
| 165 | +- job: e2e_test_native_auth_ios |
| 166 | + displayName: 'Run MSAL E2E tests for iOS native auth' |
| 167 | + dependsOn: fetch_pr_labels |
| 168 | + condition: and( succeeded(), not(contains(dependencies.fetch_pr_labels.outputs['fetchPrLabels.PR_LABELS'], 'skip-native-auth-e2e-tests')) ) |
| 169 | + timeoutInMinutes: 30 |
| 170 | + cancelTimeoutInMinutes: 5 |
| 171 | + pool: |
| 172 | + vmImage: 'macOS-14' |
| 173 | + workspace: |
| 174 | + clean: all |
| 175 | + |
| 176 | + steps: |
| 177 | + - template: templates/tests-with-conf-file.yml |
| 178 | + parameters: |
| 179 | + schema: 'MSAL iOS Native Auth E2E Tests' |
| 180 | + full_path: 'build/Build/Products/MSAL iOS Native Auth E2E Tests_MSAL iOS Native Auth E2E Tests_iphonesimulator18.1-x86_64.xctestrun' |
| 181 | + destination: 'platform=iOS Simulator,name=iPhone 16,OS=18.1' |
| 182 | + sdk: 'iphonesimulator' |
| 183 | + retry_tests: false |
| 184 | + |
| 185 | +- job: e2e_test_native_auth_mac |
| 186 | + displayName: 'Run MSAL E2E tests for macOS native auth' |
| 187 | + dependsOn: fetch_pr_labels |
| 188 | + condition: and( succeeded(), not(contains(dependencies.fetch_pr_labels.outputs['fetchPrLabels.PR_LABELS'], 'skip-native-auth-e2e-tests')) ) |
| 189 | + timeoutInMinutes: 30 |
| 190 | + cancelTimeoutInMinutes: 5 |
| 191 | + pool: |
| 192 | + vmImage: 'macOS-14' |
| 193 | + workspace: |
| 194 | + clean: all |
| 195 | + |
| 196 | + steps: |
| 197 | + - template: templates/tests-with-conf-file.yml |
| 198 | + parameters: |
| 199 | + schema: 'MSAL Mac Native Auth E2E Tests' |
| 200 | + full_path: 'build/Build/Products/MSAL Mac Native Auth E2E Tests_MSAL Mac Native Auth E2E Tests_macosx15.1-x86_64.xctestrun' |
| 201 | + destination: 'platform=macOS' |
| 202 | + sdk: 'macosx' |
| 203 | + retry_tests: false |
| 204 | + |
| 205 | +- job: 'Validate_SPM_Integration' |
| 206 | + displayName: Validate SPM Integration |
| 207 | + pool: |
| 208 | + vmImage: 'macOS-14' |
| 209 | + timeOutInMinutes: 15 |
| 210 | + workspace: |
| 211 | + clean: all |
124 | 212 |
|
125 |
| - - script: 'gem install xcpretty -N -v 0.3.0' |
126 |
| - displayName: 'Install xcpretty v0.3.0' |
127 |
| - |
128 |
| - - script: 'gem install slather -N' |
129 |
| - displayName: 'Install slather' |
| 213 | + steps: |
| 214 | + |
| 215 | + - checkout: self |
| 216 | + clean: true |
| 217 | + submodules: true |
| 218 | + fetchDepth: 1 |
| 219 | + persistCredentials: true |
| 220 | + path: s |
130 | 221 |
|
131 |
| - - task: UsePythonVersion@0 |
132 |
| - displayName: 'Use Python 3.x' |
| 222 | + - script: | |
| 223 | + /bin/bash -c "sudo xcode-select -s /Applications/Xcode_15.4.app" |
| 224 | + displayName: 'Switch to use Xcode 15.4' |
133 | 225 |
|
134 | 226 | - task: Bash@3
|
135 |
| - displayName: 'Select Xcode version' |
| 227 | + displayName: Set variable BRANCH_NAME to a temporary branch |
136 | 228 | inputs:
|
137 | 229 | targetType: 'inline'
|
138 |
| - script: '/bin/bash -c "sudo xcode-select -s /Applications/Xcode_15.4.app"' |
139 |
| - |
140 |
| -# The following is needed to install the visionOS SDK on macos-14 vm image which |
141 |
| -# doesn't have visionOS installed by default. |
142 |
| -# TODO: Remove when macos-14-arm64 is supported on ADO. |
| 230 | + script: | |
| 231 | + BRANCH_NAME_LOCAL="$(Build.SourceBranchName)-temp" |
| 232 | + echo "##vso[task.setvariable variable=BRANCH_NAME]${BRANCH_NAME_LOCAL}" |
| 233 | + |
143 | 234 | - task: Bash@3
|
144 |
| - displayName: download visionOS SDK |
| 235 | + displayName: Checkout to temporary branch |
145 | 236 | inputs:
|
146 | 237 | targetType: 'inline'
|
147 | 238 | script: |
|
148 |
| - echo "Downloading simulator for visionOS" |
149 |
| - sudo xcode-select -s /Applications/Xcode_15.4.app/Contents/Developer |
150 |
| - defaults write com.apple.dt.Xcode AllowUnsupportedVisionOSHost -bool YES |
151 |
| - defaults write com.apple.CoreSimulator AllowUnsupportedVisionOSHost -bool YES |
152 |
| - xcodebuild -downloadPlatform visionOS |
153 |
| - failOnStderr: false |
154 |
| - |
| 239 | + git checkout -b "${BRANCH_NAME}" |
155 | 240 |
|
156 | 241 | - task: Bash@3
|
157 |
| - displayName: 'Run a python script for Broker' |
| 242 | + displayName: Run SPM integration test script |
158 | 243 | inputs:
|
159 | 244 | targetType: 'inline'
|
160 | 245 | script: |
|
161 |
| - cd azure-activedirectory-tokenbroker-for-objc |
162 |
| - echo "executing build:./build.py" |
163 |
| - python3 ./build.py |
164 |
| - |
| 246 | + sh spm-integration-test.sh "${BRANCH_NAME}" |
| 247 | + continueOnError: false |
| 248 | + |
| 249 | + - task: Bash@3 |
| 250 | + condition: always() |
| 251 | + displayName: Cleanup |
| 252 | + inputs: |
| 253 | + targetType: 'inline' |
| 254 | + script: |
| 255 | + cd ../.. |
| 256 | + rm -rf "$SAMPLE_APP_TEMP_DIR" archive framework MSAL.zip |
| 257 | + git checkout -- . |
| 258 | + git fetch --quiet |
| 259 | + git switch "$(Build.SourceBranchName)" |
| 260 | + git branch -D "$BRANCH_NAME" |
| 261 | + git push origin --delete "$BRANCH_NAME" |
| 262 | + |
0 commit comments