From 6eadf9fb745ada735f1d5d0073a94d88645c401d Mon Sep 17 00:00:00 2001 From: Matt Thalman Date: Wed, 1 May 2024 09:16:01 -0500 Subject: [PATCH] Enable scenario test execution in VMR build (#19222) --- eng/pipelines/templates/jobs/vmr-build.yml | 33 +++++++++-- eng/pipelines/templates/stages/vmr-build.yml | 2 + src/SourceBuild/content/Directory.Build.props | 1 + src/SourceBuild/content/build.sh | 2 +- .../content/eng/extract-sdk-archive.proj | 20 +++++++ .../content/eng/finish-source-only.proj | 8 +-- .../CreateSdkSymbolsLayout.cs | 3 +- .../repo-projects/Directory.Build.props | 11 ++++ .../content/repo-projects/scenario-tests.proj | 55 ++++++++++++++++++- .../scenario-tests/Directory.Build.targets | 9 +++ .../test/scenario-tests/scenario-tests.proj | 17 ++++++ src/SourceBuild/content/test/tests.proj | 21 ++++++- .../0001-Disable-Aspire-scenario-test.patch | 23 ++++++++ .../0002-Disable-WPF-scenario-test.patch | 23 ++++++++ 14 files changed, 212 insertions(+), 16 deletions(-) create mode 100644 src/SourceBuild/content/eng/extract-sdk-archive.proj create mode 100644 src/SourceBuild/content/test/scenario-tests/Directory.Build.targets create mode 100644 src/SourceBuild/content/test/scenario-tests/scenario-tests.proj create mode 100644 src/SourceBuild/patches/scenario-tests/0001-Disable-Aspire-scenario-test.patch create mode 100644 src/SourceBuild/patches/scenario-tests/0002-Disable-WPF-scenario-test.patch diff --git a/eng/pipelines/templates/jobs/vmr-build.yml b/eng/pipelines/templates/jobs/vmr-build.yml index 68101af79673..1c0ba7b4e010 100644 --- a/eng/pipelines/templates/jobs/vmr-build.yml +++ b/eng/pipelines/templates/jobs/vmr-build.yml @@ -370,7 +370,7 @@ jobs: set -ex dockerVolumeArgs="-v $(sourcesPath):/vmr" - sourceOnlyArgs='' + customBuildArgs='' extraBuildProperties='' if [[ ! -z '${{ parameters.targetOS }}' ]]; then @@ -381,11 +381,15 @@ jobs: extraBuildProperties="$extraBuildProperties /p:TargetArchitecture=${{ parameters.targetArchitecture }}" fi + if [[ '${{ parameters.useDevVersions }}' == 'True' ]]; then + customBuildArgs="$customBuildArgs --dev" + fi + if [[ '${{ parameters.buildSourceOnly }}' == 'True' ]]; then if [[ '${{ parameters.enablePoison }}' == 'True' ]]; then - sourceOnlyArgs='--poison' + customBuildArgs="$customBuildArgs --poison" fi - sourceOnlyArgs="$sourceOnlyArgs --source-only /p:SmokeTestsWarnOnSdkContentDiffs=true /p:SmokeTestsExcludeOmniSharpTests=${{ parameters.excludeOmniSharpTests }}" + customBuildArgs="$customBuildArgs --source-only /p:SmokeTestsWarnOnSdkContentDiffs=true /p:SmokeTestsExcludeOmniSharpTests=${{ parameters.excludeOmniSharpTests }}" fi if [[ -n "${{ parameters.extraProperties }}" ]]; then @@ -394,10 +398,10 @@ jobs: # Only use Docker when a container is specified if [[ -n "${{ parameters.container }}" ]]; then - docker run --rm $dockerVolumeArgs -w /vmr ${{ parameters.container }} ./build.sh /bl:artifacts/log/Release/Test.binlog --test $sourceOnlyArgs $extraBuildProperties $(additionalBuildArgs) + docker run --rm $dockerVolumeArgs -w /vmr ${{ parameters.container }} ./build.sh /bl:artifacts/log/Release/Test.binlog --test $customBuildArgs $extraBuildProperties $(additionalBuildArgs) else cd $(sourcesPath) - ./build.sh /bl:artifacts/log/Release/Test.binlog --test $sourceOnlyArgs $extraBuildProperties $(additionalBuildArgs) + ./build.sh /bl:artifacts/log/Release/Test.binlog --test $customBuildArgs $extraBuildProperties $(additionalBuildArgs) fi displayName: Run Tests @@ -424,6 +428,10 @@ jobs: CopyWithRelativeFolders "src/" $targetFolder "*.binlog" CopyWithRelativeFolders "src/" $targetFolder "*.log" + if (Test-Path "artifacts/scenario-tests/") { + CopyWithRelativeFolders "artifacts/scenario-tests/" $targetFolder "*.binlog" + } + if (Test-Path "artifacts/TestResults/*") { CopyWithRelativeFolders "artifacts/TestResults/" $targetFolder "*.binlog" CopyWithRelativeFolders "artifacts/TestResults/" $targetFolder "*.diff" @@ -451,6 +459,7 @@ jobs: cd "$(sourcesPath)" find artifacts/log/ -type f -name "*.binlog" -exec rsync -R {} -t ${targetFolder} \; find artifacts/log/ -type f -name "*.log" -exec rsync -R {} -t ${targetFolder} \; + [ -d "artifacts/scenario-tests/" ] && find artifacts/scenario-tests/ -type f -name "*.binlog" -exec rsync -R {} -t ${targetFolder} \; find artifacts/TestResults/ -type f -name "*.binlog" -exec rsync -R {} -t ${targetFolder} \; find artifacts/TestResults/ -type f -name "*.diff" -exec rsync -R {} -t ${targetFolder} \; find artifacts/TestResults/ -type f -name "Updated*.txt" -exec rsync -R {} -t ${targetFolder} \; @@ -486,13 +495,25 @@ jobs: condition: succeededOrFailed() continueOnError: true inputs: - testRunner: vSTest + testRunner: VSTest testResultsFiles: 'artifacts/TestResults/Release/*.trx' searchFolder: $(sourcesPath) mergeTestResults: true publishRunAttachments: true testRunTitle: Tests_$(Agent.JobName) + - task: PublishTestResults@2 + displayName: Publish Scenario Test Results + condition: succeededOrFailed() + continueOnError: true + inputs: + testRunner: xUnit + testResultsFiles: 'artifacts/TestResults/**/scenario-tests/*.xml' + searchFolder: $(sourcesPath) + mergeTestResults: true + publishRunAttachments: true + testRunTitle: ScenarioTests_$(Agent.JobName) + - task: CopyFiles@2 inputs: SourceFolder: $(sourcesPath)/artifacts diff --git a/eng/pipelines/templates/stages/vmr-build.yml b/eng/pipelines/templates/stages/vmr-build.yml index 2f9c1ed10582..21e2c2ce6844 100644 --- a/eng/pipelines/templates/stages/vmr-build.yml +++ b/eng/pipelines/templates/stages/vmr-build.yml @@ -123,6 +123,7 @@ stages: artifactsRid: alpine.3.19-x64 pool: ${{ parameters.pool_Linux }} container: ${{ variables.alpine319Container }} + targetOS: linux-musl buildFromArchive: false # 🚫 buildSourceOnly: true # ✅ enablePoison: true # ✅ @@ -143,6 +144,7 @@ stages: architecture: x64 pool: ${{ parameters.pool_Linux }} container: ${{ variables.alpine319Container }} + targetOS: linux-musl buildFromArchive: false # 🚫 buildSourceOnly: true # ✅ enablePoison: false # 🚫 diff --git a/src/SourceBuild/content/Directory.Build.props b/src/SourceBuild/content/Directory.Build.props index d68801f19110..465fbad19cf3 100644 --- a/src/SourceBuild/content/Directory.Build.props +++ b/src/SourceBuild/content/Directory.Build.props @@ -160,6 +160,7 @@ $([MSBuild]::NormalizeDirectory('$(ArtifactsObjDir)', 'Symbols')) $([MSBuild]::NormalizeDirectory('$(ArtifactsObjDir)', 'AssetManifests')) $([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'assets', '$(Configuration)')) + $([MSBuild]::NormalizeDirectory('$(ArtifactsObjDir)', 'extracted-dotnet-sdk')) $([MSBuild]::NormalizeDirectory('$(PrereqsPackagesDir)', 'prebuilt')) $([MSBuild]::NormalizeDirectory('$(PrereqsPackagesDir)', 'previouslyRestored')) diff --git a/src/SourceBuild/content/build.sh b/src/SourceBuild/content/build.sh index abda941cccd8..252feba6fef1 100755 --- a/src/SourceBuild/content/build.sh +++ b/src/SourceBuild/content/build.sh @@ -162,7 +162,7 @@ while [[ $# > 0 ]]; do ;; # Advanced settings - -build-tests) + -build-repo-tests) properties="$properties /p:DotNetBuildTests=true" ;; -ci) diff --git a/src/SourceBuild/content/eng/extract-sdk-archive.proj b/src/SourceBuild/content/eng/extract-sdk-archive.proj new file mode 100644 index 000000000000..d170c43954ee --- /dev/null +++ b/src/SourceBuild/content/eng/extract-sdk-archive.proj @@ -0,0 +1,20 @@ + + + + $(NetCurrent) + + + + + + + + + diff --git a/src/SourceBuild/content/eng/finish-source-only.proj b/src/SourceBuild/content/eng/finish-source-only.proj index 24dc4a640f84..f6d93bcb29fd 100644 --- a/src/SourceBuild/content/eng/finish-source-only.proj +++ b/src/SourceBuild/content/eng/finish-source-only.proj @@ -10,6 +10,7 @@ + @@ -59,13 +60,9 @@ Outputs="$(SdkSymbolsTarball)"> $(BaseIntermediateOutputPath)SdkSymbols - $(BaseIntermediateOutputPath)Sdk - - - - @@ -76,7 +73,6 @@ - + false + + $([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'scenario-tests')) + $([MSBuild]::NormalizeDirectory('$(ArtifactsTestResultsDir)', 'scenario-tests')) + <_ScenarioTestsNuGetConfig>$(ScenarioTestsArtifactsDir)NuGet.config + <_InstallerNuGetConfig>$([MSBuild]::NormalizePath('$(SrcDir)', 'installer', 'NuGet.config')) + + + + + + + + + + + + <_CurrentDateTime>$([System.DateTime]::Now.ToString("yyyy-MM-dd_HH_mm_ss")) + <_TestXmlOutputPath>$(ScenarioTestsResultsDir)$(_CurrentDateTime).xml + <_ScenarioTestsAdditionalArgs>--xml $(_TestXmlOutputPath) --target-rid $(TargetRid) --no-cleanup --no-traits Category=MultiTFM + + + <_TestRoot>$(ScenarioTestsArtifactsDir)artifacts/ + + + <_DotNetTool>$(DotNetSdkExtractDir)$([System.IO.Path]::GetFileName('$(DotNetTool)')) + + + + + + <_ScenarioTestEnvVars Include=" + TestRoot=$(_TestRoot); + DotNetRoot=$(DotNetSdkExtractDir); + TestSdkVersion=$(SourceBuiltSdkVersion); + AdditionalTestArgs=$(_ScenarioTestsAdditionalArgs); + DotNetTool=$(_DotNetTool); + _InitializeDotNetCli=$(DotNetSdkExtractDir)" /> + + + + + diff --git a/src/SourceBuild/content/test/scenario-tests/Directory.Build.targets b/src/SourceBuild/content/test/scenario-tests/Directory.Build.targets new file mode 100644 index 000000000000..56dccb4796da --- /dev/null +++ b/src/SourceBuild/content/test/scenario-tests/Directory.Build.targets @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/SourceBuild/content/test/scenario-tests/scenario-tests.proj b/src/SourceBuild/content/test/scenario-tests/scenario-tests.proj new file mode 100644 index 000000000000..410ac2f54c4c --- /dev/null +++ b/src/SourceBuild/content/test/scenario-tests/scenario-tests.proj @@ -0,0 +1,17 @@ + + + + $(NetCurrent) + true + + + + + + + + diff --git a/src/SourceBuild/content/test/tests.proj b/src/SourceBuild/content/test/tests.proj index 582cb92574da..cf3d38e47075 100644 --- a/src/SourceBuild/content/test/tests.proj +++ b/src/SourceBuild/content/test/tests.proj @@ -1,10 +1,29 @@ + + <_RunScenarioTests>true + + + <_RunScenarioTests Condition="'$(BuildArchitecture.ToLowerInvariant())' != '$(TargetArchitecture.ToLowerInvariant())'">false + + + <_RunScenarioTests Condition="'$(BuildOS)' != 'windows' and '$(__PortableTargetOS.ToLowerInvariant())' != '$(TargetOS.ToLowerInvariant())'">false + + + <_RunScenarioTests Condition="'$(UseOfficialBuildVersioning)' == 'false'">false + + + + - \ No newline at end of file + diff --git a/src/SourceBuild/patches/scenario-tests/0001-Disable-Aspire-scenario-test.patch b/src/SourceBuild/patches/scenario-tests/0001-Disable-Aspire-scenario-test.patch new file mode 100644 index 000000000000..f2a5f62d399e --- /dev/null +++ b/src/SourceBuild/patches/scenario-tests/0001-Disable-Aspire-scenario-test.patch @@ -0,0 +1,23 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Matt Thalman +Date: Tue, 30 Apr 2024 08:34:08 -0500 +Subject: [PATCH] Disable Aspire scenario test + +Backport: https://github.com/dotnet/sdk/pull/40485 +--- + .../SdkTemplateTests.cs | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/Microsoft.DotNet.ScenarioTests.SdkTemplateTests/SdkTemplateTests.cs b/src/Microsoft.DotNet.ScenarioTests.SdkTemplateTests/SdkTemplateTests.cs +index c43fdd6..bb5c52d 100644 +--- a/src/Microsoft.DotNet.ScenarioTests.SdkTemplateTests/SdkTemplateTests.cs ++++ b/src/Microsoft.DotNet.ScenarioTests.SdkTemplateTests/SdkTemplateTests.cs +@@ -217,7 +217,7 @@ public class SdkTemplateTests : IClassFixture + newTest.Execute(_sdkHelper, _scenarioTestInput.TestRoot, "wasm-tools"); + } + +- [Fact] ++ //[Fact] + [Trait("Category", "Workload")] + [Trait("Category", "InProgress")] + public void VerifyAspireTemplate() diff --git a/src/SourceBuild/patches/scenario-tests/0002-Disable-WPF-scenario-test.patch b/src/SourceBuild/patches/scenario-tests/0002-Disable-WPF-scenario-test.patch new file mode 100644 index 000000000000..ba5dfa3aee6b --- /dev/null +++ b/src/SourceBuild/patches/scenario-tests/0002-Disable-WPF-scenario-test.patch @@ -0,0 +1,23 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Matt Thalman +Date: Tue, 30 Apr 2024 10:21:32 -0500 +Subject: [PATCH] Disable WPF scenario test + +Backport: https://github.com/dotnet/source-build/issues/4361 +--- + .../SdkTemplateTests.cs | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/Microsoft.DotNet.ScenarioTests.SdkTemplateTests/SdkTemplateTests.cs b/src/Microsoft.DotNet.ScenarioTests.SdkTemplateTests/SdkTemplateTests.cs +index c43fdd6..35279a9 100644 +--- a/src/Microsoft.DotNet.ScenarioTests.SdkTemplateTests/SdkTemplateTests.cs ++++ b/src/Microsoft.DotNet.ScenarioTests.SdkTemplateTests/SdkTemplateTests.cs +@@ -84,7 +84,7 @@ public class SdkTemplateTests : IClassFixture + newTest.Execute(_sdkHelper, _scenarioTestInput.TestRoot); + } + +- [Theory] ++ //[Theory] + [InlineData(DotNetLanguage.CSharp)] + [InlineData(DotNetLanguage.VB)] + [Trait("Category", "Offline")]