forked from Azure/azure-sdk-for-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlive.tests.yml
More file actions
337 lines (306 loc) · 12.1 KB
/
live.tests.yml
File metadata and controls
337 lines (306 loc) · 12.1 KB
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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
parameters:
- name: Location
type: string
default: ''
- name: ServiceDirectory
type: string
default: not-specified
- name: CtestRegex
type: string
default: .*
- name: Coverage
type: string
default: 'enabled'
- name: CoverageReportPath
type: string
default: sdk/*/*/*cov_xml.xml
- name: TimeoutInMinutes
type: number
default: 120
- name: DependsOn
type: string
default: ''
# Matrix generation:
# https://github.com/Azure/azure-sdk-tools/blob/main/eng/common/scripts/job-matrix/README.md
- name: Matrix
type: string
- name: MaxParallel
type: number
default: 0
- name: CloudConfig
type: object
default: {}
- name: UsePlatformContainer
type: boolean
default: false
- name: PreTestSteps
type: stepList
default: []
- name: PostTestSteps
type: stepList
default: []
- name: OSName
type: string
default: ''
- name: EnvVars
type: object
default: {}
- name: UseFederatedAuth
type: boolean
default: false
jobs:
- job:
displayName: ValidateLive
dependsOn: ${{ parameters.DependsOn }}
condition: and(ne(variables['Skip.LiveTest'], 'true'), ne(${{ parameters.Matrix }}, '{}'))
timeoutInMinutes: ${{ parameters.TimeoutInMinutes }}
pool:
name: $(Pool)
# 1es pipeline templates converts `image` to demands: ImageOverride under the hood
# which is incompatible with image selection in the default non-1es hosted pools
${{ if eq(parameters.OSName, 'macOS') }}:
vmImage: $(OSVmImage)
${{ else }}:
image: $(OSVmImage)
os: ${{ parameters.OSName }}
${{ if eq(parameters.UsePlatformContainer, 'true') }}:
# Add a default so the job doesn't fail when the matrix is empty
container: $[ variables['Container'] ]
strategy:
maxParallel: ${{ parameters.MaxParallel }}
matrix: $[ ${{ parameters.Matrix }} ]
variables:
- template: /eng/pipelines/templates/variables/image.yml@self
- name: CMOCKA_XML_FILE
value: "%g-test-results.xml"
- name: CMOCKA_MESSAGE_OUTPUT
value: "xml"
- name: AZURE_ENABLE_STATIC_ANALYSIS
value: 1
- name: BuildArgs
value: ""
- name: VcpkgArgs
value: ""
- name: WindowsCtestConfig
value: ""
- name: CmakeEnvArg
value: ""
- name: CmakeArgs
value: ""
- name: AZURE_TEST_MODE
value: "LIVE"
- name: AZURE_LOG_LEVEL
value: "verbose"
# Surface the ServiceDirectory parameter as an environment variable so tests can take advantage of it.
- name: AZURE_SERVICE_DIRECTORY
value: ${{ parameters.ServiceDirectory }}
steps:
- checkout: self
submodules: recursive
- template: /eng/common/pipelines/templates/steps/verify-agent-os.yml
parameters:
AgentImage: $(OSVmImage)
- template: /eng/pipelines/templates/steps/fix-1es-image-apt-azure-sources.yml
# Add g++5 repo to ubuntu
- bash: sudo sh -c "echo 'deb http://ftp.debian.org/debian/ stretch main' >> /etc/apt/sources.list"
displayName: Add g++ 5
condition: >-
and(
succeeded(),
contains(variables['OSVmImage'], 'Ubuntu'),
contains(variables['CmakeEnvArg'], 'CC=/usr/bin/gcc-5 CXX=/usr/bin/g++-5 cmake')
)
# Install g++5
- bash: sudo apt-get update & sudo apt-get install g++-5
displayName: Install g++ 5
condition: >-
and(
succeeded(),
contains(variables['OSVmImage'], 'Ubuntu'),
contains(variables['CmakeEnvArg'], 'CC=/usr/bin/gcc-5 CXX=/usr/bin/g++-5 cmake')
)
# Install apt dependencies (if appropriate)
- bash: sudo apt install -y $(AptDependencies)
retryCountOnTaskFailure: 10
condition: and(succeededOrFailed(), ne(variables['AptDependencies'], ''))
displayName: Install dependencies from apt
- template: /eng/pipelines/templates/steps/vcpkg.yml
- script: |
dotnet tool install -g dotnet-reportgenerator-globaltool
dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools
displayName: Install coverage tools
# CODE_COVERAGE variable is '' (do-not-generate) in all matrix but linux-gcc
# It is 'enabled' by default on linux-gcc but it can be opt-out by each pipeline (disabled)
condition: and(succeededOrFailed(), ne(variables['CODE_COVERAGE'], 'disabled'), ne(variables['CODE_COVERAGE'], ''))
- template: /eng/pipelines/templates/steps/cmake-build.yml
parameters:
ServiceDirectory: ${{ parameters.ServiceDirectory }}
GenerateArgs: $(CmakeArgs)
VcpkgArgs: "$(VcpkgArgs)"
BuildArgs: "$(BuildArgs)"
Env: "$(CmakeEnvArg)"
- template: /eng/pipelines/templates/steps/show-failure-logs.yml
- template: /eng/common/TestResources/build-test-resource-config.yml
parameters:
SubscriptionConfiguration: ${{ parameters.CloudConfig.SubscriptionConfiguration }}
SubscriptionConfigurations: ${{ parameters.CloudConfig.SubscriptionConfigurations }}
EnvVars:
Pool: $(Pool)
${{ insert }}: ${{ parameters.EnvVars }}
${{ if parameters.UseFederatedAuth }}:
SubscriptionConfigurationFilePaths: ${{ parameters.CloudConfig.SubscriptionConfigurationFilePaths }}
- template: /eng/common/TestResources/deploy-test-resources.yml
parameters:
ServiceDirectory: ${{ parameters.ServiceDirectory }}
Location: ${{ coalesce(parameters.Location, parameters.CloudConfig.Location) }}
SubscriptionConfiguration: $(SubscriptionConfiguration)
EnvVars:
Pool: $(Pool)
${{ insert }}: ${{ parameters.EnvVars }}
UseFederatedAuth: ${{ parameters.UseFederatedAuth }}
ServiceConnection: ${{ parameters.CloudConfig.ServiceConnection }}
- template: /eng/common/testproxy/test-proxy-tool.yml
parameters:
runProxy: false
- ${{ parameters.PreTestSteps }}
- ${{ if parameters.UseFederatedAuth }}:
- task: AzurePowerShell@5
displayName: ctest
condition: and(succeeded(), ne(variables['RunSamples'], '1'))
inputs:
azureSubscription: ${{ parameters.CloudConfig.ServiceConnection }}
azurePowerShellVersion: LatestVersion
ScriptType: InlineScript
Inline: |
$account = (Get-AzContext).Account
$env:AZURESUBSCRIPTION_CLIENT_ID = $account.Id
$env:AZURESUBSCRIPTION_TENANT_ID = $account.Tenants
ctest $(WindowsCtestConfig) -V --tests-regex "${{ parameters.CtestRegex }}" --no-compress-output -T Test
exit $LASTEXITCODE
workingDirectory: build
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
${{ insert }}: ${{ parameters.EnvVars }}
- ${{ else }}:
# For non multi-config generator use the same build configuration to run tests
# We don't need to set it to invoke ctest
# Visual Studio generator used in CI is a multi-config generator.
# As such, it requires the configuration argument for building and invoking ctest
- bash: |
export AZURE_CLIENT_ID=$(${{parameters.ServiceDirectory}}_CLIENT_ID)
export AZURE_TENANT_ID=$(${{parameters.ServiceDirectory}}_TENANT_ID)
export AZURE_CLIENT_SECRET=$(${{parameters.ServiceDirectory}}_CLIENT_SECRET)
ctest $(WindowsCtestConfig) -V --tests-regex "${{ parameters.CtestRegex }}" --no-compress-output -T Test
workingDirectory: build
displayName: ctest
# Runs only if test-resources are happily deployed.
# unit-tests runs for those configs where samples are not ran.
# This enables to run tests and samples at the same time as different matrix configuration.
# Then unit-tests runs, samples should not run.
condition: and(succeeded(), ne(variables['RunSamples'], '1'))
env:
${{ insert }}: ${{ parameters.EnvVars }}
- ${{ parameters.PostTestSteps }}
- task: PublishTestResults@2
inputs:
testResultsFormat: cTest
testResultsFiles: Testing/*/Test.xml
testRunTitle: $(Agent.JobName)
searchFolder: build
mergeTestResults: true
publishRunAttachments: true
displayName: Publish test results
# this step only makes sense when ctest has run
condition: and(succeededOrFailed(), ne(variables['RunSamples'], '1'))
- ${{ if parameters.UseFederatedAuth }}:
# Running Samples step.
# Will run samples described on a file name [service]-samples.txt within the build directory.
# For example keyvault-samples.txt.
# The file is written by CMake during configuration when building samples.
- task: AzureCLI@2
displayName: "Run Samples with AzureCli for : ${{ parameters.ServiceDirectory }}"
condition: and(succeeded(), eq(variables['RunSamples'], '1'))
inputs:
azureSubscription: ${{ parameters.CloudConfig.ServiceConnection }}
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: |
Write-Host "Where is az CLI located"
(Get-Command az).Path
Write-Host "Check az CLI version"
az --version
Write-Host "Run az account show"
az account show
Write-Host "Run az account list --debug"
az account list --debug
Write-Host "Run az account get-access-token --output none --debug --verbose"
az account get-access-token --output none --debug --verbose
Write-Host "Run env:AZURE_CONFIG_DIR"
$env:AZURE_CONFIG_DIR
Write-Host "Remove env:AZURE_CONFIG_DIR"
$env:AZURE_CONFIG_DIR=''
Write-Host "Run Get-ChildItem env:"
Get-ChildItem env:
if (Test-Path -Path "${{ parameters.ServiceDirectory }}-samples.txt") {
$samples = Get-Content "${{ parameters.ServiceDirectory }}-samples.txt"
foreach ($sample in $samples) {
Write-Host "**********Running sample: $sample"
& "$sample"
if ($LASTEXITCODE) {
Write-Host "Sample failed with exit code $LASTEXITCODE"
exit 1
}
Write-Host "**********Sample completed"
}
}
workingDirectory: build
useGlobalConfig: true
env:
# SYSTEM_ACCESSTOKEN: $(System.AccessToken)
${{ insert }}: ${{ parameters.EnvVars }}
- ${{ else }}:
- bash: |
IFS=$'\n'
if [[ -f "./${{ parameters.ServiceDirectory }}-samples.txt" ]]; then
for sample in `cat ./${{ parameters.ServiceDirectory }}-samples.txt`
do
export AZURE_CLIENT_ID=$(${{parameters.ServiceDirectory}}_CLIENT_ID)
export AZURE_TENANT_ID=$(${{parameters.ServiceDirectory}}_TENANT_ID)
export AZURE_CLIENT_SECRET=$(${{parameters.ServiceDirectory}}_CLIENT_SECRET)
echo "**********Running sample: ${sample}"
bash -c "$sample"
status=$?
if [[ $status -eq 0 ]]; then
echo "*********Sample completed*********"
else
echo "*Sample returned a failed code: $status"
exit 1
fi
done
fi
workingDirectory: build
displayName: "Run Samples for : ${{ parameters.ServiceDirectory }}"
condition: and(succeeded(), eq(variables['RunSamples'], '1'))
env:
${{ insert }}: ${{ parameters.EnvVars }}
# Make coverage targets (specified in coverage_targets.txt) and assemble
# coverage report
- bash: |
make `cat ${{ parameters.ServiceDirectory }}-targets-coverage.txt`
../tools/reportgenerator "-reports:${{ parameters.CoverageReportPath }}" "-targetdir:." "-reporttypes:Cobertura"
workingDirectory: build
displayName: Generate Code Coverage Data
condition: and(succeeded(), ne(variables['CODE_COVERAGE'], 'disabled'), ne(variables['CODE_COVERAGE'], ''))
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/**/Cobertura.xml'
displayName: Publish Code Coverage to DevOps
condition: and(succeededOrFailed(), ne(variables['CODE_COVERAGE'], 'disabled'), ne(variables['CODE_COVERAGE'], ''))
- template: /eng/common/TestResources/remove-test-resources.yml
parameters:
ServiceDirectory: ${{ parameters.ServiceDirectory }}
SubscriptionConfiguration: $(SubscriptionConfiguration)
UseFederatedAuth: ${{ parameters.UseFederatedAuth }}
EnvVars: ${{ parameters.EnvVars }}
ServiceConnection: ${{ parameters.CloudConfig.ServiceConnection }}