-
Notifications
You must be signed in to change notification settings - Fork 145
/
Copy pathpr-validation.yml
262 lines (238 loc) · 8.17 KB
/
pr-validation.yml
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
# Pipeline will be triggered for PR & any updates on the PR on all branches
pr:
autoCancel: true
branches:
include:
- '*'
drafts: true
# Trigger CI for only main/release branches
trigger:
branches:
include:
- main
- release/*
exclude:
- '*'
# Define parallel jobs that run build script for specified targets
jobs:
- job: 'PRAssistant'
pool:
vmImage: 'ubuntu-latest'
timeOutInMinutes: 10
displayName: Invoke pipeline PRAssistantInvoker to trigger copilot code review
steps:
- bash: |
echo "Source branch : $(System.PullRequest.SourceBranch) Target branch : $(System.PullRequest.targetBranchName)"
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)
displayName: 'Invoke pipeline PRAssistantInvoker'
env:
AZURE_DEVOPS_EXT_PAT: $(System.AccessToken)
failOnStderr: false
- job: 'Validate_Pull_Request'
strategy:
maxParallel: 3
matrix:
IOS_FRAMEWORK:
target: "iosFramework iosTestApp sampleIosApp sampleIosAppSwift"
MAC_FRAMEWORK:
target: "macFramework"
VISION_FRAMEWORK:
target: "visionOSFramework"
displayName: Validate Pull Request
pool:
vmImage: 'macOS-14'
timeOutInMinutes: 30
steps:
- script: |
/bin/bash -c "sudo xcode-select -s /Applications/Xcode_15.4.app"
displayName: 'Switch to use Xcode 15.4'
- task: CmdLine@2
displayName: Uninstalling xcpretty v0.4.0
inputs:
script: |
gem uninstall xcpretty -I --version 0.4.0
failOnStderr: false
- task: CmdLine@2
displayName: Installing xcpretty v0.3.0
inputs:
script: |
gem install xcpretty -N -v 0.3.0
failOnStderr: true
- task: CmdLine@2
displayName: Installing dependencies
inputs:
script: |
gem install slather bundler -N
failOnStderr: true
- checkout: self
clean: true
submodules: true
fetchDepth: 1
persistCredentials: false
- task: Bash@3
displayName: Removing any lingering codecov files. These can cause issues when the xcode version changes
inputs:
targetType: 'inline'
script: |
find . -name "*.gcda" -print0 | xargs -0 rm
- task: ComponentGovernanceComponentDetection@0
inputs:
alertWarningLevel: Low
# The following is needed to install the visionOS SDK on macos-14 vm image which
# doesn't have visionOS installed by default.
# TODO: Remove when macos-14-arm64 is supported on ADO.
- task: Bash@3
displayName: download visionOS SDK
inputs:
targetType: 'inline'
script: |
echo $(target)
if [ $(target) == 'visionOSFramework' ]; then
echo "Downloading simulator for visionOS"
sudo xcode-select -s /Applications/Xcode_15.4.app/Contents/Developer
defaults write com.apple.dt.Xcode AllowUnsupportedVisionOSHost -bool YES
defaults write com.apple.CoreSimulator AllowUnsupportedVisionOSHost -bool YES
xcodebuild -downloadPlatform visionOS
else
echo "Not visionOS job, no download needed"
fi
failOnStderr: false
- task: Bash@3
displayName: Run Build script & check for Errors
inputs:
targetType: 'inline'
script: |
{ output=$(./build.py --target $(target) 2>&1 1>&3-) ;} 3>&1
final_status=$(<./build/status.txt)
echo "FINAL STATUS = ${final_status}"
echo "POSSIBLE ERRORS: ${output}"
if [ $final_status != "0" ]; then
echo "Build & Testing Failed! \n ${output}" >&2
fi
failOnStderr: true
- task: Bash@3
condition: always()
displayName: Cleanup
inputs:
targetType: 'inline'
script: |
rm -rf ./build/status.txt
- task: PublishTestResults@2
condition: always()
displayName: Publish Test Report
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '$(Agent.BuildDirectory)/s/build/reports/*'
failTaskOnFailedTests: true
testRunTitle: 'Test Run - $(target)'
- job: fetch_pr_labels
displayName: 'Check for PR Label'
timeoutInMinutes: 5
pool:
vmImage: 'macOS-14'
steps:
- script: |
url="https://api.github.com/repos/$BUILD_REPOSITORY_ID/issues/$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER/labels"
echo "Fetching labels from $url "
# Temporary file to store the raw response
temp_file=$(mktemp)
# Store the response code and the raw response in separate variables
response_code=$(curl -s -w "%{http_code}" -o "$temp_file" "$url")
response_content=$(cat "$temp_file")
echo "Response code: $response_code"
echo "Raw response: $response_content"
if [[ "$response_code" -eq 200 ]]; then
label_names=$(echo $response_content | jq -r '.[].name' | paste -sd ', ' -)
echo "##vso[task.setvariable variable=PR_LABELS;isOutput=true]$label_names"
[ -z "$label_names" ] && echo "PR labels: <empty>" || echo "PR labels: $label_names"
else
echo "Request failed with status code: $response_code - Skipping Native Auth E2E tests as a preventive measure"
echo "##vso[task.setvariable variable=PR_LABELS;isOutput=true]'skip-native-auth-e2e-tests'"
fi
name: fetchPrLabels
- job: e2e_test_native_auth_ios
displayName: 'Run MSAL E2E tests for iOS native auth'
dependsOn: fetch_pr_labels
condition: and( succeeded(), not(contains(dependencies.fetch_pr_labels.outputs['fetchPrLabels.PR_LABELS'], 'skip-native-auth-e2e-tests')) )
timeoutInMinutes: 30
cancelTimeoutInMinutes: 5
pool:
vmImage: 'macOS-14'
workspace:
clean: all
steps:
- template: templates/tests-with-conf-file.yml
parameters:
schema: 'MSAL iOS Native Auth E2E Tests'
full_path: 'build/Build/Products/MSAL iOS Native Auth E2E Tests_MSAL iOS Native Auth E2E Tests_iphonesimulator18.1-x86_64.xctestrun'
destination: 'platform=iOS Simulator,name=iPhone 16,OS=18.1'
sdk: 'iphonesimulator'
retry_tests: false
- job: e2e_test_native_auth_mac
displayName: 'Run MSAL E2E tests for macOS native auth'
dependsOn: fetch_pr_labels
condition: and( succeeded(), not(contains(dependencies.fetch_pr_labels.outputs['fetchPrLabels.PR_LABELS'], 'skip-native-auth-e2e-tests')) )
timeoutInMinutes: 30
cancelTimeoutInMinutes: 5
pool:
vmImage: 'macOS-14'
workspace:
clean: all
steps:
- template: templates/tests-with-conf-file.yml
parameters:
schema: 'MSAL Mac Native Auth E2E Tests'
full_path: 'build/Build/Products/MSAL Mac Native Auth E2E Tests_MSAL Mac Native Auth E2E Tests_macosx15.1-x86_64.xctestrun'
destination: 'platform=macOS'
sdk: 'macosx'
retry_tests: false
- job: 'Validate_SPM_Integration'
displayName: Validate SPM Integration
pool:
vmImage: 'macOS-14'
timeOutInMinutes: 15
workspace:
clean: all
steps:
- checkout: self
clean: true
submodules: true
fetchDepth: 1
persistCredentials: true
path: s
- script: |
/bin/bash -c "sudo xcode-select -s /Applications/Xcode_15.4.app"
displayName: 'Switch to use Xcode 15.4'
- task: Bash@3
displayName: Set variable BRANCH_NAME to a temporary branch
inputs:
targetType: 'inline'
script: |
BRANCH_NAME_LOCAL="$(Build.SourceBranchName)-temp"
echo "##vso[task.setvariable variable=BRANCH_NAME]${BRANCH_NAME_LOCAL}"
- task: Bash@3
displayName: Checkout to temporary branch
inputs:
targetType: 'inline'
script: |
git checkout -b "${BRANCH_NAME}"
- task: Bash@3
displayName: Run SPM integration test script
inputs:
targetType: 'inline'
script: |
sh spm-integration-test.sh "${BRANCH_NAME}"
continueOnError: false
- task: Bash@3
condition: always()
displayName: Cleanup
inputs:
targetType: 'inline'
script:
cd ../..
rm -rf "$SAMPLE_APP_TEMP_DIR" archive framework MSAL.zip
git checkout -- .
git fetch --quiet
git switch "$(Build.SourceBranchName)"
git branch -D "$BRANCH_NAME"
git push origin --delete "$BRANCH_NAME"