From bcc4dd6b0a0a62870a180493a710fc086f11c634 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Sat, 27 Jan 2024 19:52:59 -0500 Subject: [PATCH 01/11] [tests] Add support for running tests on helix With this PR, tests will be run in two steps on CI: 1. On the build machine - which is the same as they are run currently. This will be run in a single step, from the source repo with built `artifacts`. 2. On helix - for this the tests are archived to a `.zip` file, and then sent to helix with any dependencies. Additionally, tests can be marked to always be run on helix or the build machine. Other tests can be run on either. - a new property `$(DefaultToRunningTestsOnHelix)` when true would run all the tests that are not build-machine-only to run on helix. - when the property is !true, all the tests that can run build-machine will run there. This is the default. This adds new properties that affect CI builds: - `$(IsTestSupportProject)` - which is for a project that should be run as a test project itself. - `$(IsHelixOnlyTestProject)` - such a test can only be run on helix. - `$(IsNonHelixOnlyTestProject)` - such a project must always run on the build machine, IOW, with the source repo. - Also, a default `.runsettings` file is used to allow easier setting of loggers, and other configuration for the tests. --- Directory.Build.props | 1 + .../Aspire.Components.Common.Tests.csproj | 1 + .../Aspire.Dashboard.Tests/Directory.Build.props | 8 ++++++++ tests/Aspire.Hosting.Tests/Directory.Build.props | 3 +++ tests/Directory.Build.props | 10 ++++++++++ tests/Directory.Build.targets | 16 ++++++++++++++++ tests/testproject/Directory.Build.props | 7 +++++++ 7 files changed, 46 insertions(+) create mode 100644 tests/Aspire.Dashboard.Tests/Directory.Build.props create mode 100644 tests/Directory.Build.targets create mode 100644 tests/testproject/Directory.Build.props diff --git a/Directory.Build.props b/Directory.Build.props index bc1df40eba..674e87b5b7 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -37,6 +37,7 @@ amd64 $(NuGetPackageRoot)microsoft.developercontrolplane.$(BuildOs)-$(BuildArch)/$(MicrosoftDeveloperControlPlanedarwinamd64PackageVersion)/tools/ + $([MSBuild]::NormalizeDirectory($(ArtifactsDir), 'helix', 'tests')) $(MSBuildThisFileDirectory)/artifacts/bin/Aspire.Dashboard/$(Configuration)/net8.0/ diff --git a/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj b/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj index ba590719f6..3302f81107 100644 --- a/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj +++ b/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj @@ -2,6 +2,7 @@ $(NetCurrent) + true diff --git a/tests/Aspire.Dashboard.Tests/Directory.Build.props b/tests/Aspire.Dashboard.Tests/Directory.Build.props new file mode 100644 index 0000000000..952039cc77 --- /dev/null +++ b/tests/Aspire.Dashboard.Tests/Directory.Build.props @@ -0,0 +1,8 @@ + + + + true + + + + diff --git a/tests/Aspire.Hosting.Tests/Directory.Build.props b/tests/Aspire.Hosting.Tests/Directory.Build.props index 5d2b9d076c..f20dd79904 100644 --- a/tests/Aspire.Hosting.Tests/Directory.Build.props +++ b/tests/Aspire.Hosting.Tests/Directory.Build.props @@ -1,4 +1,7 @@ + + true + diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index 68bd3e65b6..a4646d16ad 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -10,6 +10,16 @@ CS1712: Type parameter 'type_parameter' has no matching typeparam tag in the XML comment on 'type_or_member' (but other type parameters do) --> $(NoWarn);1573;1591;1712 + + false + false + true + + true + + true diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets new file mode 100644 index 0000000000..a2800fee0c --- /dev/null +++ b/tests/Directory.Build.targets @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + diff --git a/tests/testproject/Directory.Build.props b/tests/testproject/Directory.Build.props new file mode 100644 index 0000000000..4922346540 --- /dev/null +++ b/tests/testproject/Directory.Build.props @@ -0,0 +1,7 @@ + + + true + + + + From a906d21eac8375c564b75ad4c9a1a2bd43d46e73 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Sat, 27 Jan 2024 20:02:59 -0500 Subject: [PATCH 02/11] [tests] Add the CI side of support for running tests on helix All the tests will still continue to use dotnet-coverage. But since tests can run on more than one machine now, there is an additional CI step that merges all the coverage xml files. --- Directory.Build.targets | 1 - eng/pipelines/azure-pipelines.yml | 4 +- eng/pipelines/templates/BuildAndTest.yml | 42 +++++++++- eng/pipelines/templates/send-to-helix.yml | 94 +++++++++++++++++++++++ eng/testing/.runsettings | 23 ++++++ tests/send-to-helix.proj | 92 ++++++++++++++++++++++ 6 files changed, 251 insertions(+), 5 deletions(-) create mode 100644 eng/pipelines/templates/send-to-helix.yml create mode 100644 eng/testing/.runsettings create mode 100644 tests/send-to-helix.proj diff --git a/Directory.Build.targets b/Directory.Build.targets index e2c9aa3192..6964a8a316 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -22,5 +22,4 @@ - diff --git a/eng/pipelines/azure-pipelines.yml b/eng/pipelines/azure-pipelines.yml index e2609376bd..cef0af5726 100644 --- a/eng/pipelines/azure-pipelines.yml +++ b/eng/pipelines/azure-pipelines.yml @@ -126,6 +126,7 @@ stages: buildConfig: $(_BuildConfig) repoLogPath: $(Build.Arcade.LogsPath) repoTestResultsPath: $(Build.Arcade.TestResultsPath) + defaultToRunningTestsOnHelix: false isWindows: true @@ -159,6 +160,7 @@ stages: buildConfig: $(_BuildConfig) repoLogPath: $(Build.Arcade.LogsPath) repoTestResultsPath: $(Build.Arcade.TestResultsPath) + defaultToRunningTestsOnHelix: false isWindows: false @@ -167,7 +169,7 @@ stages: # ---------------------------------------------------------------- - stage: codecoverage displayName: CodeCoverage - dependsOn: + dependsOn: - build condition: succeeded('build') variables: diff --git a/eng/pipelines/templates/BuildAndTest.yml b/eng/pipelines/templates/BuildAndTest.yml index 04d1b72485..8c053f6a44 100644 --- a/eng/pipelines/templates/BuildAndTest.yml +++ b/eng/pipelines/templates/BuildAndTest.yml @@ -17,11 +17,16 @@ parameters: - name: skipTests type: boolean default: false + - name: defaultToRunningTestsOnHelix + type: boolean + default: true steps: - script: ${{ parameters.buildScript }} -restore -build -configuration ${{ parameters.buildConfig }} + /p:ArchiveTests=true + /p:DefaultToRunningTestsOnHelix=${{ parameters.defaultToRunningTestsOnHelix }} /bl:${{ parameters.repoLogPath }}/build.binlog $(_OfficialBuildIdArgs) displayName: Build @@ -29,9 +34,40 @@ steps: - ${{ if ne(parameters.skipTests, 'true') }}: - script: ${{ parameters.dotnetScript }} dotnet-coverage collect --settings $(Build.SourcesDirectory)/eng/CodeCoverage.config - --output ${{ parameters.repoTestResultsPath }}/$(Agent.Os)_$(Agent.JobName).cobertura.xml - "${{ parameters.buildScript }} -test -configuration ${{ parameters.buildConfig }} /bl:${{ parameters.repoLogPath }}/tests.binlog $(_OfficialBuildIdArgs)" - displayName: Run tests + --output ${{ parameters.repoTestResultsPath }}/NonHelixTests.cobertura.xml + "${{ parameters.buildScript }} -testnobuild -test -configuration ${{ parameters.buildConfig }} /bl:${{ parameters.repoLogPath }}/tests.binlog /p:DefaultToRunningTestsOnHelix=${{ parameters.defaultToRunningTestsOnHelix }} $(_OfficialBuildIdArgs)" + displayName: Run non-helix tests + + - template: /eng/pipelines/templates/send-to-helix.yml + parameters: + HelixProjectPath: '$(Build.SourcesDirectory)/tests/send-to-helix.proj' + HelixProjectArguments: /p:RunWithCodeCoverage=true /p:RepoTestResultsPath=${{ parameters.repoTestResultsPath }} + + ${{ if eq(parameters.isWindows, 'true') }}: + HelixTargetQueues: Windows.11.Amd64.Client.Open + ${{ if ne(parameters.isWindows, 'true') }}: + HelixTargetQueues: Ubuntu.2204.Amd64.Open + + IsWindows: ${{ parameters.isWindows }} + Creator: $(Build.DefinitionName) + HelixBuild: $(Build.BuildNumber) + HelixAccessToken: $(HelixApiAccessToken) + + - ${{ if eq(parameters.isWindows, 'true') }}: + - pwsh: | + $_cov_filelist=$((Get-ChildItem -Path ${{ parameters.repoTestResultsPath }} -Recurse -Filter *.cobertura.xml -File | % { $_.FullName }) -join ' ') + echo "${{ parameters.dotnetScript }} dotnet-coverage merge $_cov_filelist -f cobertura -o ${{ parameters.repoTestResultsPath }}/$(Agent.Os)_$(Agent.JobName).cobertura.xml" > merge-cov.cmd + cmd /c merge-cov.cmd + rm merge-cov.cmd + displayName: Merge code coverage results + + - ${{ if ne(parameters.isWindows, 'true') }}: + - script: ${{ parameters.dotnetScript }} dotnet-coverage + merge + `find ${{ parameters.repoTestResultsPath }} -name '*.cobertura.xml' -print0 | xargs -0` + -f cobertura + -o '${{ parameters.repoTestResultsPath }}/$(Agent.Os)_$(Agent.JobName).cobertura.xml' + displayName: Merge code coverage results - task: PublishBuildArtifacts@1 inputs: diff --git a/eng/pipelines/templates/send-to-helix.yml b/eng/pipelines/templates/send-to-helix.yml new file mode 100644 index 0000000000..da90ed942c --- /dev/null +++ b/eng/pipelines/templates/send-to-helix.yml @@ -0,0 +1,94 @@ +# Please remember to update the documentation if you make changes to these parameters! +parameters: + HelixSource: 'pr/default' # required -- sources must start with pr/, official/, prodcon/, or agent/ + HelixType: 'tests/default/' # required -- Helix telemetry which identifies what type of data this is; should include "test" for clarity and must end in '/' + HelixBuild: $(Build.BuildNumber) # required -- the build number Helix will use to identify this -- automatically set to the AzDO build number + HelixTargetQueues: '' # required -- semicolon-delimited list of Helix queues to test on; see https://helix.dot.net/ for a list of queues + HelixAccessToken: '' # required -- access token to make Helix API requests; should be provided by the appropriate variable group + HelixProjectPath: '' # required -- path to the project file to build + HelixProjectArguments: '' # optional -- arguments passed to the build command + HelixConfiguration: '' # optional -- additional property attached to a job + HelixPreCommands: '' # optional -- commands to run before Helix work item execution + HelixPostCommands: '' # optional -- commands to run after Helix work item execution + WorkItemDirectory: '' # optional -- a payload directory to zip up and send to Helix; requires WorkItemCommand; incompatible with XUnitProjects + WorkItemCommand: '' # optional -- a command to execute on the payload; requires WorkItemDirectory; incompatible with XUnitProjects + WorkItemTimeout: '' # optional -- a timeout in TimeSpan.Parse-ready value (e.g. 00:02:00) for the work item command; requires WorkItemDirectory; incompatible with XUnitProjects + CorrelationPayloadDirectory: '' # optional -- a directory to zip up and send to Helix as a correlation payload + XUnitProjects: '' # optional -- semicolon-delimited list of XUnitProjects to parse and send to Helix; requires XUnitRuntimeTargetFramework, XUnitPublishTargetFramework, XUnitRunnerVersion, and IncludeDotNetCli=true + XUnitWorkItemTimeout: '' # optional -- the workitem timeout in seconds for all workitems created from the xUnit projects specified by XUnitProjects + XUnitPublishTargetFramework: '' # optional -- framework to use to publish your xUnit projects + XUnitRuntimeTargetFramework: '' # optional -- framework to use for the xUnit console runner + XUnitRunnerVersion: '' # optional -- version of the xUnit nuget package you wish to use on Helix; required for XUnitProjects + IncludeDotNetCli: false # optional -- true will download a version of the .NET CLI onto the Helix machine as a correlation payload; requires DotNetCliPackageType and DotNetCliVersion + DotNetCliPackageType: '' # optional -- either 'sdk', 'runtime' or 'aspnetcore-runtime'; determines whether the sdk or runtime will be sent to Helix; see https://raw.githubusercontent.com/dotnet/core/main/release-notes/releases-index.json + DotNetCliVersion: '' # optional -- version of the CLI to send to Helix; based on this: https://raw.githubusercontent.com/dotnet/core/main/release-notes/releases-index.json + WaitForWorkItemCompletion: true # optional -- true will make the task wait until work items have been completed and fail the build if work items fail. False is "fire and forget." + IsExternal: false # [DEPRECATED] -- doesn't do anything, jobs are external if HelixAccessToken is empty and Creator is set + HelixBaseUri: 'https://helix.dot.net/' # optional -- sets the Helix API base URI (allows targeting https://helix.int-dot.net ) + Creator: '' # optional -- if the build is external, use this to specify who is sending the job + DisplayNamePrefix: 'Run Tests on helix' # optional -- rename the beginning of the displayName of the steps in AzDO + IsWindows: false + condition: succeeded() # optional -- condition for step to execute; defaults to succeeded() + continueOnError: false # optional -- determines whether to continue the build if the step errors; defaults to false + +steps: + - ${{ if and(parameters.condition, eq(parameters.IsWindows, 'true')) }}: + - powershell: 'powershell "$env:BUILD_SOURCESDIRECTORY\eng\common\msbuild.ps1 ${{ parameters.HelixProjectPath }} ${{ parameters.HelixProjectArguments }} /restore /p:TreatWarningsAsErrors=false /t:Test /bl:$env:BUILD_SOURCESDIRECTORY\artifacts\log\$env:BuildConfig\SendToHelix.binlog"' + displayName: ${{ parameters.DisplayNamePrefix }} + env: + BuildConfig: $(_BuildConfig) + HelixSource: ${{ parameters.HelixSource }} + HelixType: ${{ parameters.HelixType }} + HelixBuild: ${{ parameters.HelixBuild }} + HelixConfiguration: ${{ parameters.HelixConfiguration }} + HelixTargetQueues: ${{ parameters.HelixTargetQueues }} + HelixAccessToken: ${{ parameters.HelixAccessToken }} + HelixPreCommands: ${{ parameters.HelixPreCommands }} + HelixPostCommands: ${{ parameters.HelixPostCommands }} + WorkItemDirectory: ${{ parameters.WorkItemDirectory }} + WorkItemCommand: ${{ parameters.WorkItemCommand }} + WorkItemTimeout: ${{ parameters.WorkItemTimeout }} + CorrelationPayloadDirectory: ${{ parameters.CorrelationPayloadDirectory }} + XUnitProjects: ${{ parameters.XUnitProjects }} + XUnitWorkItemTimeout: ${{ parameters.XUnitWorkItemTimeout }} + XUnitPublishTargetFramework: ${{ parameters.XUnitPublishTargetFramework }} + XUnitRuntimeTargetFramework: ${{ parameters.XUnitRuntimeTargetFramework }} + XUnitRunnerVersion: ${{ parameters.XUnitRunnerVersion }} + IncludeDotNetCli: ${{ parameters.IncludeDotNetCli }} + DotNetCliPackageType: ${{ parameters.DotNetCliPackageType }} + DotNetCliVersion: ${{ parameters.DotNetCliVersion }} + WaitForWorkItemCompletion: ${{ parameters.WaitForWorkItemCompletion }} + HelixBaseUri: ${{ parameters.HelixBaseUri }} + Creator: ${{ parameters.Creator }} + SYSTEM_ACCESSTOKEN: $(System.AccessToken) + continueOnError: ${{ parameters.continueOnError }} + - ${{ if and(parameters.condition, ne(parameters.IsWindows, 'true')) }}: + - script: $BUILD_SOURCESDIRECTORY/eng/common/msbuild.sh ${{ parameters.HelixProjectPath }} ${{ parameters.HelixProjectArguments }} /restore /p:TreatWarningsAsErrors=false /t:Test /bl:$BUILD_SOURCESDIRECTORY/artifacts/log/$BuildConfig/SendToHelix.binlog + displayName: ${{ parameters.DisplayNamePrefix }} + env: + BuildConfig: $(_BuildConfig) + HelixSource: ${{ parameters.HelixSource }} + HelixType: ${{ parameters.HelixType }} + HelixBuild: ${{ parameters.HelixBuild }} + HelixConfiguration: ${{ parameters.HelixConfiguration }} + HelixTargetQueues: ${{ parameters.HelixTargetQueues }} + HelixAccessToken: ${{ parameters.HelixAccessToken }} + HelixPreCommands: ${{ parameters.HelixPreCommands }} + HelixPostCommands: ${{ parameters.HelixPostCommands }} + WorkItemDirectory: ${{ parameters.WorkItemDirectory }} + WorkItemCommand: ${{ parameters.WorkItemCommand }} + WorkItemTimeout: ${{ parameters.WorkItemTimeout }} + CorrelationPayloadDirectory: ${{ parameters.CorrelationPayloadDirectory }} + XUnitProjects: ${{ parameters.XUnitProjects }} + XUnitWorkItemTimeout: ${{ parameters.XUnitWorkItemTimeout }} + XUnitPublishTargetFramework: ${{ parameters.XUnitPublishTargetFramework }} + XUnitRuntimeTargetFramework: ${{ parameters.XUnitRuntimeTargetFramework }} + XUnitRunnerVersion: ${{ parameters.XUnitRunnerVersion }} + IncludeDotNetCli: ${{ parameters.IncludeDotNetCli }} + DotNetCliPackageType: ${{ parameters.DotNetCliPackageType }} + DotNetCliVersion: ${{ parameters.DotNetCliVersion }} + WaitForWorkItemCompletion: ${{ parameters.WaitForWorkItemCompletion }} + HelixBaseUri: ${{ parameters.HelixBaseUri }} + Creator: ${{ parameters.Creator }} + SYSTEM_ACCESSTOKEN: $(System.AccessToken) + continueOnError: ${{ parameters.continueOnError }} diff --git a/eng/testing/.runsettings b/eng/testing/.runsettings new file mode 100644 index 0000000000..578840a73a --- /dev/null +++ b/eng/testing/.runsettings @@ -0,0 +1,23 @@ + + + + + 300000 + + category!=failing + + + + + + TestResults.trx + + + + + normal + + + + + diff --git a/tests/send-to-helix.proj b/tests/send-to-helix.proj new file mode 100644 index 0000000000..89eb139700 --- /dev/null +++ b/tests/send-to-helix.proj @@ -0,0 +1,92 @@ + + + + msbuild + + <_workItemTimeout>00:20:00 + $(TestArchiveTestsDir)**/*.zip + + true + sdk + + $([System.IO.File]::ReadAllText('$(RepoRoot)global.json')) + $([System.Text.RegularExpressions.Regex]::Match($(GlobalJsonContent), '(%3F<="dotnet": ").*(%3F=")')) + + 17.9.3 + + + + <_SupportDataStagingDir>$([MSBuild]::NormalizeDirectory($(ArtifactsDir), 'helix', 'support-data')) + <_HelixLogsPath Condition="'$(OS)' != 'Windows_NT'">$HELIX_WORKITEM_UPLOAD_ROOT/logs + <_HelixLogsPath Condition="'$(OS)' == 'Windows_NT'">%HELIX_WORKITEM_UPLOAD_ROOT%/logs + + <_HelixCorrelationPayloadEnvVar Condition="'$(OS)' != 'Windows_NT'">$HELIX_CORRELATION_PAYLOAD + <_HelixCorrelationPayloadEnvVar Condition="'$(OS)' == 'Windows_NT'">%HELIX_CORRELATION_PAYLOAD% + + <_TestNameEnvVar Condition="'$(OS)' != 'Windows_NT'">$TEST_NAME + <_TestNameEnvVar Condition="'$(OS)' == 'Windows_NT'">%TEST_NAME% + + + + <_TestCoverageCommand Include="$(_HelixCorrelationPayloadEnvVar)/dotnet-coverage/dotnet-coverage collect" /> + <_TestCoverageCommand Include="--settings $(_HelixCorrelationPayloadEnvVar)/support-data/CodeCoverage.config" /> + <_TestCoverageCommand Include="--output $(_HelixLogsPath)/Tests.cobertura.xml" /> + + <_TestRunCommandArguments Include="dotnet test" /> + <_TestRunCommandArguments Include="-s .runsettings" /> + <_TestRunCommandArguments Include="$(_TestNameEnvVar).dll" /> + <_TestRunCommandArguments Include="--ResultsDirectory:$(_HelixLogsPath)" /> + + + + + + + $(RepoTestResultsPath) + + <_TestRunCommand Condition="'$(RunWithCodeCoverage)' == 'true'">@(_TestCoverageCommand, ' ') "@(_TestRunCommandArguments, ' ')" + <_TestRunCommand Condition="'$(RunWithCodeCoverage)' != 'true'">@(_TestRunCommandArguments, ' ') + + + + + + <_DefaultWorkItems Include="$(WorkItemArchiveWildCard)" /> + + + %(Identity) + set "TEST_NAME=%(FileName)" + export "TEST_NAME=%(FileName)" + $(_TestRunCommand) + $(_workItemTimeout) + + + logs/Tests.cobertura.xml + + + + + + + + + + + + + + + + + + + + + + + From f3fdac2fe17114aac85fdbf7ace89f8bd99faa44 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Mon, 29 Jan 2024 17:42:55 -0500 Subject: [PATCH 03/11] send-to-helix.proj: extract dotnet-coverage version from dotnet-tools.json --- tests/send-to-helix.proj | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/send-to-helix.proj b/tests/send-to-helix.proj index 89eb139700..1f7b3ecf40 100644 --- a/tests/send-to-helix.proj +++ b/tests/send-to-helix.proj @@ -11,8 +11,6 @@ $([System.IO.File]::ReadAllText('$(RepoRoot)global.json')) $([System.Text.RegularExpressions.Regex]::Match($(GlobalJsonContent), '(%3F<="dotnet": ").*(%3F=")')) - - 17.9.3 @@ -73,9 +71,20 @@ + + <_DotNetToolJsonPath>$(RepoRoot).config/dotnet-tools.json + <_DotNetToolJsonContent>$([System.IO.File]::ReadAllText($(_DotNetToolJsonPath))) + <_DotNetCoverageVersionRegex>(?:"dotnet-coverage": *{.*?"version": *")([^"]*?)(?:") + <_DotNetCoverageToolVersion>$([System.Text.RegularExpressions.Regex]::Match($(_DotNetToolJsonContent), '$(_DotNetCoverageVersionRegex)', 'System.Text.RegularExpressions.RegexOptions.Singleline').Groups[1].Value) + + + + + From af66351ffdc187cb707c242be1f30953d9e2d0d9 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 30 Jan 2024 13:30:29 -0500 Subject: [PATCH 04/11] CI: Increase timeout from 30->45mins, to account for helix waiting on agents --- eng/pipelines/azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/pipelines/azure-pipelines.yml b/eng/pipelines/azure-pipelines.yml index cef0af5726..5d133301e2 100644 --- a/eng/pipelines/azure-pipelines.yml +++ b/eng/pipelines/azure-pipelines.yml @@ -98,7 +98,7 @@ stages: jobs: - job: windows - timeoutInMinutes: 30 + timeoutInMinutes: 45 pool: ${{ if eq(variables['System.TeamProject'], 'public') }}: @@ -132,7 +132,7 @@ stages: - ${{ if eq(variables._RunAsPublic, True) }}: - job: linux - timeoutInMinutes: 30 + timeoutInMinutes: 45 pool: ${{ if eq(variables['System.TeamProject'], 'public') }}: From a2b8155454fa04a693dc319c4bfb6edd4d3eed4f Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Thu, 1 Feb 2024 01:35:07 -0500 Subject: [PATCH 05/11] Address review feedback from @ joperezr --- .../Aspire.Components.Common.Tests.csproj | 1 - tests/Aspire.Components.Common.Tests/Directory.Build.props | 7 +++++++ tests/send-to-helix.proj | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 tests/Aspire.Components.Common.Tests/Directory.Build.props diff --git a/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj b/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj index 3302f81107..ba590719f6 100644 --- a/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj +++ b/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj @@ -2,7 +2,6 @@ $(NetCurrent) - true diff --git a/tests/Aspire.Components.Common.Tests/Directory.Build.props b/tests/Aspire.Components.Common.Tests/Directory.Build.props new file mode 100644 index 0000000000..4922346540 --- /dev/null +++ b/tests/Aspire.Components.Common.Tests/Directory.Build.props @@ -0,0 +1,7 @@ + + + true + + + + diff --git a/tests/send-to-helix.proj b/tests/send-to-helix.proj index 1f7b3ecf40..b80aec5c87 100644 --- a/tests/send-to-helix.proj +++ b/tests/send-to-helix.proj @@ -74,8 +74,8 @@ <_DotNetToolJsonPath>$(RepoRoot).config/dotnet-tools.json <_DotNetToolJsonContent>$([System.IO.File]::ReadAllText($(_DotNetToolJsonPath))) - <_DotNetCoverageVersionRegex>(?:"dotnet-coverage": *{.*?"version": *")([^"]*?)(?:") - <_DotNetCoverageToolVersion>$([System.Text.RegularExpressions.Regex]::Match($(_DotNetToolJsonContent), '$(_DotNetCoverageVersionRegex)', 'System.Text.RegularExpressions.RegexOptions.Singleline').Groups[1].Value) + <_DotNetCoverageVersionRegex>"dotnet-coverage":\s*{\s*"version":\s*"([^"]*)" + <_DotNetCoverageToolVersion>$([System.Text.RegularExpressions.Regex]::Match($(_DotNetToolJsonContent), '$(_DotNetCoverageVersionRegex)').Groups[1].Value) Date: Mon, 5 Feb 2024 16:05:34 -0500 Subject: [PATCH 06/11] Address review feedback .. and use a single property named `$(RunTestsOnHelix)` that defaults to `false`. --- eng/pipelines/azure-pipelines.yml | 2 -- eng/pipelines/templates/BuildAndTest.yml | 6 +----- .../Aspire.Dashboard.Tests.csproj | 3 +++ tests/Aspire.Dashboard.Tests/Directory.Build.props | 8 -------- tests/Aspire.Hosting.Tests/Directory.Build.props | 3 --- tests/Directory.Build.props | 10 ---------- tests/Directory.Build.targets | 8 +++++++- 7 files changed, 11 insertions(+), 29 deletions(-) delete mode 100644 tests/Aspire.Dashboard.Tests/Directory.Build.props diff --git a/eng/pipelines/azure-pipelines.yml b/eng/pipelines/azure-pipelines.yml index 5d133301e2..3cfa1373d6 100644 --- a/eng/pipelines/azure-pipelines.yml +++ b/eng/pipelines/azure-pipelines.yml @@ -126,7 +126,6 @@ stages: buildConfig: $(_BuildConfig) repoLogPath: $(Build.Arcade.LogsPath) repoTestResultsPath: $(Build.Arcade.TestResultsPath) - defaultToRunningTestsOnHelix: false isWindows: true @@ -160,7 +159,6 @@ stages: buildConfig: $(_BuildConfig) repoLogPath: $(Build.Arcade.LogsPath) repoTestResultsPath: $(Build.Arcade.TestResultsPath) - defaultToRunningTestsOnHelix: false isWindows: false diff --git a/eng/pipelines/templates/BuildAndTest.yml b/eng/pipelines/templates/BuildAndTest.yml index 28a1c24093..7dca8eeea0 100644 --- a/eng/pipelines/templates/BuildAndTest.yml +++ b/eng/pipelines/templates/BuildAndTest.yml @@ -17,16 +17,12 @@ parameters: - name: skipTests type: boolean default: false - - name: defaultToRunningTestsOnHelix - type: boolean - default: true steps: - script: ${{ parameters.buildScript }} -restore -build -configuration ${{ parameters.buildConfig }} /p:ArchiveTests=true - /p:DefaultToRunningTestsOnHelix=${{ parameters.defaultToRunningTestsOnHelix }} /bl:${{ parameters.repoLogPath }}/build.binlog $(_OfficialBuildIdArgs) displayName: Build @@ -35,7 +31,7 @@ steps: - script: ${{ parameters.dotnetScript }} dotnet-coverage collect --settings $(Build.SourcesDirectory)/eng/CodeCoverage.config --output ${{ parameters.repoTestResultsPath }}/NonHelixTests.cobertura.xml - "${{ parameters.buildScript }} -testnobuild -test -configuration ${{ parameters.buildConfig }} /bl:${{ parameters.repoLogPath }}/tests.binlog /p:DefaultToRunningTestsOnHelix=${{ parameters.defaultToRunningTestsOnHelix }} $(_OfficialBuildIdArgs)" + "${{ parameters.buildScript }} -testnobuild -test -configuration ${{ parameters.buildConfig }} /bl:${{ parameters.repoLogPath }}/tests.binlog $(_OfficialBuildIdArgs)" displayName: Run non-helix tests - template: /eng/pipelines/templates/send-to-helix.yml diff --git a/tests/Aspire.Dashboard.Tests/Aspire.Dashboard.Tests.csproj b/tests/Aspire.Dashboard.Tests/Aspire.Dashboard.Tests.csproj index 2be42ac724..37c80171b8 100644 --- a/tests/Aspire.Dashboard.Tests/Aspire.Dashboard.Tests.csproj +++ b/tests/Aspire.Dashboard.Tests/Aspire.Dashboard.Tests.csproj @@ -2,6 +2,9 @@ $(NetCurrent) + + + true diff --git a/tests/Aspire.Dashboard.Tests/Directory.Build.props b/tests/Aspire.Dashboard.Tests/Directory.Build.props deleted file mode 100644 index 952039cc77..0000000000 --- a/tests/Aspire.Dashboard.Tests/Directory.Build.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - true - - - - diff --git a/tests/Aspire.Hosting.Tests/Directory.Build.props b/tests/Aspire.Hosting.Tests/Directory.Build.props index f20dd79904..5d2b9d076c 100644 --- a/tests/Aspire.Hosting.Tests/Directory.Build.props +++ b/tests/Aspire.Hosting.Tests/Directory.Build.props @@ -1,7 +1,4 @@ - - true - diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index a4646d16ad..68bd3e65b6 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -10,16 +10,6 @@ CS1712: Type parameter 'type_parameter' has no matching typeparam tag in the XML comment on 'type_or_member' (but other type parameters do) --> $(NoWarn);1573;1591;1712 - - false - false - true - - true - - true diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets index a2800fee0c..32f2946920 100644 --- a/tests/Directory.Build.targets +++ b/tests/Directory.Build.targets @@ -1,11 +1,17 @@ + + true + + false + true + - + From 0b092dc7c90fd8eec2a510c71d96f8878f7c31a5 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Mon, 5 Feb 2024 16:14:52 -0500 Subject: [PATCH 07/11] Address review feedback, and modify the original template for send-to-helix.yml --- eng/common/templates/steps/send-to-helix.yml | 125 ++++++++++--------- eng/pipelines/templates/BuildAndTest.yml | 2 +- eng/pipelines/templates/send-to-helix.yml | 94 -------------- 3 files changed, 65 insertions(+), 156 deletions(-) delete mode 100644 eng/pipelines/templates/send-to-helix.yml diff --git a/eng/common/templates/steps/send-to-helix.yml b/eng/common/templates/steps/send-to-helix.yml index 3eb7e2d5f8..da90ed942c 100644 --- a/eng/common/templates/steps/send-to-helix.yml +++ b/eng/common/templates/steps/send-to-helix.yml @@ -5,6 +5,8 @@ parameters: HelixBuild: $(Build.BuildNumber) # required -- the build number Helix will use to identify this -- automatically set to the AzDO build number HelixTargetQueues: '' # required -- semicolon-delimited list of Helix queues to test on; see https://helix.dot.net/ for a list of queues HelixAccessToken: '' # required -- access token to make Helix API requests; should be provided by the appropriate variable group + HelixProjectPath: '' # required -- path to the project file to build + HelixProjectArguments: '' # optional -- arguments passed to the build command HelixConfiguration: '' # optional -- additional property attached to a job HelixPreCommands: '' # optional -- commands to run before Helix work item execution HelixPostCommands: '' # optional -- commands to run after Helix work item execution @@ -24,68 +26,69 @@ parameters: IsExternal: false # [DEPRECATED] -- doesn't do anything, jobs are external if HelixAccessToken is empty and Creator is set HelixBaseUri: 'https://helix.dot.net/' # optional -- sets the Helix API base URI (allows targeting https://helix.int-dot.net ) Creator: '' # optional -- if the build is external, use this to specify who is sending the job - DisplayNamePrefix: 'Run Tests' # optional -- rename the beginning of the displayName of the steps in AzDO + DisplayNamePrefix: 'Run Tests on helix' # optional -- rename the beginning of the displayName of the steps in AzDO + IsWindows: false condition: succeeded() # optional -- condition for step to execute; defaults to succeeded() continueOnError: false # optional -- determines whether to continue the build if the step errors; defaults to false steps: - - powershell: 'powershell "$env:BUILD_SOURCESDIRECTORY\eng\common\msbuild.ps1 $env:BUILD_SOURCESDIRECTORY\eng\common\helixpublish.proj /restore /p:TreatWarningsAsErrors=false /t:Test /bl:$env:BUILD_SOURCESDIRECTORY\artifacts\log\$env:BuildConfig\SendToHelix.binlog"' - displayName: ${{ parameters.DisplayNamePrefix }} (Windows) - env: - BuildConfig: $(_BuildConfig) - HelixSource: ${{ parameters.HelixSource }} - HelixType: ${{ parameters.HelixType }} - HelixBuild: ${{ parameters.HelixBuild }} - HelixConfiguration: ${{ parameters.HelixConfiguration }} - HelixTargetQueues: ${{ parameters.HelixTargetQueues }} - HelixAccessToken: ${{ parameters.HelixAccessToken }} - HelixPreCommands: ${{ parameters.HelixPreCommands }} - HelixPostCommands: ${{ parameters.HelixPostCommands }} - WorkItemDirectory: ${{ parameters.WorkItemDirectory }} - WorkItemCommand: ${{ parameters.WorkItemCommand }} - WorkItemTimeout: ${{ parameters.WorkItemTimeout }} - CorrelationPayloadDirectory: ${{ parameters.CorrelationPayloadDirectory }} - XUnitProjects: ${{ parameters.XUnitProjects }} - XUnitWorkItemTimeout: ${{ parameters.XUnitWorkItemTimeout }} - XUnitPublishTargetFramework: ${{ parameters.XUnitPublishTargetFramework }} - XUnitRuntimeTargetFramework: ${{ parameters.XUnitRuntimeTargetFramework }} - XUnitRunnerVersion: ${{ parameters.XUnitRunnerVersion }} - IncludeDotNetCli: ${{ parameters.IncludeDotNetCli }} - DotNetCliPackageType: ${{ parameters.DotNetCliPackageType }} - DotNetCliVersion: ${{ parameters.DotNetCliVersion }} - WaitForWorkItemCompletion: ${{ parameters.WaitForWorkItemCompletion }} - HelixBaseUri: ${{ parameters.HelixBaseUri }} - Creator: ${{ parameters.Creator }} - SYSTEM_ACCESSTOKEN: $(System.AccessToken) - condition: and(${{ parameters.condition }}, eq(variables['Agent.Os'], 'Windows_NT')) - continueOnError: ${{ parameters.continueOnError }} - - script: $BUILD_SOURCESDIRECTORY/eng/common/msbuild.sh $BUILD_SOURCESDIRECTORY/eng/common/helixpublish.proj /restore /p:TreatWarningsAsErrors=false /t:Test /bl:$BUILD_SOURCESDIRECTORY/artifacts/log/$BuildConfig/SendToHelix.binlog - displayName: ${{ parameters.DisplayNamePrefix }} (Unix) - env: - BuildConfig: $(_BuildConfig) - HelixSource: ${{ parameters.HelixSource }} - HelixType: ${{ parameters.HelixType }} - HelixBuild: ${{ parameters.HelixBuild }} - HelixConfiguration: ${{ parameters.HelixConfiguration }} - HelixTargetQueues: ${{ parameters.HelixTargetQueues }} - HelixAccessToken: ${{ parameters.HelixAccessToken }} - HelixPreCommands: ${{ parameters.HelixPreCommands }} - HelixPostCommands: ${{ parameters.HelixPostCommands }} - WorkItemDirectory: ${{ parameters.WorkItemDirectory }} - WorkItemCommand: ${{ parameters.WorkItemCommand }} - WorkItemTimeout: ${{ parameters.WorkItemTimeout }} - CorrelationPayloadDirectory: ${{ parameters.CorrelationPayloadDirectory }} - XUnitProjects: ${{ parameters.XUnitProjects }} - XUnitWorkItemTimeout: ${{ parameters.XUnitWorkItemTimeout }} - XUnitPublishTargetFramework: ${{ parameters.XUnitPublishTargetFramework }} - XUnitRuntimeTargetFramework: ${{ parameters.XUnitRuntimeTargetFramework }} - XUnitRunnerVersion: ${{ parameters.XUnitRunnerVersion }} - IncludeDotNetCli: ${{ parameters.IncludeDotNetCli }} - DotNetCliPackageType: ${{ parameters.DotNetCliPackageType }} - DotNetCliVersion: ${{ parameters.DotNetCliVersion }} - WaitForWorkItemCompletion: ${{ parameters.WaitForWorkItemCompletion }} - HelixBaseUri: ${{ parameters.HelixBaseUri }} - Creator: ${{ parameters.Creator }} - SYSTEM_ACCESSTOKEN: $(System.AccessToken) - condition: and(${{ parameters.condition }}, ne(variables['Agent.Os'], 'Windows_NT')) - continueOnError: ${{ parameters.continueOnError }} + - ${{ if and(parameters.condition, eq(parameters.IsWindows, 'true')) }}: + - powershell: 'powershell "$env:BUILD_SOURCESDIRECTORY\eng\common\msbuild.ps1 ${{ parameters.HelixProjectPath }} ${{ parameters.HelixProjectArguments }} /restore /p:TreatWarningsAsErrors=false /t:Test /bl:$env:BUILD_SOURCESDIRECTORY\artifacts\log\$env:BuildConfig\SendToHelix.binlog"' + displayName: ${{ parameters.DisplayNamePrefix }} + env: + BuildConfig: $(_BuildConfig) + HelixSource: ${{ parameters.HelixSource }} + HelixType: ${{ parameters.HelixType }} + HelixBuild: ${{ parameters.HelixBuild }} + HelixConfiguration: ${{ parameters.HelixConfiguration }} + HelixTargetQueues: ${{ parameters.HelixTargetQueues }} + HelixAccessToken: ${{ parameters.HelixAccessToken }} + HelixPreCommands: ${{ parameters.HelixPreCommands }} + HelixPostCommands: ${{ parameters.HelixPostCommands }} + WorkItemDirectory: ${{ parameters.WorkItemDirectory }} + WorkItemCommand: ${{ parameters.WorkItemCommand }} + WorkItemTimeout: ${{ parameters.WorkItemTimeout }} + CorrelationPayloadDirectory: ${{ parameters.CorrelationPayloadDirectory }} + XUnitProjects: ${{ parameters.XUnitProjects }} + XUnitWorkItemTimeout: ${{ parameters.XUnitWorkItemTimeout }} + XUnitPublishTargetFramework: ${{ parameters.XUnitPublishTargetFramework }} + XUnitRuntimeTargetFramework: ${{ parameters.XUnitRuntimeTargetFramework }} + XUnitRunnerVersion: ${{ parameters.XUnitRunnerVersion }} + IncludeDotNetCli: ${{ parameters.IncludeDotNetCli }} + DotNetCliPackageType: ${{ parameters.DotNetCliPackageType }} + DotNetCliVersion: ${{ parameters.DotNetCliVersion }} + WaitForWorkItemCompletion: ${{ parameters.WaitForWorkItemCompletion }} + HelixBaseUri: ${{ parameters.HelixBaseUri }} + Creator: ${{ parameters.Creator }} + SYSTEM_ACCESSTOKEN: $(System.AccessToken) + continueOnError: ${{ parameters.continueOnError }} + - ${{ if and(parameters.condition, ne(parameters.IsWindows, 'true')) }}: + - script: $BUILD_SOURCESDIRECTORY/eng/common/msbuild.sh ${{ parameters.HelixProjectPath }} ${{ parameters.HelixProjectArguments }} /restore /p:TreatWarningsAsErrors=false /t:Test /bl:$BUILD_SOURCESDIRECTORY/artifacts/log/$BuildConfig/SendToHelix.binlog + displayName: ${{ parameters.DisplayNamePrefix }} + env: + BuildConfig: $(_BuildConfig) + HelixSource: ${{ parameters.HelixSource }} + HelixType: ${{ parameters.HelixType }} + HelixBuild: ${{ parameters.HelixBuild }} + HelixConfiguration: ${{ parameters.HelixConfiguration }} + HelixTargetQueues: ${{ parameters.HelixTargetQueues }} + HelixAccessToken: ${{ parameters.HelixAccessToken }} + HelixPreCommands: ${{ parameters.HelixPreCommands }} + HelixPostCommands: ${{ parameters.HelixPostCommands }} + WorkItemDirectory: ${{ parameters.WorkItemDirectory }} + WorkItemCommand: ${{ parameters.WorkItemCommand }} + WorkItemTimeout: ${{ parameters.WorkItemTimeout }} + CorrelationPayloadDirectory: ${{ parameters.CorrelationPayloadDirectory }} + XUnitProjects: ${{ parameters.XUnitProjects }} + XUnitWorkItemTimeout: ${{ parameters.XUnitWorkItemTimeout }} + XUnitPublishTargetFramework: ${{ parameters.XUnitPublishTargetFramework }} + XUnitRuntimeTargetFramework: ${{ parameters.XUnitRuntimeTargetFramework }} + XUnitRunnerVersion: ${{ parameters.XUnitRunnerVersion }} + IncludeDotNetCli: ${{ parameters.IncludeDotNetCli }} + DotNetCliPackageType: ${{ parameters.DotNetCliPackageType }} + DotNetCliVersion: ${{ parameters.DotNetCliVersion }} + WaitForWorkItemCompletion: ${{ parameters.WaitForWorkItemCompletion }} + HelixBaseUri: ${{ parameters.HelixBaseUri }} + Creator: ${{ parameters.Creator }} + SYSTEM_ACCESSTOKEN: $(System.AccessToken) + continueOnError: ${{ parameters.continueOnError }} diff --git a/eng/pipelines/templates/BuildAndTest.yml b/eng/pipelines/templates/BuildAndTest.yml index 7dca8eeea0..ddeffe5f3a 100644 --- a/eng/pipelines/templates/BuildAndTest.yml +++ b/eng/pipelines/templates/BuildAndTest.yml @@ -34,7 +34,7 @@ steps: "${{ parameters.buildScript }} -testnobuild -test -configuration ${{ parameters.buildConfig }} /bl:${{ parameters.repoLogPath }}/tests.binlog $(_OfficialBuildIdArgs)" displayName: Run non-helix tests - - template: /eng/pipelines/templates/send-to-helix.yml + - template: /eng/common/templates/steps/send-to-helix.yml parameters: HelixProjectPath: '$(Build.SourcesDirectory)/tests/send-to-helix.proj' HelixProjectArguments: /p:RunWithCodeCoverage=true /p:RepoTestResultsPath=${{ parameters.repoTestResultsPath }} diff --git a/eng/pipelines/templates/send-to-helix.yml b/eng/pipelines/templates/send-to-helix.yml deleted file mode 100644 index da90ed942c..0000000000 --- a/eng/pipelines/templates/send-to-helix.yml +++ /dev/null @@ -1,94 +0,0 @@ -# Please remember to update the documentation if you make changes to these parameters! -parameters: - HelixSource: 'pr/default' # required -- sources must start with pr/, official/, prodcon/, or agent/ - HelixType: 'tests/default/' # required -- Helix telemetry which identifies what type of data this is; should include "test" for clarity and must end in '/' - HelixBuild: $(Build.BuildNumber) # required -- the build number Helix will use to identify this -- automatically set to the AzDO build number - HelixTargetQueues: '' # required -- semicolon-delimited list of Helix queues to test on; see https://helix.dot.net/ for a list of queues - HelixAccessToken: '' # required -- access token to make Helix API requests; should be provided by the appropriate variable group - HelixProjectPath: '' # required -- path to the project file to build - HelixProjectArguments: '' # optional -- arguments passed to the build command - HelixConfiguration: '' # optional -- additional property attached to a job - HelixPreCommands: '' # optional -- commands to run before Helix work item execution - HelixPostCommands: '' # optional -- commands to run after Helix work item execution - WorkItemDirectory: '' # optional -- a payload directory to zip up and send to Helix; requires WorkItemCommand; incompatible with XUnitProjects - WorkItemCommand: '' # optional -- a command to execute on the payload; requires WorkItemDirectory; incompatible with XUnitProjects - WorkItemTimeout: '' # optional -- a timeout in TimeSpan.Parse-ready value (e.g. 00:02:00) for the work item command; requires WorkItemDirectory; incompatible with XUnitProjects - CorrelationPayloadDirectory: '' # optional -- a directory to zip up and send to Helix as a correlation payload - XUnitProjects: '' # optional -- semicolon-delimited list of XUnitProjects to parse and send to Helix; requires XUnitRuntimeTargetFramework, XUnitPublishTargetFramework, XUnitRunnerVersion, and IncludeDotNetCli=true - XUnitWorkItemTimeout: '' # optional -- the workitem timeout in seconds for all workitems created from the xUnit projects specified by XUnitProjects - XUnitPublishTargetFramework: '' # optional -- framework to use to publish your xUnit projects - XUnitRuntimeTargetFramework: '' # optional -- framework to use for the xUnit console runner - XUnitRunnerVersion: '' # optional -- version of the xUnit nuget package you wish to use on Helix; required for XUnitProjects - IncludeDotNetCli: false # optional -- true will download a version of the .NET CLI onto the Helix machine as a correlation payload; requires DotNetCliPackageType and DotNetCliVersion - DotNetCliPackageType: '' # optional -- either 'sdk', 'runtime' or 'aspnetcore-runtime'; determines whether the sdk or runtime will be sent to Helix; see https://raw.githubusercontent.com/dotnet/core/main/release-notes/releases-index.json - DotNetCliVersion: '' # optional -- version of the CLI to send to Helix; based on this: https://raw.githubusercontent.com/dotnet/core/main/release-notes/releases-index.json - WaitForWorkItemCompletion: true # optional -- true will make the task wait until work items have been completed and fail the build if work items fail. False is "fire and forget." - IsExternal: false # [DEPRECATED] -- doesn't do anything, jobs are external if HelixAccessToken is empty and Creator is set - HelixBaseUri: 'https://helix.dot.net/' # optional -- sets the Helix API base URI (allows targeting https://helix.int-dot.net ) - Creator: '' # optional -- if the build is external, use this to specify who is sending the job - DisplayNamePrefix: 'Run Tests on helix' # optional -- rename the beginning of the displayName of the steps in AzDO - IsWindows: false - condition: succeeded() # optional -- condition for step to execute; defaults to succeeded() - continueOnError: false # optional -- determines whether to continue the build if the step errors; defaults to false - -steps: - - ${{ if and(parameters.condition, eq(parameters.IsWindows, 'true')) }}: - - powershell: 'powershell "$env:BUILD_SOURCESDIRECTORY\eng\common\msbuild.ps1 ${{ parameters.HelixProjectPath }} ${{ parameters.HelixProjectArguments }} /restore /p:TreatWarningsAsErrors=false /t:Test /bl:$env:BUILD_SOURCESDIRECTORY\artifacts\log\$env:BuildConfig\SendToHelix.binlog"' - displayName: ${{ parameters.DisplayNamePrefix }} - env: - BuildConfig: $(_BuildConfig) - HelixSource: ${{ parameters.HelixSource }} - HelixType: ${{ parameters.HelixType }} - HelixBuild: ${{ parameters.HelixBuild }} - HelixConfiguration: ${{ parameters.HelixConfiguration }} - HelixTargetQueues: ${{ parameters.HelixTargetQueues }} - HelixAccessToken: ${{ parameters.HelixAccessToken }} - HelixPreCommands: ${{ parameters.HelixPreCommands }} - HelixPostCommands: ${{ parameters.HelixPostCommands }} - WorkItemDirectory: ${{ parameters.WorkItemDirectory }} - WorkItemCommand: ${{ parameters.WorkItemCommand }} - WorkItemTimeout: ${{ parameters.WorkItemTimeout }} - CorrelationPayloadDirectory: ${{ parameters.CorrelationPayloadDirectory }} - XUnitProjects: ${{ parameters.XUnitProjects }} - XUnitWorkItemTimeout: ${{ parameters.XUnitWorkItemTimeout }} - XUnitPublishTargetFramework: ${{ parameters.XUnitPublishTargetFramework }} - XUnitRuntimeTargetFramework: ${{ parameters.XUnitRuntimeTargetFramework }} - XUnitRunnerVersion: ${{ parameters.XUnitRunnerVersion }} - IncludeDotNetCli: ${{ parameters.IncludeDotNetCli }} - DotNetCliPackageType: ${{ parameters.DotNetCliPackageType }} - DotNetCliVersion: ${{ parameters.DotNetCliVersion }} - WaitForWorkItemCompletion: ${{ parameters.WaitForWorkItemCompletion }} - HelixBaseUri: ${{ parameters.HelixBaseUri }} - Creator: ${{ parameters.Creator }} - SYSTEM_ACCESSTOKEN: $(System.AccessToken) - continueOnError: ${{ parameters.continueOnError }} - - ${{ if and(parameters.condition, ne(parameters.IsWindows, 'true')) }}: - - script: $BUILD_SOURCESDIRECTORY/eng/common/msbuild.sh ${{ parameters.HelixProjectPath }} ${{ parameters.HelixProjectArguments }} /restore /p:TreatWarningsAsErrors=false /t:Test /bl:$BUILD_SOURCESDIRECTORY/artifacts/log/$BuildConfig/SendToHelix.binlog - displayName: ${{ parameters.DisplayNamePrefix }} - env: - BuildConfig: $(_BuildConfig) - HelixSource: ${{ parameters.HelixSource }} - HelixType: ${{ parameters.HelixType }} - HelixBuild: ${{ parameters.HelixBuild }} - HelixConfiguration: ${{ parameters.HelixConfiguration }} - HelixTargetQueues: ${{ parameters.HelixTargetQueues }} - HelixAccessToken: ${{ parameters.HelixAccessToken }} - HelixPreCommands: ${{ parameters.HelixPreCommands }} - HelixPostCommands: ${{ parameters.HelixPostCommands }} - WorkItemDirectory: ${{ parameters.WorkItemDirectory }} - WorkItemCommand: ${{ parameters.WorkItemCommand }} - WorkItemTimeout: ${{ parameters.WorkItemTimeout }} - CorrelationPayloadDirectory: ${{ parameters.CorrelationPayloadDirectory }} - XUnitProjects: ${{ parameters.XUnitProjects }} - XUnitWorkItemTimeout: ${{ parameters.XUnitWorkItemTimeout }} - XUnitPublishTargetFramework: ${{ parameters.XUnitPublishTargetFramework }} - XUnitRuntimeTargetFramework: ${{ parameters.XUnitRuntimeTargetFramework }} - XUnitRunnerVersion: ${{ parameters.XUnitRunnerVersion }} - IncludeDotNetCli: ${{ parameters.IncludeDotNetCli }} - DotNetCliPackageType: ${{ parameters.DotNetCliPackageType }} - DotNetCliVersion: ${{ parameters.DotNetCliVersion }} - WaitForWorkItemCompletion: ${{ parameters.WaitForWorkItemCompletion }} - HelixBaseUri: ${{ parameters.HelixBaseUri }} - Creator: ${{ parameters.Creator }} - SYSTEM_ACCESSTOKEN: $(System.AccessToken) - continueOnError: ${{ parameters.continueOnError }} From 6677ba2d9a301877dcde721081e5ff79c8aa2829 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Mon, 5 Feb 2024 18:11:30 -0600 Subject: [PATCH 08/11] Minor PR feedback --- Directory.Build.targets | 1 + .../Aspire.Components.Common.Tests.csproj | 1 + tests/Aspire.Components.Common.Tests/Directory.Build.props | 7 ------- 3 files changed, 2 insertions(+), 7 deletions(-) delete mode 100644 tests/Aspire.Components.Common.Tests/Directory.Build.props diff --git a/Directory.Build.targets b/Directory.Build.targets index 6964a8a316..cbd14c71d4 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -22,4 +22,5 @@ + diff --git a/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj b/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj index ba590719f6..3302f81107 100644 --- a/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj +++ b/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj @@ -2,6 +2,7 @@ $(NetCurrent) + true diff --git a/tests/Aspire.Components.Common.Tests/Directory.Build.props b/tests/Aspire.Components.Common.Tests/Directory.Build.props deleted file mode 100644 index 4922346540..0000000000 --- a/tests/Aspire.Components.Common.Tests/Directory.Build.props +++ /dev/null @@ -1,7 +0,0 @@ - - - true - - - - From 31dafb0390b861cdefa11e4b18a3e98c06fe7b9b Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Mon, 5 Feb 2024 19:41:08 -0500 Subject: [PATCH 09/11] Instead of modifying the template from arcade, use a copy in pipelines/templates --- eng/common/templates/steps/send-to-helix.yml | 125 +++++++++---------- eng/pipelines/templates/BuildAndTest.yml | 2 +- eng/pipelines/templates/send-to-helix.yml | 94 ++++++++++++++ 3 files changed, 156 insertions(+), 65 deletions(-) create mode 100644 eng/pipelines/templates/send-to-helix.yml diff --git a/eng/common/templates/steps/send-to-helix.yml b/eng/common/templates/steps/send-to-helix.yml index da90ed942c..3eb7e2d5f8 100644 --- a/eng/common/templates/steps/send-to-helix.yml +++ b/eng/common/templates/steps/send-to-helix.yml @@ -5,8 +5,6 @@ parameters: HelixBuild: $(Build.BuildNumber) # required -- the build number Helix will use to identify this -- automatically set to the AzDO build number HelixTargetQueues: '' # required -- semicolon-delimited list of Helix queues to test on; see https://helix.dot.net/ for a list of queues HelixAccessToken: '' # required -- access token to make Helix API requests; should be provided by the appropriate variable group - HelixProjectPath: '' # required -- path to the project file to build - HelixProjectArguments: '' # optional -- arguments passed to the build command HelixConfiguration: '' # optional -- additional property attached to a job HelixPreCommands: '' # optional -- commands to run before Helix work item execution HelixPostCommands: '' # optional -- commands to run after Helix work item execution @@ -26,69 +24,68 @@ parameters: IsExternal: false # [DEPRECATED] -- doesn't do anything, jobs are external if HelixAccessToken is empty and Creator is set HelixBaseUri: 'https://helix.dot.net/' # optional -- sets the Helix API base URI (allows targeting https://helix.int-dot.net ) Creator: '' # optional -- if the build is external, use this to specify who is sending the job - DisplayNamePrefix: 'Run Tests on helix' # optional -- rename the beginning of the displayName of the steps in AzDO - IsWindows: false + DisplayNamePrefix: 'Run Tests' # optional -- rename the beginning of the displayName of the steps in AzDO condition: succeeded() # optional -- condition for step to execute; defaults to succeeded() continueOnError: false # optional -- determines whether to continue the build if the step errors; defaults to false steps: - - ${{ if and(parameters.condition, eq(parameters.IsWindows, 'true')) }}: - - powershell: 'powershell "$env:BUILD_SOURCESDIRECTORY\eng\common\msbuild.ps1 ${{ parameters.HelixProjectPath }} ${{ parameters.HelixProjectArguments }} /restore /p:TreatWarningsAsErrors=false /t:Test /bl:$env:BUILD_SOURCESDIRECTORY\artifacts\log\$env:BuildConfig\SendToHelix.binlog"' - displayName: ${{ parameters.DisplayNamePrefix }} - env: - BuildConfig: $(_BuildConfig) - HelixSource: ${{ parameters.HelixSource }} - HelixType: ${{ parameters.HelixType }} - HelixBuild: ${{ parameters.HelixBuild }} - HelixConfiguration: ${{ parameters.HelixConfiguration }} - HelixTargetQueues: ${{ parameters.HelixTargetQueues }} - HelixAccessToken: ${{ parameters.HelixAccessToken }} - HelixPreCommands: ${{ parameters.HelixPreCommands }} - HelixPostCommands: ${{ parameters.HelixPostCommands }} - WorkItemDirectory: ${{ parameters.WorkItemDirectory }} - WorkItemCommand: ${{ parameters.WorkItemCommand }} - WorkItemTimeout: ${{ parameters.WorkItemTimeout }} - CorrelationPayloadDirectory: ${{ parameters.CorrelationPayloadDirectory }} - XUnitProjects: ${{ parameters.XUnitProjects }} - XUnitWorkItemTimeout: ${{ parameters.XUnitWorkItemTimeout }} - XUnitPublishTargetFramework: ${{ parameters.XUnitPublishTargetFramework }} - XUnitRuntimeTargetFramework: ${{ parameters.XUnitRuntimeTargetFramework }} - XUnitRunnerVersion: ${{ parameters.XUnitRunnerVersion }} - IncludeDotNetCli: ${{ parameters.IncludeDotNetCli }} - DotNetCliPackageType: ${{ parameters.DotNetCliPackageType }} - DotNetCliVersion: ${{ parameters.DotNetCliVersion }} - WaitForWorkItemCompletion: ${{ parameters.WaitForWorkItemCompletion }} - HelixBaseUri: ${{ parameters.HelixBaseUri }} - Creator: ${{ parameters.Creator }} - SYSTEM_ACCESSTOKEN: $(System.AccessToken) - continueOnError: ${{ parameters.continueOnError }} - - ${{ if and(parameters.condition, ne(parameters.IsWindows, 'true')) }}: - - script: $BUILD_SOURCESDIRECTORY/eng/common/msbuild.sh ${{ parameters.HelixProjectPath }} ${{ parameters.HelixProjectArguments }} /restore /p:TreatWarningsAsErrors=false /t:Test /bl:$BUILD_SOURCESDIRECTORY/artifacts/log/$BuildConfig/SendToHelix.binlog - displayName: ${{ parameters.DisplayNamePrefix }} - env: - BuildConfig: $(_BuildConfig) - HelixSource: ${{ parameters.HelixSource }} - HelixType: ${{ parameters.HelixType }} - HelixBuild: ${{ parameters.HelixBuild }} - HelixConfiguration: ${{ parameters.HelixConfiguration }} - HelixTargetQueues: ${{ parameters.HelixTargetQueues }} - HelixAccessToken: ${{ parameters.HelixAccessToken }} - HelixPreCommands: ${{ parameters.HelixPreCommands }} - HelixPostCommands: ${{ parameters.HelixPostCommands }} - WorkItemDirectory: ${{ parameters.WorkItemDirectory }} - WorkItemCommand: ${{ parameters.WorkItemCommand }} - WorkItemTimeout: ${{ parameters.WorkItemTimeout }} - CorrelationPayloadDirectory: ${{ parameters.CorrelationPayloadDirectory }} - XUnitProjects: ${{ parameters.XUnitProjects }} - XUnitWorkItemTimeout: ${{ parameters.XUnitWorkItemTimeout }} - XUnitPublishTargetFramework: ${{ parameters.XUnitPublishTargetFramework }} - XUnitRuntimeTargetFramework: ${{ parameters.XUnitRuntimeTargetFramework }} - XUnitRunnerVersion: ${{ parameters.XUnitRunnerVersion }} - IncludeDotNetCli: ${{ parameters.IncludeDotNetCli }} - DotNetCliPackageType: ${{ parameters.DotNetCliPackageType }} - DotNetCliVersion: ${{ parameters.DotNetCliVersion }} - WaitForWorkItemCompletion: ${{ parameters.WaitForWorkItemCompletion }} - HelixBaseUri: ${{ parameters.HelixBaseUri }} - Creator: ${{ parameters.Creator }} - SYSTEM_ACCESSTOKEN: $(System.AccessToken) - continueOnError: ${{ parameters.continueOnError }} + - powershell: 'powershell "$env:BUILD_SOURCESDIRECTORY\eng\common\msbuild.ps1 $env:BUILD_SOURCESDIRECTORY\eng\common\helixpublish.proj /restore /p:TreatWarningsAsErrors=false /t:Test /bl:$env:BUILD_SOURCESDIRECTORY\artifacts\log\$env:BuildConfig\SendToHelix.binlog"' + displayName: ${{ parameters.DisplayNamePrefix }} (Windows) + env: + BuildConfig: $(_BuildConfig) + HelixSource: ${{ parameters.HelixSource }} + HelixType: ${{ parameters.HelixType }} + HelixBuild: ${{ parameters.HelixBuild }} + HelixConfiguration: ${{ parameters.HelixConfiguration }} + HelixTargetQueues: ${{ parameters.HelixTargetQueues }} + HelixAccessToken: ${{ parameters.HelixAccessToken }} + HelixPreCommands: ${{ parameters.HelixPreCommands }} + HelixPostCommands: ${{ parameters.HelixPostCommands }} + WorkItemDirectory: ${{ parameters.WorkItemDirectory }} + WorkItemCommand: ${{ parameters.WorkItemCommand }} + WorkItemTimeout: ${{ parameters.WorkItemTimeout }} + CorrelationPayloadDirectory: ${{ parameters.CorrelationPayloadDirectory }} + XUnitProjects: ${{ parameters.XUnitProjects }} + XUnitWorkItemTimeout: ${{ parameters.XUnitWorkItemTimeout }} + XUnitPublishTargetFramework: ${{ parameters.XUnitPublishTargetFramework }} + XUnitRuntimeTargetFramework: ${{ parameters.XUnitRuntimeTargetFramework }} + XUnitRunnerVersion: ${{ parameters.XUnitRunnerVersion }} + IncludeDotNetCli: ${{ parameters.IncludeDotNetCli }} + DotNetCliPackageType: ${{ parameters.DotNetCliPackageType }} + DotNetCliVersion: ${{ parameters.DotNetCliVersion }} + WaitForWorkItemCompletion: ${{ parameters.WaitForWorkItemCompletion }} + HelixBaseUri: ${{ parameters.HelixBaseUri }} + Creator: ${{ parameters.Creator }} + SYSTEM_ACCESSTOKEN: $(System.AccessToken) + condition: and(${{ parameters.condition }}, eq(variables['Agent.Os'], 'Windows_NT')) + continueOnError: ${{ parameters.continueOnError }} + - script: $BUILD_SOURCESDIRECTORY/eng/common/msbuild.sh $BUILD_SOURCESDIRECTORY/eng/common/helixpublish.proj /restore /p:TreatWarningsAsErrors=false /t:Test /bl:$BUILD_SOURCESDIRECTORY/artifacts/log/$BuildConfig/SendToHelix.binlog + displayName: ${{ parameters.DisplayNamePrefix }} (Unix) + env: + BuildConfig: $(_BuildConfig) + HelixSource: ${{ parameters.HelixSource }} + HelixType: ${{ parameters.HelixType }} + HelixBuild: ${{ parameters.HelixBuild }} + HelixConfiguration: ${{ parameters.HelixConfiguration }} + HelixTargetQueues: ${{ parameters.HelixTargetQueues }} + HelixAccessToken: ${{ parameters.HelixAccessToken }} + HelixPreCommands: ${{ parameters.HelixPreCommands }} + HelixPostCommands: ${{ parameters.HelixPostCommands }} + WorkItemDirectory: ${{ parameters.WorkItemDirectory }} + WorkItemCommand: ${{ parameters.WorkItemCommand }} + WorkItemTimeout: ${{ parameters.WorkItemTimeout }} + CorrelationPayloadDirectory: ${{ parameters.CorrelationPayloadDirectory }} + XUnitProjects: ${{ parameters.XUnitProjects }} + XUnitWorkItemTimeout: ${{ parameters.XUnitWorkItemTimeout }} + XUnitPublishTargetFramework: ${{ parameters.XUnitPublishTargetFramework }} + XUnitRuntimeTargetFramework: ${{ parameters.XUnitRuntimeTargetFramework }} + XUnitRunnerVersion: ${{ parameters.XUnitRunnerVersion }} + IncludeDotNetCli: ${{ parameters.IncludeDotNetCli }} + DotNetCliPackageType: ${{ parameters.DotNetCliPackageType }} + DotNetCliVersion: ${{ parameters.DotNetCliVersion }} + WaitForWorkItemCompletion: ${{ parameters.WaitForWorkItemCompletion }} + HelixBaseUri: ${{ parameters.HelixBaseUri }} + Creator: ${{ parameters.Creator }} + SYSTEM_ACCESSTOKEN: $(System.AccessToken) + condition: and(${{ parameters.condition }}, ne(variables['Agent.Os'], 'Windows_NT')) + continueOnError: ${{ parameters.continueOnError }} diff --git a/eng/pipelines/templates/BuildAndTest.yml b/eng/pipelines/templates/BuildAndTest.yml index ddeffe5f3a..7dca8eeea0 100644 --- a/eng/pipelines/templates/BuildAndTest.yml +++ b/eng/pipelines/templates/BuildAndTest.yml @@ -34,7 +34,7 @@ steps: "${{ parameters.buildScript }} -testnobuild -test -configuration ${{ parameters.buildConfig }} /bl:${{ parameters.repoLogPath }}/tests.binlog $(_OfficialBuildIdArgs)" displayName: Run non-helix tests - - template: /eng/common/templates/steps/send-to-helix.yml + - template: /eng/pipelines/templates/send-to-helix.yml parameters: HelixProjectPath: '$(Build.SourcesDirectory)/tests/send-to-helix.proj' HelixProjectArguments: /p:RunWithCodeCoverage=true /p:RepoTestResultsPath=${{ parameters.repoTestResultsPath }} diff --git a/eng/pipelines/templates/send-to-helix.yml b/eng/pipelines/templates/send-to-helix.yml new file mode 100644 index 0000000000..da90ed942c --- /dev/null +++ b/eng/pipelines/templates/send-to-helix.yml @@ -0,0 +1,94 @@ +# Please remember to update the documentation if you make changes to these parameters! +parameters: + HelixSource: 'pr/default' # required -- sources must start with pr/, official/, prodcon/, or agent/ + HelixType: 'tests/default/' # required -- Helix telemetry which identifies what type of data this is; should include "test" for clarity and must end in '/' + HelixBuild: $(Build.BuildNumber) # required -- the build number Helix will use to identify this -- automatically set to the AzDO build number + HelixTargetQueues: '' # required -- semicolon-delimited list of Helix queues to test on; see https://helix.dot.net/ for a list of queues + HelixAccessToken: '' # required -- access token to make Helix API requests; should be provided by the appropriate variable group + HelixProjectPath: '' # required -- path to the project file to build + HelixProjectArguments: '' # optional -- arguments passed to the build command + HelixConfiguration: '' # optional -- additional property attached to a job + HelixPreCommands: '' # optional -- commands to run before Helix work item execution + HelixPostCommands: '' # optional -- commands to run after Helix work item execution + WorkItemDirectory: '' # optional -- a payload directory to zip up and send to Helix; requires WorkItemCommand; incompatible with XUnitProjects + WorkItemCommand: '' # optional -- a command to execute on the payload; requires WorkItemDirectory; incompatible with XUnitProjects + WorkItemTimeout: '' # optional -- a timeout in TimeSpan.Parse-ready value (e.g. 00:02:00) for the work item command; requires WorkItemDirectory; incompatible with XUnitProjects + CorrelationPayloadDirectory: '' # optional -- a directory to zip up and send to Helix as a correlation payload + XUnitProjects: '' # optional -- semicolon-delimited list of XUnitProjects to parse and send to Helix; requires XUnitRuntimeTargetFramework, XUnitPublishTargetFramework, XUnitRunnerVersion, and IncludeDotNetCli=true + XUnitWorkItemTimeout: '' # optional -- the workitem timeout in seconds for all workitems created from the xUnit projects specified by XUnitProjects + XUnitPublishTargetFramework: '' # optional -- framework to use to publish your xUnit projects + XUnitRuntimeTargetFramework: '' # optional -- framework to use for the xUnit console runner + XUnitRunnerVersion: '' # optional -- version of the xUnit nuget package you wish to use on Helix; required for XUnitProjects + IncludeDotNetCli: false # optional -- true will download a version of the .NET CLI onto the Helix machine as a correlation payload; requires DotNetCliPackageType and DotNetCliVersion + DotNetCliPackageType: '' # optional -- either 'sdk', 'runtime' or 'aspnetcore-runtime'; determines whether the sdk or runtime will be sent to Helix; see https://raw.githubusercontent.com/dotnet/core/main/release-notes/releases-index.json + DotNetCliVersion: '' # optional -- version of the CLI to send to Helix; based on this: https://raw.githubusercontent.com/dotnet/core/main/release-notes/releases-index.json + WaitForWorkItemCompletion: true # optional -- true will make the task wait until work items have been completed and fail the build if work items fail. False is "fire and forget." + IsExternal: false # [DEPRECATED] -- doesn't do anything, jobs are external if HelixAccessToken is empty and Creator is set + HelixBaseUri: 'https://helix.dot.net/' # optional -- sets the Helix API base URI (allows targeting https://helix.int-dot.net ) + Creator: '' # optional -- if the build is external, use this to specify who is sending the job + DisplayNamePrefix: 'Run Tests on helix' # optional -- rename the beginning of the displayName of the steps in AzDO + IsWindows: false + condition: succeeded() # optional -- condition for step to execute; defaults to succeeded() + continueOnError: false # optional -- determines whether to continue the build if the step errors; defaults to false + +steps: + - ${{ if and(parameters.condition, eq(parameters.IsWindows, 'true')) }}: + - powershell: 'powershell "$env:BUILD_SOURCESDIRECTORY\eng\common\msbuild.ps1 ${{ parameters.HelixProjectPath }} ${{ parameters.HelixProjectArguments }} /restore /p:TreatWarningsAsErrors=false /t:Test /bl:$env:BUILD_SOURCESDIRECTORY\artifacts\log\$env:BuildConfig\SendToHelix.binlog"' + displayName: ${{ parameters.DisplayNamePrefix }} + env: + BuildConfig: $(_BuildConfig) + HelixSource: ${{ parameters.HelixSource }} + HelixType: ${{ parameters.HelixType }} + HelixBuild: ${{ parameters.HelixBuild }} + HelixConfiguration: ${{ parameters.HelixConfiguration }} + HelixTargetQueues: ${{ parameters.HelixTargetQueues }} + HelixAccessToken: ${{ parameters.HelixAccessToken }} + HelixPreCommands: ${{ parameters.HelixPreCommands }} + HelixPostCommands: ${{ parameters.HelixPostCommands }} + WorkItemDirectory: ${{ parameters.WorkItemDirectory }} + WorkItemCommand: ${{ parameters.WorkItemCommand }} + WorkItemTimeout: ${{ parameters.WorkItemTimeout }} + CorrelationPayloadDirectory: ${{ parameters.CorrelationPayloadDirectory }} + XUnitProjects: ${{ parameters.XUnitProjects }} + XUnitWorkItemTimeout: ${{ parameters.XUnitWorkItemTimeout }} + XUnitPublishTargetFramework: ${{ parameters.XUnitPublishTargetFramework }} + XUnitRuntimeTargetFramework: ${{ parameters.XUnitRuntimeTargetFramework }} + XUnitRunnerVersion: ${{ parameters.XUnitRunnerVersion }} + IncludeDotNetCli: ${{ parameters.IncludeDotNetCli }} + DotNetCliPackageType: ${{ parameters.DotNetCliPackageType }} + DotNetCliVersion: ${{ parameters.DotNetCliVersion }} + WaitForWorkItemCompletion: ${{ parameters.WaitForWorkItemCompletion }} + HelixBaseUri: ${{ parameters.HelixBaseUri }} + Creator: ${{ parameters.Creator }} + SYSTEM_ACCESSTOKEN: $(System.AccessToken) + continueOnError: ${{ parameters.continueOnError }} + - ${{ if and(parameters.condition, ne(parameters.IsWindows, 'true')) }}: + - script: $BUILD_SOURCESDIRECTORY/eng/common/msbuild.sh ${{ parameters.HelixProjectPath }} ${{ parameters.HelixProjectArguments }} /restore /p:TreatWarningsAsErrors=false /t:Test /bl:$BUILD_SOURCESDIRECTORY/artifacts/log/$BuildConfig/SendToHelix.binlog + displayName: ${{ parameters.DisplayNamePrefix }} + env: + BuildConfig: $(_BuildConfig) + HelixSource: ${{ parameters.HelixSource }} + HelixType: ${{ parameters.HelixType }} + HelixBuild: ${{ parameters.HelixBuild }} + HelixConfiguration: ${{ parameters.HelixConfiguration }} + HelixTargetQueues: ${{ parameters.HelixTargetQueues }} + HelixAccessToken: ${{ parameters.HelixAccessToken }} + HelixPreCommands: ${{ parameters.HelixPreCommands }} + HelixPostCommands: ${{ parameters.HelixPostCommands }} + WorkItemDirectory: ${{ parameters.WorkItemDirectory }} + WorkItemCommand: ${{ parameters.WorkItemCommand }} + WorkItemTimeout: ${{ parameters.WorkItemTimeout }} + CorrelationPayloadDirectory: ${{ parameters.CorrelationPayloadDirectory }} + XUnitProjects: ${{ parameters.XUnitProjects }} + XUnitWorkItemTimeout: ${{ parameters.XUnitWorkItemTimeout }} + XUnitPublishTargetFramework: ${{ parameters.XUnitPublishTargetFramework }} + XUnitRuntimeTargetFramework: ${{ parameters.XUnitRuntimeTargetFramework }} + XUnitRunnerVersion: ${{ parameters.XUnitRunnerVersion }} + IncludeDotNetCli: ${{ parameters.IncludeDotNetCli }} + DotNetCliPackageType: ${{ parameters.DotNetCliPackageType }} + DotNetCliVersion: ${{ parameters.DotNetCliVersion }} + WaitForWorkItemCompletion: ${{ parameters.WaitForWorkItemCompletion }} + HelixBaseUri: ${{ parameters.HelixBaseUri }} + Creator: ${{ parameters.Creator }} + SYSTEM_ACCESSTOKEN: $(System.AccessToken) + continueOnError: ${{ parameters.continueOnError }} From 762293342ade4c7ef4726b2055ddfe038f68d5bf Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Mon, 5 Feb 2024 19:45:21 -0500 Subject: [PATCH 10/11] send-to-helix.yml - minor cleanup --- eng/pipelines/templates/send-to-helix.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/eng/pipelines/templates/send-to-helix.yml b/eng/pipelines/templates/send-to-helix.yml index da90ed942c..5dcd7ea792 100644 --- a/eng/pipelines/templates/send-to-helix.yml +++ b/eng/pipelines/templates/send-to-helix.yml @@ -1,3 +1,4 @@ +# This is a modified copy of eng/common/templates/steps/send-to-helix.yml # Please remember to update the documentation if you make changes to these parameters! parameters: HelixSource: 'pr/default' # required -- sources must start with pr/, official/, prodcon/, or agent/ @@ -26,8 +27,8 @@ parameters: IsExternal: false # [DEPRECATED] -- doesn't do anything, jobs are external if HelixAccessToken is empty and Creator is set HelixBaseUri: 'https://helix.dot.net/' # optional -- sets the Helix API base URI (allows targeting https://helix.int-dot.net ) Creator: '' # optional -- if the build is external, use this to specify who is sending the job - DisplayNamePrefix: 'Run Tests on helix' # optional -- rename the beginning of the displayName of the steps in AzDO - IsWindows: false + DisplayNamePrefix: 'Run helix tests' # optional -- rename the beginning of the displayName of the steps in AzDO + IsWindows: false # optional condition: succeeded() # optional -- condition for step to execute; defaults to succeeded() continueOnError: false # optional -- determines whether to continue the build if the step errors; defaults to false From c5d31f33718a8800eb8e243f7a2a51f425288a44 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 6 Feb 2024 01:04:34 -0500 Subject: [PATCH 11/11] Fix merging code coverage results The second stage processes the *cobertura.xml files to generate a report. And for that it collects these xml files from all the jobs. Earlier commits in this PR did not have unique names across jobs, like for linux, and windows. Which meant that the report generation step only handled one set of the xml files. Fix that by using the original unique filenames for the merged xml generated from the helix, and non-helix tests. --- eng/pipelines/templates/BuildAndTest.yml | 25 +++++++++++------------- tests/send-to-helix.proj | 4 ++-- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/eng/pipelines/templates/BuildAndTest.yml b/eng/pipelines/templates/BuildAndTest.yml index 7dca8eeea0..3f5ecb325b 100644 --- a/eng/pipelines/templates/BuildAndTest.yml +++ b/eng/pipelines/templates/BuildAndTest.yml @@ -49,21 +49,18 @@ steps: HelixBuild: $(Build.BuildNumber) HelixAccessToken: $(HelixApiAccessToken) - - ${{ if eq(parameters.isWindows, 'true') }}: - - pwsh: | - $_cov_filelist=$((Get-ChildItem -Path ${{ parameters.repoTestResultsPath }} -Recurse -Filter *.cobertura.xml -File | % { $_.FullName }) -join ' ') - echo "${{ parameters.dotnetScript }} dotnet-coverage merge $_cov_filelist -f cobertura -o ${{ parameters.repoTestResultsPath }}/$(Agent.Os)_$(Agent.JobName).cobertura.xml" > merge-cov.cmd - cmd /c merge-cov.cmd - rm merge-cov.cmd - displayName: Merge code coverage results + - task: CopyFiles@2 + inputs: + Contents: '${{ parameters.repoTestResultsPath }}/**/*.cobertura.xml' + TargetFolder: '${{ parameters.repoTestResultsPath }}/collected' + flattenFolders: true + displayName: Gather coverage results (cobertura.xml) - - ${{ if ne(parameters.isWindows, 'true') }}: - - script: ${{ parameters.dotnetScript }} dotnet-coverage - merge - `find ${{ parameters.repoTestResultsPath }} -name '*.cobertura.xml' -print0 | xargs -0` - -f cobertura - -o '${{ parameters.repoTestResultsPath }}/$(Agent.Os)_$(Agent.JobName).cobertura.xml' - displayName: Merge code coverage results + - script: $(Build.SourcesDirectory)/.dotnet/dotnet dotnet-coverage merge + ${{ parameters.repoTestResultsPath }}/collected/*.cobertura.xml + --output-format cobertura + --output ${{ parameters.repoTestResultsPath }}/$(Agent.Os)_$(Agent.JobName).cobertura.xml + displayName: Merge code coverage reports - task: PublishBuildArtifacts@1 inputs: diff --git a/tests/send-to-helix.proj b/tests/send-to-helix.proj index b80aec5c87..b7b8c5afc0 100644 --- a/tests/send-to-helix.proj +++ b/tests/send-to-helix.proj @@ -28,7 +28,7 @@ <_TestCoverageCommand Include="$(_HelixCorrelationPayloadEnvVar)/dotnet-coverage/dotnet-coverage collect" /> <_TestCoverageCommand Include="--settings $(_HelixCorrelationPayloadEnvVar)/support-data/CodeCoverage.config" /> - <_TestCoverageCommand Include="--output $(_HelixLogsPath)/Tests.cobertura.xml" /> + <_TestCoverageCommand Include="--output $(_HelixLogsPath)/$(_TestNameEnvVar).cobertura.xml" /> <_TestRunCommandArguments Include="dotnet test" /> <_TestRunCommandArguments Include="-s .runsettings" /> @@ -60,7 +60,7 @@ $(_workItemTimeout) - logs/Tests.cobertura.xml + logs/%(FileName).cobertura.xml