From b627355948b85060db8d191f4c00e0392a739498 Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Sun, 7 Mar 2021 18:53:45 -0800 Subject: [PATCH 1/4] Correct and streamline internal builds - correct manual internal builds - need to explicitly set `$(BuildNumber)` property in all build steps - rename `$(BuildScriptArgs)` to avoid circular reference - skip tests by default in internal non-PR builds nits: - include new `$(BuildNumberArg)` in `$(SharedFxArgs)` - run all test jobs in internal pull requests --- .azure/pipelines/ci.yml | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/.azure/pipelines/ci.yml b/.azure/pipelines/ci.yml index 8437936e9b54..aeef07331b1a 100644 --- a/.azure/pipelines/ci.yml +++ b/.azure/pipelines/ci.yml @@ -20,16 +20,17 @@ variables: - name: TeamName value: AspNetCore - ${{ if eq(variables['System.TeamProject'], 'public') }}: - - name: BuildScriptArgs + - name: BuildNumberArg value: '' - ${{ if ne(variables['System.TeamProject'], 'public') }}: - - name: BuildScriptArgs + - name: BuildNumberArg value: '/p:BuildNumber=$(Build.BuildId)' - name: SharedFxArgs value: '/t:Prepare /t:Restore /t:GeneratePropsFiles - /t:BuildSharedFx' + /t:BuildSharedFx + $(BuildNumberArg)' jobs: - template: jobs/default-build.yml @@ -37,22 +38,29 @@ jobs: jobName: Windows_Build jobDisplayName: "Build and test: Windows" agentOs: Windows + buildArgs: $(BuildNumberArg) codeSign: true beforeBuild: - powershell: "& ./src/Servers/IIS/tools/UpdateIISExpressCertificate.ps1" displayName: Setup IISExpress test certificates -# Unix test jobs only run on public CI builds -- ${{ if eq(variables['System.TeamProject'], 'public') }}: + # Skip tests by default in internal non-PR builds. + ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: + variables: + PB_SKIPTESTS: ${{ coalesce(variables.PB_SKIPTESTS, 'true') }} +# Unix test jobs only run on public CI builds and PRs +- ${{ if or(eq(variables['System.TeamProject'], 'public'), in(variables['Build.Reason'], 'PullRequest')) }}: - template: jobs/default-build.yml parameters: jobName: MacOs_Build jobDisplayName: "Build and test : MacOS" agentOs: MacOS + buildArgs: $(BuildNumberArg) - template: jobs/default-build.yml parameters: jobName: Linux_Build jobDisplayName: "Build and test : Linux" agentOs: Linux + buildArgs: $(BuildNumberArg) - ${{ if eq(variables['System.TeamProject'], 'internal') }}: - job: Windows_SharedFx @@ -102,7 +110,6 @@ jobs: - script: .\build.cmd -ci /p:SignType=$(_SignType) - $(BuildScriptArgs) $(SharedFxArgs) /p:SharedFxRID=win-x64 /bl:artifacts/logs/SharedFx-win-x64.binlog @@ -118,7 +125,6 @@ jobs: - script: .\build.cmd -ci /p:SignType=$(_SignType) - $(BuildScriptArgs) $(SharedFxArgs) /p:SharedFxRID=win-x86 /bl:artifacts/logs/SharedFx-win-x86.binlog @@ -134,7 +140,7 @@ jobs: - script: .\build.cmd -ci /p:SignType=$(_SignType) - $(BuildScriptArgs) + $(BuildNumberArg) /p:SkipArtifactInfoTargets=true /p:DisableSignCheck=true /t:DoCodeSigning @@ -198,7 +204,6 @@ jobs: targetFolder: $(Build.SourcesDirectory)/.deps/ - script: ./$(BuildDirectory)/build.sh -ci - $(BuildScriptArgs) $(SharedFxArgs) /p:SharedFxRID=osx-x64 /bl:artifacts/logs/SharedFx-osx-x64.binlog @@ -246,7 +251,6 @@ jobs: targetFolder: $(Build.SourcesDirectory)/.deps/ - script: ./$(BuildDirectory)/build.sh -ci - $(BuildScriptArgs) $(SharedFxArgs) /p:SharedFXRid=linux-x64 /bl:artifacts/logs/SharedFx-linux-x64.binlog @@ -258,7 +262,6 @@ jobs: displayName: Build linux-x64 SharedFX - script: ./$(BuildDirectory)/build.sh -ci - $(BuildScriptArgs) $(SharedFxArgs) /p:SharedFXRid=linux-arm /p:IsLinuxArmSupported=true @@ -308,7 +311,7 @@ jobs: - script: ./$(BuildDirectory)/dockerbuild.sh alpine -ci - $(BuildScriptArgs) + $(BuildNumberArg) /t:Prepare /t:GeneratePropsFiles /t:BuildSharedFx @@ -443,7 +446,7 @@ jobs: targetFolder: $(Build.SourcesDirectory)/.deps/Signed/ - script: .\build.cmd -ci - $(BuildScriptArgs) + $(BuildNumberArg) /p:SignType=$(_SignType) /t:BuildFallbackArchive /bl:artifacts/logs/PackageArchive.binlog @@ -468,7 +471,7 @@ jobs: - job: SharedFX_Installers displayName: Build SharedFX Installers - dependsOn: + dependsOn: - Linux_SharedFx - Linux_Musl_SharedFx - MacOs_SharedFx @@ -531,7 +534,7 @@ jobs: targetFolder: $(Build.SourcesDirectory)/.deps/Signed/ - script: ./$(BuildDirectory)/build.sh -ci - $(BuildScriptArgs) + $(BuildNumberArg) /t:BuildInstallers /bl:artifacts/logs/SharedFx-Installers.binlog env: @@ -554,7 +557,7 @@ jobs: - job: Publish displayName: Publish - dependsOn: + dependsOn: - Windows_Installers - SharedFX_Installers - Package_Archive @@ -703,7 +706,7 @@ jobs: contents: korebuild.json - script: .\build.cmd -ci - $(BuildScriptArgs) + $(BuildNumberArg) /t:Publish /p:BuildBranch=$(Build.SourceBranchName) /bl:artifacts/logs/Publish.binlog From 9abd18f5faa392accbf571fc76ec5cb355c253a5 Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Mon, 8 Mar 2021 13:45:07 -0800 Subject: [PATCH 2/4] Always skip tests in SharedFx and later jobs - however test\SharedFx.UnitTests\SharedFx.UnitTests.csproj always runs as part of `BuildSharedFx` target --- .azure/pipelines/ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.azure/pipelines/ci.yml b/.azure/pipelines/ci.yml index aeef07331b1a..209f247241a6 100644 --- a/.azure/pipelines/ci.yml +++ b/.azure/pipelines/ci.yml @@ -75,6 +75,7 @@ jobs: variables: _SignType: real JAVA_HOME: $(Agent.BuildDirectory)\.tools\jdk + PB_SKIPTESTS: 'true' steps: - checkout: self clean: true @@ -184,6 +185,8 @@ jobs: clean: all pool: vmImage: macOS-10.14 + variables: + PB_SKIPTESTS: 'true' steps: - checkout: self clean: true @@ -231,6 +234,8 @@ jobs: clean: all pool: vmImage: ubuntu-16.04 + variables: + PB_SKIPTESTS: 'true' steps: - checkout: self clean: true @@ -290,6 +295,8 @@ jobs: clean: all pool: vmImage: ubuntu-16.04 + variables: + PB_SKIPTESTS: 'true' steps: - checkout: self clean: true @@ -347,6 +354,7 @@ jobs: variables: _SignType: real JAVA_HOME: $(Agent.BuildDirectory)\.tools\jdk + PB_SKIPTESTS: 'true' steps: - checkout: self clean: true @@ -424,6 +432,7 @@ jobs: variables: _SignType: real JAVA_HOME: $(Agent.BuildDirectory)\.tools\jdk + PB_SKIPTESTS: 'true' steps: - checkout: self clean: true @@ -481,6 +490,8 @@ jobs: clean: all pool: vmImage: ubuntu-16.04 + variables: + PB_SKIPTESTS: 'true' steps: - checkout: self clean: true @@ -570,6 +581,7 @@ jobs: variables: _SignType: real JAVA_HOME: $(Agent.BuildDirectory)\.tools\jdk + PB_SKIPTESTS: 'true' steps: - checkout: self clean: true From bb003c4312b1c3c74d23245eecc91d9b06815724 Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Mon, 8 Mar 2021 16:19:16 -0800 Subject: [PATCH 3/4] Reduce retries in `RetryHelper` - download will usually fail repeatedly if it fails even once - previous maximum duration (105 min.) was greater than the job timeout --- test/SharedFx.UnitTests/RetryHelper.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/test/SharedFx.UnitTests/RetryHelper.cs b/test/SharedFx.UnitTests/RetryHelper.cs index 2d92113e3656..8d3400fc06c9 100644 --- a/test/SharedFx.UnitTests/RetryHelper.cs +++ b/test/SharedFx.UnitTests/RetryHelper.cs @@ -14,13 +14,6 @@ internal static class RetryHelpers /// private const int MaxRetryMinutes = 15; - private static int TotalRetriesUsed; - - public static int GetTotalRetriesUsed() - { - return TotalRetriesUsed; - } - public static async Task RetryAsync(Func action, IReporter reporter) { await RetryAsync( @@ -36,7 +29,7 @@ public static async Task RetryAsync(Func> action, IReporter report { Exception firstException = null; - var retriesRemaining = 10; + var retriesRemaining = 5; var retryDelayInMinutes = 1; while (retriesRemaining > 0) @@ -49,14 +42,15 @@ public static async Task RetryAsync(Func> action, IReporter report { firstException = firstException ?? e; reporter.Output($"Exception thrown! {e.Message}"); + + retriesRemaining--; reporter.Output($"Waiting {retryDelayInMinutes} minute(s) to retry ({retriesRemaining} left)..."); + await Task.Delay(retryDelayInMinutes * 60 * 1000); - // Do exponential back-off, but limit it (1, 2, 4, 8, 15, 15, 15, ...) - // With MaxRetryMinutes=15 and MaxRetries=10, this will delay a maximum of 105 minutes + // Do exponential back-off, but limit it (1, 2, 4, 8, 15) + // With MaxRetryMinutes=15 and MaxRetries=5, this will delay a maximum of 30 minutes (1/3 job timeout). retryDelayInMinutes = Math.Min(2 * retryDelayInMinutes, MaxRetryMinutes); - retriesRemaining--; - TotalRetriesUsed++; } } throw new InvalidOperationException("Max exception retries reached, giving up.", firstException); From 64b7204052ca30e5636df434c9a579ab279a4b52 Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Tue, 9 Mar 2021 16:38:34 -0800 Subject: [PATCH 4/4] Don't run `SharedFxTests.BaselineTest(...)` in some cases - when `!$(ValidateBaseline)`, previous runtimes do not exist --- test/SharedFx.UnitTests/SharedFx.UnitTests.csproj | 4 ++++ test/SharedFx.UnitTests/SharedFxTests.cs | 7 ++++++- test/SharedFx.UnitTests/TestData.cs | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/test/SharedFx.UnitTests/SharedFx.UnitTests.csproj b/test/SharedFx.UnitTests/SharedFx.UnitTests.csproj index e439e2842bc9..fbef6b2c85a2 100644 --- a/test/SharedFx.UnitTests/SharedFx.UnitTests.csproj +++ b/test/SharedFx.UnitTests/SharedFx.UnitTests.csproj @@ -30,6 +30,10 @@ <_Parameter1>PreviousAspNetCoreReleaseVersion <_Parameter2>$(PreviousAspNetCoreReleaseVersion) + + <_Parameter1>ValidateBaseline + <_Parameter2>$(ValidateBaseline) + diff --git a/test/SharedFx.UnitTests/SharedFxTests.cs b/test/SharedFx.UnitTests/SharedFxTests.cs index de57b07f7055..0319997f97e5 100644 --- a/test/SharedFx.UnitTests/SharedFxTests.cs +++ b/test/SharedFx.UnitTests/SharedFxTests.cs @@ -17,11 +17,16 @@ namespace Microsoft.AspNetCore { public class SharedFxTests { - [Theory] [MemberData(nameof(GetSharedFxConfig))] public async Task BaselineTest(SharedFxConfig config) { + if (!TestData.GetValidateBaseline()) + { + // Inability to validate the package baselines indicates dotnetcli is not up-to-date. + return; + } + var previousVersion = TestData.GetPreviousAspNetCoreReleaseVersion(); var url = new Uri($"https://dotnetcli.blob.core.windows.net/dotnet/aspnetcore/Runtime/" + previousVersion + "/aspnetcore-runtime-internal-" + previousVersion + "-win-x64.zip"); var zipName = "assemblies.zip"; diff --git a/test/SharedFx.UnitTests/TestData.cs b/test/SharedFx.UnitTests/TestData.cs index dd024ae3bdc8..8001e1b38f58 100644 --- a/test/SharedFx.UnitTests/TestData.cs +++ b/test/SharedFx.UnitTests/TestData.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Linq; using System.Reflection; @@ -20,6 +21,9 @@ public class TestData public static string GetSharedFxRuntimeIdentifier() => GetTestDataValue("SharedFxRuntimeIdentifier"); + public static bool GetValidateBaseline() => + string.Equals(GetTestDataValue("ValidateBaseline"), "true", StringComparison.OrdinalIgnoreCase); + private static string GetTestDataValue(string key) => typeof(TestData).Assembly.GetCustomAttributes().Single(d => d.Key == key).Value; }