From 07d77aa4655b126cf879498aa398d609e32b40bd Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Fri, 29 Nov 2024 12:20:19 +0100 Subject: [PATCH] Optimize Azure pipeline (#17674) * Only fetch single commit * Hopefully fixes Nerdbank.GitVersioning.GitException: Shallow clone lacks the objects required to calculate version height. Use full clones or clones with a history at least as deep as the last version height resetting change. * Do not checkout again * More test pipeline * Another attempt * yet another attempt * more attempts * Revert "more attempts" This reverts commit 5694d97ba620e90fdeea287936f58002f2a5ddba. * Test without building backoffice and login explicitly * Fix mem leak in integration tests * Fixes sqlserver lock test --- build/azure-pipelines.yml | 37 +++++++++++-------- ...ServerEFCoreDistributedLockingMechanism.cs | 4 +- .../Testing/UmbracoIntegrationTest.cs | 6 ++- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/build/azure-pipelines.yml b/build/azure-pipelines.yml index cf80f9ef7b..a1b519d000 100644 --- a/build/azure-pipelines.yml +++ b/build/azure-pipelines.yml @@ -78,24 +78,13 @@ stages: vmImage: "windows-latest" steps: - checkout: self - submodules: true + submodules: false + lfs: false, + fetchDepth: 500 - task: UseDotNet@2 displayName: Use .NET SDK from global.json inputs: useGlobalJson: true - - template: templates/backoffice-install.yml - - script: npm run build:for:cms - displayName: Run build (Bellissima) - workingDirectory: src/Umbraco.Web.UI.Client - - script: npm run check:paths - displayName: Run check:paths - workingDirectory: src/Umbraco.Web.UI.Client - - script: npm ci --no-fund --no-audit --prefer-offline - displayName: Run npm ci (Login) - workingDirectory: src/Umbraco.Web.UI.Login - - script: npm run build - displayName: Run npm build (Login) - workingDirectory: src/Umbraco.Web.UI.Login - task: DotNetCoreCLI@2 displayName: Run dotnet restore inputs: @@ -125,7 +114,10 @@ stages: vmImage: "ubuntu-latest" steps: - checkout: self - submodules: true + submodules: false + lfs: false, + fetchDepth: 1 + fetchFilter: tree:0 - template: templates/backoffice-install.yml - script: npm run build:for:npm displayName: Run build:for:npm @@ -209,7 +201,10 @@ stages: BASE_PATH: /v$(umbracoMajorVersion)/ui steps: - checkout: self - submodules: true + submodules: false + lfs: false, + fetchDepth: 1 + fetchFilter: tree:0 - template: templates/backoffice-install.yml - script: npm run storybook:build displayName: Build Storybook @@ -266,6 +261,11 @@ stages: pool: vmImage: $(vmImage) steps: + - checkout: self + submodules: false + lfs: false, + fetchDepth: 1 + fetchFilter: tree:0 - task: DownloadPipelineArtifact@2 displayName: Download build artifacts inputs: @@ -306,6 +306,11 @@ stages: variables: Tests__Database__DatabaseType: "Sqlite" steps: + - checkout: self + submodules: false + lfs: false, + fetchDepth: 1 + fetchFilter: tree:0 # Setup test environment - task: DownloadPipelineArtifact@2 displayName: Download build artifacts diff --git a/src/Umbraco.Cms.Persistence.EFCore/Locking/SqlServerEFCoreDistributedLockingMechanism.cs b/src/Umbraco.Cms.Persistence.EFCore/Locking/SqlServerEFCoreDistributedLockingMechanism.cs index 38cdeef114..91342c386f 100644 --- a/src/Umbraco.Cms.Persistence.EFCore/Locking/SqlServerEFCoreDistributedLockingMechanism.cs +++ b/src/Umbraco.Cms.Persistence.EFCore/Locking/SqlServerEFCoreDistributedLockingMechanism.cs @@ -170,7 +170,9 @@ internal class SqlServerEFCoreDistributedLockingMechanism : IDistributedLocki "A transaction with minimum ReadCommitted isolation level is required."); } - var rowsAffected = await dbContext.Database.ExecuteSqlAsync(@$"SET LOCK_TIMEOUT {(int)_timeout.TotalMilliseconds};UPDATE umbracoLock WITH (REPEATABLEREAD) SET value = (CASE WHEN (value=1) THEN -1 ELSE 1 END) WHERE id={LockId}"); +#pragma warning disable EF1002 + var rowsAffected = await dbContext.Database.ExecuteSqlRawAsync(@$"SET LOCK_TIMEOUT {(int)_timeout.TotalMilliseconds};UPDATE umbracoLock WITH (REPEATABLEREAD) SET value = (CASE WHEN (value=1) THEN -1 ELSE 1 END) WHERE id={LockId}"); +#pragma warning restore EF1002 if (rowsAffected == 0) { diff --git a/tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs b/tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs index 39e6c8ac04..7f7d1d06e4 100644 --- a/tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs +++ b/tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs @@ -84,7 +84,11 @@ public abstract class UmbracoIntegrationTest : UmbracoIntegrationTestBase } [TearDown] - public void TearDownAsync() => _host.StopAsync(); + public void TearDownAsync() + { + _host.StopAsync(); + Services.DisposeIfDisposable(); + } /// /// Create the Generic Host and execute startup ConfigureServices/Configure calls