@@ -48,6 +48,11 @@ parameters:
4848 - name : jobNameSuffix
4949 type : string
5050
51+ # True to fail the job when stress tests fail. When false, test failures produce warnings
52+ # (SucceededWithIssues) but do not fail the job.
53+ - name : failOnTestFailure
54+ type : boolean
55+
5156 # The list of .NET Framework runtimes to test against.
5257 - name : netFrameworkTestRuntimes
5358 type : object
@@ -88,10 +93,13 @@ jobs:
8893
8994 variables :
9095
91- # The directory where dotnet artifacts will be staged. Not to be
92- # confused with pipeline artifacts.
93- - name : dotnetArtifactsDir
94- value : $(Build.StagingDirectory)/dotnetArtifacts
96+ # Import the variable group that provides SQL Server build properties used by the
97+ # shared configure-sql-server-*-step.yml templates (e.g. x64AliasRegistryPath,
98+ # x86AliasRegistryPath, SQLAliasName, SQLAliasPort).
99+ - group : ADO Build Properties
100+
101+ # Import the variable group that provides SQL Server test configuration variables.
102+ - group : ADO Test Configuration Properties
95103
96104 # The top-level project file to build and run.
97105 - name : project
@@ -101,7 +109,6 @@ jobs:
101109 - name : dotnetArguments
102110 value : >-
103111 --verbosity ${{ parameters.dotnetVerbosity }}
104- --artifacts-path $(dotnetArtifactsDir)
105112 --configuration ${{ parameters.buildConfiguration }}
106113
107114 # The contents of the config file to use for all tests. We will write this to a JSON file and
@@ -153,6 +160,12 @@ jobs:
153160 # Write the JSON content to the config file.
154161 $content | Out-File -FilePath "config.json"
155162
163+ # Authenticate with NuGet feeds so that upstream packages (e.g. runtime host packs) can be
164+ # fetched through the ADO Artifacts feed. This is required on hosted pool agents (macOS)
165+ # that do not have pre-configured feed credentials.
166+ - task : NuGetAuthenticate@1
167+ displayName : Authenticate NuGet feeds
168+
156169 # Build the project.
157170 - task : DotNetCoreCLI@2
158171 displayName : Build Project
@@ -161,10 +174,31 @@ jobs:
161174 projects : $(project)
162175 arguments : $(dotnetArguments)
163176
177+ # Set a flag so test steps can distinguish a build failure from a test failure.
178+ - pwsh : Write-Host "##vso[task.setvariable variable=buildSucceeded]true"
179+ displayName : Set build success flag
180+
164181 # Run the stress tests for each .NET runtime.
182+ #
183+ # The condition and continueOnError work together to achieve the following behavior:
184+ #
185+ # condition: and(succeededOrFailed(), eq(variables['buildSucceeded'], 'true'))
186+ # - succeededOrFailed() allows the step to run even if a *previous test* step failed,
187+ # ensuring all runtimes are exercised regardless of earlier failures.
188+ # - eq(variables['buildSucceeded'], 'true') gates on the flag set above, so tests are
189+ # skipped entirely if the build or any setup step failed (since there's nothing to run).
190+ #
191+ # continueOnError: ${{ not(parameters.failOnTestFailure) }}
192+ # - When failOnTestFailure is false, continueOnError is true: a test failure marks the
193+ # step and job as SucceededWithIssues (orange warning) rather than Failed.
194+ # - When failOnTestFailure is true, continueOnError is false: a test failure fails the
195+ # job (red), though subsequent runtimes still run due to the condition above.
196+ #
165197 - ${{ each runtime in parameters.netTestRuntimes }} :
166198 - task : DotNetCoreCLI@2
167199 displayName : Test [${{ runtime }}]
200+ condition : and(succeededOrFailed(), eq(variables['buildSucceeded'], 'true'))
201+ continueOnError : ${{ not(parameters.failOnTestFailure) }}
168202 inputs :
169203 command : run
170204 projects : $(project)
@@ -174,6 +208,8 @@ jobs:
174208 - ${{ each runtime in parameters.netFrameworkTestRuntimes }} :
175209 - task : DotNetCoreCLI@2
176210 displayName : Test [${{ runtime }}]
211+ condition : and(succeededOrFailed(), eq(variables['buildSucceeded'], 'true'))
212+ continueOnError : ${{ not(parameters.failOnTestFailure) }}
177213 inputs :
178214 command : run
179215 projects : $(project)
0 commit comments