-
Notifications
You must be signed in to change notification settings - Fork 329
Expand file tree
/
Copy pathtest-azure-package-ci-job.yml
More file actions
386 lines (336 loc) · 13.6 KB
/
test-azure-package-ci-job.yml
File metadata and controls
386 lines (336 loc) · 13.6 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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
################################################################################
# Licensed to the .NET Foundation under one or more agreements. The .NET
# Foundation licenses this file to you under the MIT license. See the LICENSE
# file in the project root for more information.
################################################################################
# This job builds the Azure package and runs its tests for a set of .NET
# runtimes.
#
# This template defines a job named 'test_azure_package_job_<jobNameSuffix>'
# that can be depended on by downstream jobs.
parameters:
# The name of the Abstractions pipeline artifacts to download.
#
# This is used when the referenceType is 'Package'.
- name: abstractionsArtifactsName
type: string
default: Abstractions.Artifacts
# The name of the Logging pipeline artifacts to download.
#
# This is used when the referenceType is 'Package'.
- name: loggingArtifactsName
type: string
default: Logging.Artifacts
# The Logging package version to depend on.
#
# This is used when the referenceType is 'Package'.
- name: loggingPackageVersion
type: string
default: ''
# The Abstractions package verion to depend on.
#
# This is used when the referenceType is 'Package'.
- name: abstractionsPackageVersion
type: string
# The type of build to test (Release or Debug)
- name: buildConfiguration
type: string
values:
- Release
- Debug
# True to emit debug information and steps.
- name: debug
type: boolean
default: false
# The prefix to prepend to the job's display name:
#
# [<prefix>] Test Azure Package
#
- name: displayNamePrefix
type: string
# The verbosity level for the dotnet CLI commands.
- name: dotnetVerbosity
type: string
default: normal
values:
- quiet
- minimal
- normal
- detailed
- diagnostic
# The suffix to append to the job name.
- name: jobNameSuffix
type: string
# The name of the MDS pipeline artifacts to download.
#
# This is used when the referenceType is 'Package'.
- name: mdsArtifactsName
type: string
default: MDS.Artifacts
# The MDS package verion to depend on.
#
# This is used when the referenceType is 'Package'.
- name: mdsPackageVersion
type: string
# The name of the SqlServer pipeline artifacts to download.
#
# This is used when the referenceType is 'Package'. MDS depends on
# SqlServer.Server, so the package must be available for transitive restore.
- name: sqlServerArtifactsName
type: string
default: SqlServer.Artifacts
# The SqlServer package version to depend on.
#
# This is used when the referenceType is 'Package'.
- name: sqlServerPackageVersion
type: string
default: ''
# The list of .NET Framework runtimes to test against.
- name: netFrameworkRuntimes
type: object
default: []
# The list of .NET runtimes to test against.
- name: netRuntimes
type: object
default: []
# The name of the Azure Pipelines pool to use.
- name: poolName
type: string
# The C# project reference type to use when building and packing the packages.
- name: referenceType
type: string
values:
# Reference sibling packages as NuGet packages.
- Package
# Reference sibling packages as C# projects.
- Project
# The SA password set by the sqlServerSetupSteps, if relevant.
- name: saPassword
type: string
default: ''
# Steps to run, if any, to configure a local SQL Server instance on the agent
# VM.
- name: sqlServerSetupSteps
type: stepList
default: []
# True if the VM image includes a local SQL Server that supports connections
# via integrated security.
- name: supportsIntegratedSecurity
type: boolean
default: false
# The pool VM image to use.
- name: vmImage
type: string
jobs:
- job: test_azure_package_job_${{ parameters.jobNameSuffix }}
displayName: '[${{ parameters.displayNamePrefix }}] Test Azure Package'
pool:
name: ${{ parameters.poolName }}
# Images provided by Azure Pipelines must be selected using 'vmImage'.
${{ if eq(parameters.poolName, 'Azure Pipelines') }}:
vmImage: ${{ parameters.vmImage }}
# Images provided by 1ES must be selected using a demand.
${{ else }}:
demands:
- imageOverride -equals ${{ parameters.vmImage }}
variables:
# The Azure test project file to use for all dotnet CLI commands.
#
# Building this project implicitly builds the Azure project.
- name: project
value: src/Microsoft.Data.SqlClient.Extensions/Azure/test/Azure.Test.csproj
# dotnet CLI arguments for build/test/pack commands.
- name: buildArguments
value: >-
-p:Configuration=${{ parameters.buildConfiguration }}
--verbosity ${{ parameters.dotnetVerbosity }}
-p:ReferenceType=${{ parameters.referenceType }}
-p:AbstractionsPackageVersion=${{ parameters.abstractionsPackageVersion }}
-p:LoggingPackageVersion=${{ parameters.loggingPackageVersion }}
-p:SqlClientPackageVersion=${{ parameters.mdsPackageVersion }}
-p:SqlServerPackageVersion=${{ parameters.sqlServerPackageVersion }}
# Explicitly unset the $PLATFORM environment variable that is set by the
# 'ADO Build properties' Library in the ADO SqlClientDrivers public
# project. This is defined with a non-standard Platform of 'AnyCPU', and
# will fail the builds if left defined.
#
# Note that Azure Pipelines will inject this variable as PLATFORM into the
# environment of all tasks in this job.
#
# See:
# https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch
#
- name: Platform
value: ''
# Do the same for $CONFIGURATION since we explicitly set it using our
# 'buildConfiguration' parameter, and we don't want the environment to
# override us.
- name: Configuration
value: ''
steps:
# Emit environment variables if debug is enabled.
- ${{ if eq(parameters.debug, true) }}:
- pwsh: 'Get-ChildItem Env: | Sort-Object Name'
displayName: '[Debug] Print Environment Variables'
# We have a few extra steps for Package reference builds.
- ${{ if eq(parameters.referenceType, 'Package') }}:
# Download the Abstractions package artifacts into packages/.
- task: DownloadPipelineArtifact@2
displayName: Download Abstractions Package Artifacts
inputs:
artifactName: ${{ parameters.abstractionsArtifactsName }}
targetPath: $(Build.SourcesDirectory)/packages
# Download the Logging package artifacts into packages/.
- task: DownloadPipelineArtifact@2
displayName: Download Logging Package Artifacts
inputs:
artifactName: ${{ parameters.loggingArtifactsName }}
targetPath: $(Build.SourcesDirectory)/packages
# Download the MDS package artifacts into packages/.
#
# The Azure project doesn't depend on MDS, but the test project does.
- task: DownloadPipelineArtifact@2
displayName: Download MDS Package Artifacts
inputs:
artifactName: ${{ parameters.mdsArtifactsName }}
targetPath: $(Build.SourcesDirectory)/packages
# Download the SqlServer package artifacts into packages/.
#
# MDS depends on SqlServer.Server, so the package must be available for
# transitive restore.
- task: DownloadPipelineArtifact@2
displayName: Download SqlServer Package Artifacts
inputs:
artifactName: ${{ parameters.sqlServerArtifactsName }}
targetPath: $(Build.SourcesDirectory)/packages
# Install the .NET SDK and Runtimes.
- template: /eng/pipelines/steps/install-dotnet.yml@self
parameters:
debug: ${{ parameters.debug }}
runtimes: [8.x, 9.x]
# The Windows agent images include a suitable .NET Framework runtime, so
# we don't have to install one explicitly.
# Setup the test config file.
#
# This must be done before building the project. This template updates
# the sample config file, which is then copied into place by the build.
#
- template: /eng/pipelines/common/templates/steps/update-config-file-step.yml@self
parameters:
debug: ${{ parameters.debug }}
saPassword: ${{ parameters.saPassword }}
# The config.jsonc file has many options, but only some of them are
# used by the Azure package tests. We only specify the ones that are
# necessary here.
AADServicePrincipalId: $(AADServicePrincipalId)
AzureKeyVaultTenantId: $(AzureKeyVaultTenantId)
# macOS doesn't support managed identities.
ManagedIdentitySupported: ${{ not(eq(parameters.vmImage, 'macos-latest')) }}
SupportsIntegratedSecurity: ${{ parameters.supportsIntegratedSecurity }}
TCPConnectionString: $(AZURE_DB_TCP_CONN_STRING)
UserManagedIdentityClientId: $(UserManagedIdentityClientId)
WorkloadIdentityFederationServiceConnectionId: $(WorkloadIdentityFederationServiceConnectionId)
# Avoid exposing secrets to pipeline jobs triggered via forks. This
# prevents external contributors from creating PRs and running
# pipelines that could expose these secrets.
${{ if eq(variables['System.PullRequest.IsFork'], 'False') }}:
AADPasswordConnectionString: $(AAD_PASSWORD_CONN_STR)
AADServicePrincipalSecret: $(AADServicePrincipalSecret)
# Perform any local SQL Server setup.
- ${{ parameters.sqlServerSetupSteps }}
# Build the project.
- task: DotNetCoreCLI@2
displayName: Build Project
inputs:
command: build
projects: $(project)
arguments: $(buildArguments)
# List the DLLs in the output directory for debugging purposes.
- ${{ if eq(parameters.debug, true) }}:
- pwsh: >-
Get-ChildItem
-Path "src/Microsoft.Data.SqlClient.Extensions/Azure/test/bin/${{ parameters.buildConfiguration }}"
-Recurse
displayName: '[Debug] List Output DLLs'
# Run the tests for each .NET runtime.
- ${{ each runtime in parameters.netRuntimes }}:
- task: DotNetCoreCLI@2
displayName: Test [${{ runtime }}]
env:
# Many of our tests require access to Azure resources that are
# currently only granted by agents running our custom ADO 1ES
# images in our ADO pools.
${{ if ne(parameters.poolName, 'Azure Pipelines') }}:
ADO_POOL: 1
# When using connectedServiceName below, the DotNetCoreCLI task
# needs the system access token to be injected as this environment
# variable.
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
${{ if eq(parameters.debug, true) }}:
TEST_DEBUG_EMIT: 1
inputs:
# The tests need to access Azure resources, which is achieved via
# this service connection. See:
#
# https://sqlclientdrivers.visualstudio.com/public/_settings/adminservices?resourceId=ec9623b2-829c-497f-ae1f-7461766f9a9c
connectedServiceName: dotnetMSI-managed-identity
command: test
projects: $(project)
arguments: >-
$(buildArguments)
--no-build
-f ${{ runtime }}
--filter "category != failing & category != flaky & category != interactive"
- task: DotNetCoreCLI@2
displayName: Test Flaky [${{ runtime }}]
env:
${{ if ne(parameters.poolName, 'Azure Pipelines') }}:
ADO_POOL: 1
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
${{ if eq(parameters.debug, true) }}:
TEST_DEBUG_EMIT: 1
inputs:
connectedServiceName: dotnetMSI-managed-identity
command: test
projects: $(project)
arguments: >-
$(buildArguments)
--no-build
-f ${{ runtime }}
--filter "category = flaky"
# Run the tests for each .NET Framework runtime.
- ${{ each runtime in parameters.netFrameworkRuntimes }}:
- task: DotNetCoreCLI@2
displayName: Test [${{ runtime }}]
env:
${{ if ne(parameters.poolName, 'Azure Pipelines') }}:
ADO_POOL: 1
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
${{ if eq(parameters.debug, true) }}:
TEST_DEBUG_EMIT: 1
inputs:
connectedServiceName: dotnetMSI-managed-identity
command: test
projects: $(project)
arguments: >-
$(buildArguments)
--no-build
-f ${{ runtime }}
--filter "category != failing & category != flaky & category != interactive"
- task: DotNetCoreCLI@2
displayName: Test Flaky [${{ runtime }}]
env:
${{ if ne(parameters.poolName, 'Azure Pipelines') }}:
ADO_POOL: 1
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
${{ if eq(parameters.debug, true) }}:
TEST_DEBUG_EMIT: 1
inputs:
connectedServiceName: dotnetMSI-managed-identity
command: test
projects: $(project)
arguments: >-
$(buildArguments)
--no-build
-f ${{ runtime }}
--filter "category = flaky"