Skip to content

Commit 12005ac

Browse files
authored
Gate test steps on setup success in CI pipeline (#4141)
1 parent 4c294c6 commit 12005ac

2 files changed

Lines changed: 39 additions & 26 deletions

File tree

eng/pipelines/common/templates/jobs/ci-run-tests-job.yml

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,33 @@ jobs:
326326
${{ if parameters.configProperties.FileStreamDirectory }}:
327327
fileStreamDirectory: ${{ parameters.configProperties.FileStreamDirectory }}
328328

329+
# Set up for x86 tests by manually installing dotnet for x86 to an alternative location. This
330+
# is only used to execute the test runtime (framework to test is specified in build params), so
331+
# it should be acceptable to just install a specific version in all cases.
332+
# @TODO: This setup is very confusing. Ideally we should just be utilizing the dotnet installation
333+
# earlier in the job. There has to be a cleaner way of doing this.
334+
- ${{ if and(eq(parameters.enableX86Test, true), eq(parameters.operatingSystem, 'Windows')) }}:
335+
- ${{ if ne(variables['dotnetx86RootPath'], '') }}:
336+
# Install the .NET SDK and Runtimes for x86.
337+
- template: /eng/pipelines/steps/install-dotnet.yml@self
338+
parameters:
339+
architecture: x86
340+
debug: ${{ parameters.debug }}
341+
installDir: $(dotnetx86RootPath)
342+
runtimes: [8.x, 9.x]
343+
344+
# Ensure TestResults directory exists so that publish steps don't fail when
345+
# tests are skipped due to a setup failure.
346+
- pwsh: New-Item -ItemType Directory -Path TestResults -Force | Out-Null
347+
displayName: 'Create TestResults Directory'
348+
349+
# Gate: record that all setup steps (SDK install, build, SQL config, x86 SDK
350+
# install, etc.) completed successfully. Test steps condition on this variable
351+
# so they are skipped when setup fails, yet remain independent of each
352+
# other's results.
353+
- pwsh: Write-Host '##vso[task.setvariable variable=setupSucceeded]true'
354+
displayName: 'Gate: Mark Setup Succeeded'
355+
329356
- ${{ if eq(parameters.enableX64Test, true) }}: # run native tests
330357
- template: /eng/pipelines/common/templates/steps/run-all-tests-step.yml@self # run tests
331358
parameters:
@@ -340,20 +367,6 @@ jobs:
340367
mdsPackageVersion: ${{ parameters.mdsPackageVersion }}
341368

342369
- ${{ if and(eq(parameters.enableX86Test, true), eq(parameters.operatingSystem, 'Windows')) }}:
343-
# Set up for x86 tests by manually installing dotnet for x86 to an alternative location. This
344-
# is only used to execute the test runtime (framework to test is specified in build params), so
345-
# it should be acceptable to just install a specific version in all cases.
346-
# @TODO: This setup is very confusing. Ideally we should just be utilizing the dotnet installation
347-
# earlier in the job. There has to be a cleaner way of doing this.
348-
- ${{ if ne(variables['dotnetx86RootPath'], '') }}:
349-
# Install the .NET SDK and Runtimes for x86.
350-
- template: /eng/pipelines/steps/install-dotnet.yml@self
351-
parameters:
352-
architecture: x86
353-
debug: ${{ parameters.debug }}
354-
installDir: $(dotnetx86RootPath)
355-
runtimes: [8.x, 9.x]
356-
357370
- template: /eng/pipelines/common/templates/steps/run-all-tests-step.yml@self
358371
parameters:
359372
debug: ${{ parameters.debug }}

eng/pipelines/common/templates/steps/run-all-tests-step.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ steps:
7979
- ${{if eq(parameters.referenceType, 'Project')}}:
8080
- task: MSBuild@1
8181
displayName: 'Run Unit Tests ${{parameters.msbuildArchitecture }}'
82-
condition: succeededOrFailed()
82+
condition: and(eq(variables['setupSucceeded'], 'true'), succeededOrFailed())
8383
inputs:
8484
solution: build2.proj
8585
msbuildArchitecture: ${{parameters.msbuildArchitecture }}
@@ -101,7 +101,7 @@ steps:
101101
102102
- task: MSBuild@1
103103
displayName: 'Run Flaky Unit Tests ${{parameters.msbuildArchitecture }}'
104-
condition: succeededOrFailed()
104+
condition: and(eq(variables['setupSucceeded'], 'true'), succeededOrFailed())
105105
inputs:
106106
solution: build2.proj
107107
msbuildArchitecture: ${{parameters.msbuildArchitecture }}
@@ -128,7 +128,7 @@ steps:
128128

129129
- task: MSBuild@1
130130
displayName: 'Run Functional Tests ${{parameters.msbuildArchitecture }}'
131-
condition: succeededOrFailed()
131+
condition: and(eq(variables['setupSucceeded'], 'true'), succeededOrFailed())
132132
inputs:
133133
solution: build2.proj
134134
msbuildArchitecture: ${{parameters.msbuildArchitecture }}
@@ -155,7 +155,7 @@ steps:
155155
-p:TestResultsFolderPath=TestResults
156156
157157
- task: MSBuild@1
158-
condition: succeededOrFailed()
158+
condition: and(eq(variables['setupSucceeded'], 'true'), succeededOrFailed())
159159
displayName: 'Run Flaky Functional Tests ${{parameters.msbuildArchitecture }}'
160160
inputs:
161161
solution: build2.proj
@@ -188,7 +188,7 @@ steps:
188188
continueOnError: true
189189

190190
- task: MSBuild@1
191-
condition: succeededOrFailed()
191+
condition: and(eq(variables['setupSucceeded'], 'true'), succeededOrFailed())
192192
displayName: 'Run Manual Tests ${{parameters.msbuildArchitecture }}'
193193
inputs:
194194
solution: build2.proj
@@ -219,7 +219,7 @@ steps:
219219
retryCountOnTaskFailure: ${{parameters.retryCountOnManualTests }}
220220

221221
- task: MSBuild@1
222-
condition: succeededOrFailed()
222+
condition: and(eq(variables['setupSucceeded'], 'true'), succeededOrFailed())
223223
displayName: 'Run Flaky Manual Tests ${{parameters.msbuildArchitecture }}'
224224
inputs:
225225
solution: build2.proj
@@ -257,7 +257,7 @@ steps:
257257
- ${{if eq(parameters.referenceType, 'Project')}}:
258258
- task: DotNetCoreCLI@2
259259
displayName: 'Run Unit Tests'
260-
condition: succeededOrFailed()
260+
condition: and(eq(variables['setupSucceeded'], 'true'), succeededOrFailed())
261261
inputs:
262262
command: custom
263263
projects: build2.proj
@@ -276,7 +276,7 @@ steps:
276276

277277
- task: DotNetCoreCLI@2
278278
displayName: 'Run Flaky Unit Tests'
279-
condition: succeededOrFailed()
279+
condition: and(eq(variables['setupSucceeded'], 'true'), succeededOrFailed())
280280
inputs:
281281
command: custom
282282
projects: build2.proj
@@ -298,7 +298,7 @@ steps:
298298

299299
- task: DotNetCoreCLI@2
300300
displayName: 'Run Functional Tests'
301-
condition: succeededOrFailed()
301+
condition: and(eq(variables['setupSucceeded'], 'true'), succeededOrFailed())
302302
inputs:
303303
command: custom
304304
projects: build2.proj
@@ -316,7 +316,7 @@ steps:
316316
verbosityPack: Detailed
317317

318318
- task: DotNetCoreCLI@2
319-
condition: succeededOrFailed()
319+
condition: and(eq(variables['setupSucceeded'], 'true'), succeededOrFailed())
320320
displayName: 'Run Flaky Functional Tests'
321321
inputs:
322322
command: custom
@@ -339,7 +339,7 @@ steps:
339339

340340
- task: DotNetCoreCLI@2
341341
displayName: 'Run Manual Tests'
342-
condition: succeededOrFailed()
342+
condition: and(eq(variables['setupSucceeded'], 'true'), succeededOrFailed())
343343
inputs:
344344
command: custom
345345
projects: build2.proj
@@ -360,7 +360,7 @@ steps:
360360

361361
- task: DotNetCoreCLI@2
362362
displayName: 'Run Flaky Manual Tests'
363-
condition: succeededOrFailed()
363+
condition: and(eq(variables['setupSucceeded'], 'true'), succeededOrFailed())
364364
inputs:
365365
command: custom
366366
projects: build2.proj

0 commit comments

Comments
 (0)