From ec6f14da69a19c606fb556c8498033839a4d8fca Mon Sep 17 00:00:00 2001 From: Michael Simons Date: Thu, 14 Apr 2022 12:48:49 -0500 Subject: [PATCH 01/10] Update MsftToSbSdk baseline in response to SBRP text-only package fix (#13628) --- .../assets/baselines/MsftToSbSdk.diff | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/assets/baselines/MsftToSbSdk.diff b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/assets/baselines/MsftToSbSdk.diff index 9a44f27de..4c334fee4 100644 --- a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/assets/baselines/MsftToSbSdk.diff +++ b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/assets/baselines/MsftToSbSdk.diff @@ -856,14 +856,6 @@ index ------------ ./sdk/x.y.z/SDKPrecomputedAssemblyReferences.cache ./sdk/x.y.z/SdkResolvers/ ./sdk/x.y.z/SdkResolvers/Microsoft.Build.NuGetSdkResolver/ -@@ ------------ @@ - ./sdk/x.y.z/Sdks/FSharp.NET.Sdk/Sdk/Sdk.props - ./sdk/x.y.z/Sdks/FSharp.NET.Sdk/Sdk/Sdk.targets - ./sdk/x.y.z/Sdks/Microsoft.Docker.Sdk/ -+./sdk/x.y.z/Sdks/Microsoft.Docker.Sdk/microsoft.docker.sdk.x.y.z.csproj - ./sdk/x.y.z/Sdks/Microsoft.Docker.Sdk/Sdk/ - ./sdk/x.y.z/Sdks/Microsoft.Docker.Sdk/Sdk/Sdk.props - ./sdk/x.y.z/Sdks/Microsoft.Docker.Sdk/Sdk/Sdk.targets @@ ------------ @@ ./sdk/x.y.z/Sdks/Microsoft.NET.ILLink.Tasks/tools/net472/System.Buffers.dll ./sdk/x.y.z/Sdks/Microsoft.NET.ILLink.Tasks/tools/net472/System.Collections.Immutable.dll @@ -1478,4 +1470,4 @@ index ------------ +./shared/Microsoft.AspNetCore.App/x.y.z/System.Text.Json.dll ./shared/Microsoft.AspNetCore.App/x.y.z/THIRD-PARTY-NOTICES.txt ./shared/Microsoft.NETCore.App/ - ./shared/Microsoft.NETCore.App/x.y.z/ + ./shared/Microsoft.NETCore.App/x.y.z/ \ No newline at end of file From 3da46c012c74ad3d2cdc20dec1049a8afbe08404 Mon Sep 17 00:00:00 2001 From: Michael Simons Date: Thu, 14 Apr 2022 16:20:25 -0500 Subject: [PATCH 02/10] Add retry to omnisharp download (#13639) --- .../Config.cs | 1 + .../HttpClientExtensions.cs | 16 +++-- .../OmniSharpTests.cs | 4 +- .../Utilities.cs | 58 +++++++++++++++++++ 4 files changed, 73 insertions(+), 6 deletions(-) create mode 100644 src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/Utilities.cs diff --git a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/Config.cs b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/Config.cs index 67b5bfc78..fc077fb19 100644 --- a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/Config.cs +++ b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/Config.cs @@ -30,6 +30,7 @@ internal static class Config public static string? SdkTarballPath { get; } = Environment.GetEnvironmentVariable(SdkTarballPathEnv); public static string TargetRid { get; } = Environment.GetEnvironmentVariable(TargetRidEnv) ?? throw new InvalidOperationException($"'{Config.TargetRidEnv}' must be specified"); + public static string TargetArchitecture { get; } = TargetRid.Split('-')[1]; public static bool WarnOnPoisonDiffs { get; } = bool.TryParse(Environment.GetEnvironmentVariable(WarnPoisonDiffsEnv), out bool excludeOnlineTests) && excludeOnlineTests; public static bool WarnOnSdkContentDiffs { get; } = diff --git a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/HttpClientExtensions.cs b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/HttpClientExtensions.cs index 77115c981..b0f778fa6 100644 --- a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/HttpClientExtensions.cs +++ b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/HttpClientExtensions.cs @@ -6,15 +6,23 @@ using System; using System.IO; using System.Net.Http; using System.Threading.Tasks; +using Xunit.Abstractions; namespace Microsoft.DotNet.SourceBuild.SmokeTests; internal static class HttpClientExtensions { - public static async Task DownloadFileAsync(this HttpClient client, Uri uri, string path) + public static async Task DownloadFileAsync(this HttpClient client, Uri uri, string path, ITestOutputHelper outputHelper) { - using Stream stream = await client.GetStreamAsync(uri); - using FileStream fileStream = new(path, FileMode.OpenOrCreate); - await stream.CopyToAsync(fileStream); + outputHelper.WriteLine($"Downloading {uri}"); + + await Utilities.RetryAsync( + async () => + { + using Stream stream = await client.GetStreamAsync(uri); + using FileStream fileStream = new(path, FileMode.OpenOrCreate); + await stream.CopyToAsync(fileStream); + }, + outputHelper); } } diff --git a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/OmniSharpTests.cs b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/OmniSharpTests.cs index 50788019c..56f14043b 100644 --- a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/OmniSharpTests.cs +++ b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/OmniSharpTests.cs @@ -60,9 +60,9 @@ public class OmniSharpTests : SmokeTests if (!Directory.Exists(OmniSharpDirectory)) { using HttpClient client = new(); - string omniSharpTarballFile = "omnisharp-linux-x64.tar.gz"; + string omniSharpTarballFile = $"omnisharp-linux-{Config.TargetArchitecture}.tar.gz"; Uri omniSharpTarballUrl = new($"https://github.com/OmniSharp/omnisharp-roslyn/releases/latest/download/{omniSharpTarballFile}"); - await client.DownloadFileAsync(omniSharpTarballUrl, omniSharpTarballFile); + await client.DownloadFileAsync(omniSharpTarballUrl, omniSharpTarballFile, OutputHelper); Directory.CreateDirectory(OmniSharpDirectory); ExecuteHelper.ExecuteProcessValidateExitCode("tar", $"xzf {omniSharpTarballFile} -C {OmniSharpDirectory}", OutputHelper); diff --git a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/Utilities.cs b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/Utilities.cs new file mode 100644 index 000000000..d706d3972 --- /dev/null +++ b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/Utilities.cs @@ -0,0 +1,58 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Threading; +using System.Threading.Tasks; +using Xunit.Abstractions; + +namespace Microsoft.DotNet.SourceBuild.SmokeTests; + +public static class Utilities +{ + public static async Task RetryAsync(Func executor, ITestOutputHelper outputHelper) + { + await Utilities.RetryAsync( + async () => + { + try + { + await executor(); + return null; + } + catch (Exception e) + { + return e; + } + }, + outputHelper); + } + + private static async Task RetryAsync(Func> executor, ITestOutputHelper outputHelper) + { + const int maxRetries = 5; + const int waitFactor = 5; + + int retryCount = 0; + + Exception? exception = await executor(); + while (exception != null) + { + retryCount++; + if (retryCount >= maxRetries) + { + throw new InvalidOperationException($"Failed after {retryCount} retries.", exception); + } + + int waitTime = Convert.ToInt32(Math.Pow(waitFactor, retryCount - 1)); + if (outputHelper != null) + { + outputHelper.WriteLine($"Retry {retryCount}/{maxRetries}, retrying in {waitTime} seconds..."); + } + + Thread.Sleep(TimeSpan.FromSeconds(waitTime)); + exception = await executor(); + } + } +} From 1f059f340cc085ef12b8687e2fcac609d63b4e45 Mon Sep 17 00:00:00 2001 From: Michael Simons Date: Thu, 14 Apr 2022 19:14:43 -0500 Subject: [PATCH 03/10] [source-build] Expose CleanWhileBuilding msbuild option in build.sh (#13642) --- .../templates/job/source-build-build-tarball.yml | 2 +- src/SourceBuild/tarball/content/build.sh | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/SourceBuild/Arcade/eng/common/templates/job/source-build-build-tarball.yml b/src/SourceBuild/Arcade/eng/common/templates/job/source-build-build-tarball.yml index 7ce2ad732..24b93ffc4 100644 --- a/src/SourceBuild/Arcade/eng/common/templates/job/source-build-build-tarball.yml +++ b/src/SourceBuild/Arcade/eng/common/templates/job/source-build-build-tarball.yml @@ -132,7 +132,7 @@ jobs: customBuildArgs="$customBuildArgs --poison" fi - docker run --rm -v $(tarballDir):/tarball -w /tarball ${networkArgs} $(_Container) ./build.sh ${customBuildArgs} $(additionalBuildArgs) -- /p:CleanWhileBuilding=true + docker run --rm -v $(tarballDir):/tarball -w /tarball ${networkArgs} $(_Container) ./build.sh --clean-while-building ${customBuildArgs} $(additionalBuildArgs) displayName: Build Tarball - script: | diff --git a/src/SourceBuild/tarball/content/build.sh b/src/SourceBuild/tarball/content/build.sh index 29ca1644b..39e5fbd11 100755 --- a/src/SourceBuild/tarball/content/build.sh +++ b/src/SourceBuild/tarball/content/build.sh @@ -5,11 +5,12 @@ IFS=$'\n\t' usage() { echo "usage: $0 [options]" echo "options:" + echo " --clean-while-building cleans each repo after building (reduces disk space usage)" echo " --online build using online sources" - echo " --with-packages use the specified directory of previously-built packages" - echo " --with-sdk use the SDK in the specified directory for bootstrapping" echo " --poison build with poisoning checks" echo " --run-smoke-test don't build; run smoke tests" + echo " --with-packages use the specified directory of previously-built packages" + echo " --with-sdk use the SDK in the specified directory for bootstrapping" echo "use -- to send the remaining arguments to MSBuild" echo "" } @@ -29,9 +30,8 @@ while :; do lowerI="$(echo $1 | awk '{print tolower($0)}')" case $lowerI in - --run-smoke-test) - alternateTarget=true - MSBUILD_ARGUMENTS+=( "/t:RunSmokeTest" ) + --clean-while-building) + MSBUILD_ARGUMENTS+=( "/p:CleanWhileBuilding=true") ;; --online) MSBUILD_ARGUMENTS+=( "/p:BuildWithOnlineSources=true") @@ -39,6 +39,10 @@ while :; do --poison) MSBUILD_ARGUMENTS+=( "/p:EnablePoison=true") ;; + --run-smoke-test) + alternateTarget=true + MSBUILD_ARGUMENTS+=( "/t:RunSmokeTest" ) + ;; --with-packages) CUSTOM_PREVIOUSLY_BUILT_PACKAGES_DIR="$(cd -P "$2" && pwd)" if [ ! -d "$CUSTOM_PREVIOUSLY_BUILT_PACKAGES_DIR" ]; then From 5609d7db883a5af9da761cdcebec236077c6b15b Mon Sep 17 00:00:00 2001 From: Michael Simons Date: Thu, 14 Apr 2022 20:19:51 -0500 Subject: [PATCH 04/10] Exclude sdk content tests in PR validation and public CI (#13644) --- .../eng/common/templates/job/source-build-build-tarball.yml | 2 +- .../common/templates/job/source-build-run-tarball-build.yml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/SourceBuild/Arcade/eng/common/templates/job/source-build-build-tarball.yml b/src/SourceBuild/Arcade/eng/common/templates/job/source-build-build-tarball.yml index 24b93ffc4..ff035940f 100644 --- a/src/SourceBuild/Arcade/eng/common/templates/job/source-build-build-tarball.yml +++ b/src/SourceBuild/Arcade/eng/common/templates/job/source-build-build-tarball.yml @@ -146,7 +146,7 @@ jobs: dockerEnvArgs="-e SMOKE_TESTS_EXCLUDE_OMNISHARP=$(_ExcludeOmniSharpTests) -e SMOKE_TESTS_WARN_SDK_CONTENT_DIFFS=true" poisonArg='' - if [[ '${{ parameters.excludeSdkContentTests}}' != 'true' && '${{ parameters.installerBuildResourceId }}' != 'current' ]]; then + if [[ '${{ parameters.excludeSdkContentTests}}' != 'true' ]]; then dockerVolumeArgs+=" -v $(PIPELINE.WORKSPACE)/${{ parameters.installerBuildResourceId }}/BlobArtifacts/:/BlobArtifacts" msftSdkTarballName=$(find "$(PIPELINE.WORKSPACE)/${{ parameters.installerBuildResourceId }}/BlobArtifacts/" -name "dotnet-sdk-*-linux-${{ parameters.architecture }}.tar.gz" -exec basename {} \;) dockerEnvArgs+=" -e SMOKE_TESTS_MSFT_SDK_TARBALL_PATH=/BlobArtifacts/$msftSdkTarballName" diff --git a/src/SourceBuild/Arcade/eng/common/templates/job/source-build-run-tarball-build.yml b/src/SourceBuild/Arcade/eng/common/templates/job/source-build-run-tarball-build.yml index d9651229b..c8a0a71f1 100644 --- a/src/SourceBuild/Arcade/eng/common/templates/job/source-build-run-tarball-build.yml +++ b/src/SourceBuild/Arcade/eng/common/templates/job/source-build-run-tarball-build.yml @@ -34,6 +34,8 @@ jobs: architecture: x64 condition: ${{ parameters.condition }} dependsOn: ${{ parameters.dependsOn }} + ${{ if or(eq(variables['System.TeamProject'], 'public'), in(variables['Build.Reason'], 'PullRequest')) }}: + excludeSdkContentTests: true installerBuildResourceId: ${{ parameters.installerBuildResourceId }} matrix: CentOS7-Online: @@ -86,6 +88,8 @@ jobs: architecture: arm64 condition: ${{ parameters.condition }} dependsOn: ${{ parameters.dependsOn }} + ${{ if in(variables['Build.Reason'], 'PullRequest') }}: + excludeSdkContentTests: true installerBuildResourceId: ${{ parameters.installerBuildResourceId }} matrix: ${{ if ne(variables['Build.Reason'], 'PullRequest') }}: From 21c7bb3abb36a3592eac54d210520219cbc76e4f Mon Sep 17 00:00:00 2001 From: Michael Simons Date: Fri, 15 Apr 2022 15:24:48 -0500 Subject: [PATCH 05/10] Fix threading issue in ExecuteHelper (#13643) --- .../DotNetHelper.cs | 17 ++-- .../ExecuteHelper.cs | 18 +++- .../SkippableFactAttribute.cs | 49 +++++----- .../SkippableTheoryAttribute.cs | 23 +++-- .../TestScenario.cs | 95 +++++++++---------- 5 files changed, 104 insertions(+), 98 deletions(-) diff --git a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/DotNetHelper.cs b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/DotNetHelper.cs index 7c263e080..a9361453e 100644 --- a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/DotNetHelper.cs +++ b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/DotNetHelper.cs @@ -5,7 +5,6 @@ using System; using System.Diagnostics; using System.IO; -using Xunit; using Xunit.Abstractions; namespace Microsoft.DotNet.SourceBuild.SmokeTests; @@ -81,15 +80,6 @@ internal class DotNetHelper public void ExecuteCmd(string args, string? workingDirectory = null, Action? additionalProcessConfigCallback = null, int expectedExitCode = 0, int millisecondTimeout = -1) { - Action configureProcess = (Process process, string? workingDirectory) => { - ConfigureProcess(process, workingDirectory); - - if (additionalProcessConfigCallback != null) - { - additionalProcessConfigCallback(process); - } - }; - (Process Process, string StdOut, string StdErr) executeResult = ExecuteHelper.ExecuteProcess( DotNetPath, args, @@ -98,6 +88,13 @@ internal class DotNetHelper millisecondTimeout: millisecondTimeout); ExecuteHelper.ValidateExitCode(executeResult, expectedExitCode); + + void configureProcess(Process process, string? workingDirectory) + { + ConfigureProcess(process, workingDirectory); + + additionalProcessConfigCallback?.Invoke(process); + } } public static void ConfigureProcess(Process process, string? workingDirectory, bool setPath = false) diff --git a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/ExecuteHelper.cs b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/ExecuteHelper.cs index 4a7b87750..62e1eb594 100644 --- a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/ExecuteHelper.cs +++ b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/ExecuteHelper.cs @@ -44,10 +44,24 @@ internal static class ExecuteHelper configure?.Invoke(process); StringBuilder stdOutput = new(); - process.OutputDataReceived += new DataReceivedEventHandler((sender, e) => stdOutput.AppendLine(e.Data)); + process.OutputDataReceived += new DataReceivedEventHandler( + (sender, e) => + { + lock (stdOutput) + { + stdOutput.AppendLine(e.Data); + } + }); StringBuilder stdError = new(); - process.ErrorDataReceived += new DataReceivedEventHandler((sender, e) => stdError.AppendLine(e.Data)); + process.ErrorDataReceived += new DataReceivedEventHandler( + (sender, e) => + { + lock (stdError) + { + stdError.AppendLine(e.Data); + } + }); process.Start(); process.BeginOutputReadLine(); diff --git a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/SkippableFactAttribute.cs b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/SkippableFactAttribute.cs index fbe57433f..867bb77a5 100644 --- a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/SkippableFactAttribute.cs +++ b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/SkippableFactAttribute.cs @@ -5,35 +5,34 @@ using System; using Xunit; -namespace Microsoft.DotNet.SourceBuild.SmokeTests +namespace Microsoft.DotNet.SourceBuild.SmokeTests; + +/// +/// A Fact that will be skipped based on the specified environment variable's value. +/// +internal class SkippableFactAttribute : FactAttribute { - /// - /// A Fact that will be skipped based on the specified environment variable's value. - /// - internal class SkippableFactAttribute : FactAttribute + public SkippableFactAttribute(string envName, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) => + CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envName); + + public SkippableFactAttribute(string[] envNames, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) => + CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envNames); + + public static void CheckEnvs(bool skipOnNullOrWhiteSpace, bool skipOnTrue, Action setSkip, params string[] envNames) { - public SkippableFactAttribute(string envName, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) => - CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envName); - - public SkippableFactAttribute(string[] envNames, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) => - CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envNames); - - public static void CheckEnvs(bool skipOnNullOrWhiteSpace, bool skipOnTrue, Action setSkip, params string[] envNames) + foreach (string envName in envNames) { - foreach (string envName in envNames) - { - string? envValue = Environment.GetEnvironmentVariable(envName); + string? envValue = Environment.GetEnvironmentVariable(envName); - if (skipOnNullOrWhiteSpace && string.IsNullOrWhiteSpace(envValue)) - { - setSkip($"Skipping because `{envName}` is null or whitespace"); - break; - } - else if (skipOnTrue && bool.TryParse(envValue, out bool boolValue) && boolValue) - { - setSkip($"Skipping because `{envName}` is set to True"); - break; - } + if (skipOnNullOrWhiteSpace && string.IsNullOrWhiteSpace(envValue)) + { + setSkip($"Skipping because `{envName}` is null or whitespace"); + break; + } + else if (skipOnTrue && bool.TryParse(envValue, out bool boolValue) && boolValue) + { + setSkip($"Skipping because `{envName}` is set to True"); + break; } } } diff --git a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/SkippableTheoryAttribute.cs b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/SkippableTheoryAttribute.cs index 8ce5a4881..32a7179a1 100644 --- a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/SkippableTheoryAttribute.cs +++ b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/SkippableTheoryAttribute.cs @@ -4,17 +4,16 @@ using Xunit; -namespace Microsoft.DotNet.SourceBuild.SmokeTests -{ - /// - /// A Theory that will be skipped based on the specified environment variable's value. - /// - internal class SkippableTheoryAttribute : TheoryAttribute - { - public SkippableTheoryAttribute(string envName, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) => - SkippableFactAttribute.CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envName); +namespace Microsoft.DotNet.SourceBuild.SmokeTests; - public SkippableTheoryAttribute(string[] envNames, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) => - SkippableFactAttribute.CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envNames); - } +/// +/// A Theory that will be skipped based on the specified environment variable's value. +/// +internal class SkippableTheoryAttribute : TheoryAttribute +{ + public SkippableTheoryAttribute(string envName, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) => + SkippableFactAttribute.CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envName); + + public SkippableTheoryAttribute(string[] envNames, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) => + SkippableFactAttribute.CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envNames); } diff --git a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/TestScenario.cs b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/TestScenario.cs index 29f3259c1..f5a04de1e 100644 --- a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/TestScenario.cs +++ b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/TestScenario.cs @@ -2,66 +2,63 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; +namespace Microsoft.DotNet.SourceBuild.SmokeTests; -namespace Microsoft.DotNet.SourceBuild.SmokeTests +public class TestScenario { - public class TestScenario + public DotNetActions Commands { get; } + public DotNetLanguage Language { get; } + public bool NoHttps { get; set; } = Config.TargetRid.Contains("osx"); + public string ScenarioName { get; } + public DotNetTemplate Template { get; } + + public TestScenario(string scenarioName, DotNetLanguage language, DotNetTemplate template, DotNetActions commands = DotNetActions.None) { - public DotNetActions Commands { get; } - public DotNetLanguage Language { get; } - public bool NoHttps { get; set; } = Config.TargetRid.Contains("osx"); - public string ScenarioName { get; } - public DotNetTemplate Template { get; } + ScenarioName = scenarioName; + Template = template; + Language = language; + Commands = commands; + } - public TestScenario(string scenarioName, DotNetLanguage language, DotNetTemplate template, DotNetActions commands = DotNetActions.None) + internal void Execute(DotNetHelper dotNetHelper) + { + // Don't use the cli language name in the project name because it may contain '#': https://github.com/dotnet/roslyn/issues/51692 + string projectName = $"{ScenarioName}_{Template}_{Language}"; + string customNewArgs = Template.IsAspNetCore() && NoHttps ? "--no-https" : string.Empty; + dotNetHelper.ExecuteNew(Template.GetName(), projectName, Language.ToCliName(), customArgs: customNewArgs); + + if (Commands.HasFlag(DotNetActions.Build)) { - ScenarioName = scenarioName; - Template = template; - Language = language; - Commands = commands; + dotNetHelper.ExecuteBuild(projectName); } - - internal void Execute(DotNetHelper dotNetHelper) + if (Commands.HasFlag(DotNetActions.Run)) { - // Don't use the cli language name in the project name because it may contain '#': https://github.com/dotnet/roslyn/issues/51692 - string projectName = $"{ScenarioName}_{Template}_{Language}"; - string customNewArgs = Template.IsAspNetCore() && NoHttps ? "--no-https" : string.Empty; - dotNetHelper.ExecuteNew(Template.GetName(), projectName, Language.ToCliName(), customArgs: customNewArgs); - - if (Commands.HasFlag(DotNetActions.Build)) + if (Template.IsAspNetCore()) { - dotNetHelper.ExecuteBuild(projectName); + dotNetHelper.ExecuteRunWeb(projectName); } - if (Commands.HasFlag(DotNetActions.Run)) + else { - if (Template.IsAspNetCore()) - { - dotNetHelper.ExecuteRunWeb(projectName); - } - else - { - dotNetHelper.ExecuteRun(projectName); - } - } - if (Commands.HasFlag(DotNetActions.Publish)) - { - dotNetHelper.ExecutePublish(projectName); - } - if (Commands.HasFlag(DotNetActions.PublishComplex)) - { - dotNetHelper.ExecutePublish(projectName, selfContained: false); - dotNetHelper.ExecutePublish(projectName, selfContained: true, Config.TargetRid); - dotNetHelper.ExecutePublish(projectName, selfContained: true, "linux-x64"); - } - if (Commands.HasFlag(DotNetActions.PublishR2R)) - { - dotNetHelper.ExecutePublish(projectName, selfContained: true, "linux-x64", trimmed: true, readyToRun: true); - } - if (Commands.HasFlag(DotNetActions.Test)) - { - dotNetHelper.ExecuteTest(projectName); + dotNetHelper.ExecuteRun(projectName); } } + if (Commands.HasFlag(DotNetActions.Publish)) + { + dotNetHelper.ExecutePublish(projectName); + } + if (Commands.HasFlag(DotNetActions.PublishComplex)) + { + dotNetHelper.ExecutePublish(projectName, selfContained: false); + dotNetHelper.ExecutePublish(projectName, selfContained: true, Config.TargetRid); + dotNetHelper.ExecutePublish(projectName, selfContained: true, "linux-x64"); + } + if (Commands.HasFlag(DotNetActions.PublishR2R)) + { + dotNetHelper.ExecutePublish(projectName, selfContained: true, "linux-x64", trimmed: true, readyToRun: true); + } + if (Commands.HasFlag(DotNetActions.Test)) + { + dotNetHelper.ExecuteTest(projectName); + } } } From e44e5907d65cd4af06748c309bd875833e4471ff Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Tue, 19 Apr 2022 14:44:59 +0100 Subject: [PATCH 06/10] Fix compatibility with BSD df (#13653) --- .../tarball/content/repos/Directory.Build.targets | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SourceBuild/tarball/content/repos/Directory.Build.targets b/src/SourceBuild/tarball/content/repos/Directory.Build.targets index e49bb87ef..ab338c52e 100644 --- a/src/SourceBuild/tarball/content/repos/Directory.Build.targets +++ b/src/SourceBuild/tarball/content/repos/Directory.Build.targets @@ -561,20 +561,20 @@ BeforeTargets="Build" Condition=" '$(CleanWhileBuilding)' == 'true' "> - + - + - + Date: Tue, 19 Apr 2022 15:55:14 +0000 Subject: [PATCH 07/10] Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220419.1 Microsoft.SourceBuild.Intermediate.source-build-reference-packages From Version 6.0.0-servicing.22213.1 -> To Version 6.0.0-servicing.22219.1 --- NuGet.config | 4 ---- eng/Version.Details.xml | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/NuGet.config b/NuGet.config index f03617759..941bd870a 100644 --- a/NuGet.config +++ b/NuGet.config @@ -9,10 +9,6 @@ - - - - diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 51284cde3..cdb415346 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -215,9 +215,9 @@ https://github.com/dotnet/arcade 1a6b24397e50146d0fece9cfb9c0b87275691e6f - + https://github.com/dotnet/source-build-reference-packages - 60845bf36f0dd6dd310070548a58cb8ad3ab513c + bb35f199756a8b45dacb1025d72419f6ea5ff1a4 From 65dd7c1427cd15b60b4a16c5207a98e8bd6ddb37 Mon Sep 17 00:00:00 2001 From: Michael Simons Date: Tue, 19 Apr 2022 17:00:36 -0500 Subject: [PATCH 08/10] Remove net TFMs from xml doc baseline (#13662) --- .../BaselineHelper.cs | 12 ++- .../XmlDocTests.cs | 1 + .../assets/baselines/MissingXmlDoc.txt | 102 +++++++++--------- 3 files changed, 60 insertions(+), 55 deletions(-) diff --git a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/BaselineHelper.cs b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/BaselineHelper.cs index 8070b2576..32a23d76f 100644 --- a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/BaselineHelper.cs +++ b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/BaselineHelper.cs @@ -85,6 +85,13 @@ namespace Microsoft.DotNet.SourceBuild.SmokeTests private static string GetBaselineFilePath(string baselineFileName) => Path.Combine(GetAssetsDirectory(), "baselines", baselineFileName); + public static string RemoveNetTfmPaths(string source) + { + string pathSeparator = Regex.Escape(Path.DirectorySeparatorChar.ToString()); + Regex netTfmRegex = new($"{pathSeparator}net[1-9]+\\.[0-9]+{pathSeparator}"); + return netTfmRegex.Replace(source, $"{Path.DirectorySeparatorChar}netx.y{Path.DirectorySeparatorChar}"); + } + public static string RemoveRids(string diff, bool isPortable = false) => isPortable ? diff.Replace(Config.PortableRid, "portable-rid") : diff.Replace(Config.TargetRid, "banana-rid"); @@ -98,10 +105,7 @@ namespace Microsoft.DotNet.SourceBuild.SmokeTests + $"?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?"); string result = semanticVersionRegex.Replace(source, $"x.y.z"); - // Remove netx.y path segments - string pathSeparator = Regex.Escape(Path.DirectorySeparatorChar.ToString()); - Regex netTfmRegex = new($"{pathSeparator}net[1-9]+\\.[0-9]+{pathSeparator}"); - return netTfmRegex.Replace(result, $"{Path.DirectorySeparatorChar}netx.y{Path.DirectorySeparatorChar}"); + return RemoveNetTfmPaths(result); } } } diff --git a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/XmlDocTests.cs b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/XmlDocTests.cs index e99125700..00c0c2b79 100644 --- a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/XmlDocTests.cs +++ b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/XmlDocTests.cs @@ -37,6 +37,7 @@ public class XmlDocTests : SmokeTests string pathWithoutPacksPrefix = xmlFile[(targetingPacksDirectory.Length + 1)..]; string[] pathParts = pathWithoutPacksPrefix.Split(Path.DirectorySeparatorChar); string pathWithoutVersion = string.Join(Path.DirectorySeparatorChar, pathParts.Take(1).Concat(pathParts.Skip(2))); + pathWithoutVersion = BaselineHelper.RemoveNetTfmPaths(pathWithoutVersion); missingXmlDoc.Add(pathWithoutVersion); } } diff --git a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/assets/baselines/MissingXmlDoc.txt b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/assets/baselines/MissingXmlDoc.txt index 8db91d9d7..38f80e186 100644 --- a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/assets/baselines/MissingXmlDoc.txt +++ b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/assets/baselines/MissingXmlDoc.txt @@ -2,57 +2,57 @@ Microsoft.AspNetCore.App.Ref/analyzers/dotnet/cs/Microsoft.AspNetCore.App.Analyz Microsoft.AspNetCore.App.Ref/analyzers/dotnet/cs/Microsoft.AspNetCore.App.CodeFixes.xml Microsoft.AspNetCore.App.Ref/analyzers/dotnet/roslyn4.0/cs/Microsoft.Extensions.Logging.Generators.xml Microsoft.NETCore.App.Ref/analyzers/dotnet/cs/System.Text.Json.SourceGeneration.xml -Microsoft.NETCore.App.Ref/ref/net6.0/Microsoft.VisualBasic.xml -Microsoft.NETCore.App.Ref/ref/net6.0/mscorlib.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.AppContext.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Buffers.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.ComponentModel.DataAnnotations.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Configuration.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Core.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Data.DataSetExtensions.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Data.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Diagnostics.Debug.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Diagnostics.Tools.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Drawing.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Dynamic.Runtime.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Globalization.Calendars.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Globalization.Extensions.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Globalization.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.IO.Compression.Brotli.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.IO.Compression.FileSystem.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.IO.FileSystem.Primitives.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.IO.FileSystem.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.IO.UnmanagedMemoryStream.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.IO.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Net.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Numerics.Vectors.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Numerics.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Reflection.Extensions.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Reflection.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Resources.Reader.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Resources.ResourceManager.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Runtime.Extensions.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Runtime.Handles.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Runtime.Serialization.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Security.Principal.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Security.SecureString.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Security.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.ServiceModel.Web.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.ServiceProcess.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Text.Encoding.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Threading.Tasks.Extensions.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Threading.Tasks.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Threading.Timer.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Transactions.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.ValueTuple.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Web.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Windows.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Xml.Linq.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Xml.Serialization.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Xml.xml -Microsoft.NETCore.App.Ref/ref/net6.0/System.Xml.XmlDocument.xml -Microsoft.NETCore.App.Ref/ref/net6.0/WindowsBase.xml +Microsoft.NETCore.App.Ref/ref/netx.y/Microsoft.VisualBasic.xml +Microsoft.NETCore.App.Ref/ref/netx.y/mscorlib.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.AppContext.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Buffers.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.ComponentModel.DataAnnotations.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Configuration.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Core.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Data.DataSetExtensions.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Data.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Diagnostics.Debug.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Diagnostics.Tools.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Drawing.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Dynamic.Runtime.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Globalization.Calendars.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Globalization.Extensions.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Globalization.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.IO.Compression.Brotli.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.IO.Compression.FileSystem.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.IO.FileSystem.Primitives.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.IO.FileSystem.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.IO.UnmanagedMemoryStream.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.IO.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Net.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Numerics.Vectors.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Numerics.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Reflection.Extensions.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Reflection.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Resources.Reader.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Resources.ResourceManager.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Runtime.Extensions.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Runtime.Handles.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Runtime.Serialization.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Security.Principal.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Security.SecureString.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Security.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.ServiceModel.Web.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.ServiceProcess.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Text.Encoding.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Threading.Tasks.Extensions.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Threading.Tasks.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Threading.Timer.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Transactions.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.ValueTuple.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Web.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Windows.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Xml.Linq.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Xml.Serialization.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Xml.xml +Microsoft.NETCore.App.Ref/ref/netx.y/System.Xml.XmlDocument.xml +Microsoft.NETCore.App.Ref/ref/netx.y/WindowsBase.xml NETStandard.Library.Ref/ref/netstandard2.1/Microsoft.Win32.Primitives.xml NETStandard.Library.Ref/ref/netstandard2.1/mscorlib.xml NETStandard.Library.Ref/ref/netstandard2.1/System.AppContext.xml From f0800059e3ea365d4d6ae931a6613cdfc4a268a3 Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Wed, 20 Apr 2022 01:27:33 -0700 Subject: [PATCH 09/10] Restore the version.details.xml file --- eng/Version.Details.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index cdb415346..51284cde3 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -215,9 +215,9 @@ https://github.com/dotnet/arcade 1a6b24397e50146d0fece9cfb9c0b87275691e6f - + https://github.com/dotnet/source-build-reference-packages - bb35f199756a8b45dacb1025d72419f6ea5ff1a4 + 60845bf36f0dd6dd310070548a58cb8ad3ab513c From bf78d7434c070d829eefd75c483c21061983d404 Mon Sep 17 00:00:00 2001 From: Jason Zhai Date: Wed, 20 Apr 2022 01:29:10 -0700 Subject: [PATCH 10/10] Restore the nuget.config file --- NuGet.config | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NuGet.config b/NuGet.config index 941bd870a..f03617759 100644 --- a/NuGet.config +++ b/NuGet.config @@ -9,6 +9,10 @@ + + + +