diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index f41835a5..77afab7d 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -1,12 +1,19 @@ name: snapx -on: push +on: + push: + branches: + - develop + - master + pull_request: + branches: + - develop env: - GITVERSION_VERSION: 5.6.3 + GITVERSION_VERSION: 5.6.6 MSVS_TOOLSET_VERSION: 16 DOTNET_FRAMEWORK_VERSION: net5.0 - DOTNET_SDK_VERSION: 5.0.102 + DOTNET_SDK_VERSION: 5.0.200 DOTNET_CLI_TELEMETRY_OPTOUT: 1 DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 DOTNET_NOLOGO: 1 diff --git a/GitVersion.yml b/GitVersion.yml index cfa29d50..e90d26b6 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -1,4 +1,4 @@ -next-version: 3.0.9 +next-version: 3.0.11 mode: ContinuousDeployment continuous-delivery-fallback-tag: '' branches: diff --git a/build.ps1 b/build.ps1 index ec8015d5..19fd5d42 100644 --- a/build.ps1 +++ b/build.ps1 @@ -8,7 +8,7 @@ param( [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)] [string] $DockerImageName = "snapx", [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)] - [string] $DockerVersion = "6.1", + [string] $DockerVersion = "6.5", [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)] [switch] $DockerLocal, [Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)] diff --git a/docker/Dockerfile b/docker/Dockerfile index 22f43761..27dcad9d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -41,7 +41,7 @@ RUN \ RUN \ apt-get update && \ apt-get install -y apt-transport-https:amd64 ca-certificates:amd64 && \ - wget --no-check-certificate https://packages.microsoft.com/config/ubuntu/20.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \ + wget --no-check-certificate https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \ dpkg -i packages-microsoft-prod.deb && \ apt-get update && \ apt-get install -y dotnet-sdk-5.0:amd64 && \ diff --git a/src/Snap.Installer.Tests/Snap.Installer.Tests.csproj b/src/Snap.Installer.Tests/Snap.Installer.Tests.csproj index 938a4966..192b7765 100644 --- a/src/Snap.Installer.Tests/Snap.Installer.Tests.csproj +++ b/src/Snap.Installer.Tests/Snap.Installer.Tests.csproj @@ -22,8 +22,8 @@ - - + + diff --git a/src/Snap.Installer/Snap.Installer.Deps.targets b/src/Snap.Installer/Snap.Installer.Deps.targets index 4a41793a..30f81a4f 100644 --- a/src/Snap.Installer/Snap.Installer.Deps.targets +++ b/src/Snap.Installer/Snap.Installer.Deps.targets @@ -3,6 +3,6 @@ - + diff --git a/src/Snap.Shared.Tests/Snap.Shared.Tests.csproj b/src/Snap.Shared.Tests/Snap.Shared.Tests.csproj index 2234fac7..2131228b 100644 --- a/src/Snap.Shared.Tests/Snap.Shared.Tests.csproj +++ b/src/Snap.Shared.Tests/Snap.Shared.Tests.csproj @@ -9,11 +9,11 @@ - + - - + + diff --git a/src/Snap.Tests/Core/SnapPackTests.cs b/src/Snap.Tests/Core/SnapPackTests.cs index 83855888..9ed53c83 100644 --- a/src/Snap.Tests/Core/SnapPackTests.cs +++ b/src/Snap.Tests/Core/SnapPackTests.cs @@ -1163,18 +1163,17 @@ public async Task TestRebuildPackageAsync() update3SnapReleaseBuilder.AssertChecksums(update3PackageContext.FullPackageSnapApp, update3PackageContext.DeltaPackageSnapRelease, update3ExtractedFiles); - var (fullNupkgMemoryStream, fullSnapApp, fullSnapRelease) = await _snapPack.RebuildPackageAsync( + var (fullSnapApp, fullSnapRelease) = await _snapPack.RebuildPackageAsync( update3SnapReleaseBuilder.SnapAppPackagesDirectory, snapAppsReleases.GetReleases(update3PackageContext.DeltaPackageSnapApp, update3PackageContext.DeltaPackageSnapApp.GetCurrentChannelOrThrow()), - update3PackageContext.DeltaPackageSnapRelease); + update3PackageContext.DeltaPackageSnapRelease,filesystem:_snapFilesystem); - await using (fullNupkgMemoryStream) - { - Assert.NotNull(fullNupkgMemoryStream); - Assert.Equal(update3PackageContext.FullPackageSnapApp.BuildNugetFilename(), fullSnapApp.BuildNugetFilename()); - Assert.Equal(update3PackageContext.FullPackageSnapRelease.BuildNugetFilename(), fullSnapRelease.BuildNugetFilename()); - } + var packageFile = _snapFilesystem.PathCombine(update3SnapReleaseBuilder.SnapAppPackagesDirectory, fullSnapRelease.Filename); + Assert.True(_snapFilesystem.FileDeleteIfExists(packageFile)); + + Assert.Equal(update3PackageContext.FullPackageSnapApp.BuildNugetFilename(), fullSnapApp.BuildNugetFilename()); + Assert.Equal(update3PackageContext.FullPackageSnapRelease.BuildNugetFilename(), fullSnapRelease.BuildNugetFilename()); } [Fact] diff --git a/src/Snap.Tests/Snap.Tests.csproj b/src/Snap.Tests/Snap.Tests.csproj index 0f1461d0..7bf6d53c 100644 --- a/src/Snap.Tests/Snap.Tests.csproj +++ b/src/Snap.Tests/Snap.Tests.csproj @@ -19,8 +19,8 @@ - - + + diff --git a/src/Snap/Core/SnapPack.cs b/src/Snap/Core/SnapPack.cs index 769670cc..6eb0febd 100644 --- a/src/Snap/Core/SnapPack.cs +++ b/src/Snap/Core/SnapPack.cs @@ -111,9 +111,10 @@ internal interface ISnapPack Task<(MemoryStream fullNupkgMemoryStream, SnapApp fullSnapApp, SnapRelease fullSnapRelease, MemoryStream deltaNupkgMemoryStream, SnapApp deltaSnapApp, SnapRelease deltaSnapRelease)> BuildPackageAsync([NotNull] ISnapPackageDetails packageDetails, [NotNull] ICoreRunLib coreRunLib, CancellationToken cancellationToken = default); - Task<(MemoryStream outputStream, SnapApp fullSnapApp, SnapRelease fullSnapRelease)> RebuildPackageAsync([NotNull] string packagesDirectory, - [NotNull] ISnapAppChannelReleases snapAppChannelReleases, [NotNull] SnapRelease snapRelease, - IRebuildPackageProgressSource rebuildPackageProgressSource = null, CancellationToken cancellationToken = default); + Task<(SnapApp fullSnapApp, SnapRelease fullSnapRelease)> RebuildPackageAsync([NotNull] string packagesDirectory, + [NotNull] ISnapAppChannelReleases snapAppChannelReleases, [NotNull] SnapRelease snapRelease, + IRebuildPackageProgressSource rebuildPackageProgressSource = null, ISnapFilesystem filesystem = default, + CancellationToken cancellationToken = default); MemoryStream BuildEmptyReleasesPackage([NotNull] SnapApp snapApp, [NotNull] SnapAppsReleases snapAppsReleases); MemoryStream BuildReleasesPackage([NotNull] SnapApp snapApp, [NotNull] SnapAppsReleases snapAppsReleases, int? version = null); Task GetSnapAppAsync([NotNull] IAsyncPackageCoreReader asyncPackageCoreReader, CancellationToken cancellationToken = default); @@ -576,23 +577,25 @@ bool ShouldGenerateBsDiff(IPackageFile packageFile) return deltaNupkgPackageBuilder; } - public async Task<(MemoryStream outputStream, SnapApp fullSnapApp, SnapRelease fullSnapRelease)> RebuildPackageAsync(string packagesDirectory, - ISnapAppChannelReleases snapAppChannelReleases, SnapRelease snapRelease, IRebuildPackageProgressSource rebuildPackageProgressSource = null, CancellationToken cancellationToken = default) + public async Task<(SnapApp fullSnapApp, SnapRelease fullSnapRelease)> RebuildPackageAsync(string packagesDirectory, + ISnapAppChannelReleases snapAppChannelReleases, SnapRelease snapRelease, IRebuildPackageProgressSource rebuildPackageProgressSource = null, + ISnapFilesystem filesystem = default, CancellationToken cancellationToken = default) { if (packagesDirectory == null) throw new ArgumentNullException(nameof(packagesDirectory)); if (snapAppChannelReleases == null) throw new ArgumentNullException(nameof(snapAppChannelReleases)); if (snapRelease == null) throw new ArgumentNullException(nameof(snapRelease)); + if (filesystem == null) throw new ArgumentNullException(nameof(filesystem)); - var outputStream = new MemoryStream(); + var (packageBuilder, fullSnapApp, fullSnapRelease) = await RebuildFullPackageAsyncInternal(packagesDirectory, snapAppChannelReleases, snapRelease, rebuildPackageProgressSource, cancellationToken); - packageBuilder.Save(outputStream); - outputStream.Seek(0, SeekOrigin.Begin); + await using var filestream=filesystem.FileWrite(filesystem.PathCombine(packagesDirectory, fullSnapRelease.Filename)); + packageBuilder.Save(filestream); snapRelease.Sort(); - return (outputStream, fullSnapApp, fullSnapRelease); + return (fullSnapApp, fullSnapRelease); } async Task<(PackageBuilder packageBuilder, SnapApp fullSnapApp, SnapRelease fullSnapRelease)> RebuildFullPackageAsyncInternal(string packagesDirectory, diff --git a/src/Snap/Core/SnapPackageManager.cs b/src/Snap/Core/SnapPackageManager.cs index a9b38070..5d62d95c 100644 --- a/src/Snap/Core/SnapPackageManager.cs +++ b/src/Snap/Core/SnapPackageManager.cs @@ -541,19 +541,13 @@ await releasesToReassemble.ForEachAsync(async x => { try { - var (fullNupkgMemoryStream, _, fullSnapRelease) = - await _snapPack.RebuildPackageAsync(packagesDirectory, snapAppChannelReleases, x, compoundProgressSource, cancellationToken); + var ( _, fullSnapRelease) = + await _snapPack.RebuildPackageAsync(packagesDirectory, snapAppChannelReleases, x, compoundProgressSource, _filesystem, cancellationToken); - await using (fullNupkgMemoryStream) - { - var fullNupkgAbsolutePath = _filesystem.PathCombine(packagesDirectory, fullSnapRelease.Filename); - await _filesystem.FileWriteAsync(fullNupkgMemoryStream, fullNupkgAbsolutePath, cancellationToken); - - var releasesReassembledSoFarVolatile = Interlocked.Increment(ref releasesReassembled); - restoreSummary.ReassembleSummary.Add(new SnapPackageManagerReleaseStatus(fullSnapRelease, true)); + var releasesReassembledSoFarVolatile = Interlocked.Increment(ref releasesReassembled); + restoreSummary.ReassembleSummary.Add(new SnapPackageManagerReleaseStatus(fullSnapRelease, true)); - logger?.Debug($"Successfully restored {releasesReassembledSoFarVolatile} of {releasesToReassemble.Count()}."); - } + logger?.Debug($"Successfully restored {releasesReassembledSoFarVolatile} of {releasesToReassemble.Count()}."); } catch (Exception e) { diff --git a/src/Snap/Snap.Deps.targets b/src/Snap/Snap.Deps.targets index 7911433a..6059e2bf 100644 --- a/src/Snap/Snap.Deps.targets +++ b/src/Snap/Snap.Deps.targets @@ -7,13 +7,13 @@ - + - - + + diff --git a/src/Snapx.Tests/Snapx.Tests.csproj b/src/Snapx.Tests/Snapx.Tests.csproj index a00d9ea8..7f1ac886 100644 --- a/src/Snapx.Tests/Snapx.Tests.csproj +++ b/src/Snapx.Tests/Snapx.Tests.csproj @@ -19,8 +19,8 @@ - - + + diff --git a/src/Snapx/Options/DemoteOptions.cs b/src/Snapx/Options/DemoteOptions.cs index 1c015842..e80c0083 100644 --- a/src/Snapx/Options/DemoteOptions.cs +++ b/src/Snapx/Options/DemoteOptions.cs @@ -33,6 +33,10 @@ internal class DemoteOptions : BaseSubOptions HelpText = "Override lock token.")] public string LockToken { get; set; } + [Option("skip-await-update", + HelpText = "Skip waiting for the nuget feed update.")] + public bool SkipAwaitUpdate { get; set; } + [Value(0, HelpText = "The Application id.", Required = true)] diff --git a/src/Snapx/Options/PackOptions.cs b/src/Snapx/Options/PackOptions.cs index 89261534..c66d6863 100644 --- a/src/Snapx/Options/PackOptions.cs +++ b/src/Snapx/Options/PackOptions.cs @@ -48,6 +48,10 @@ internal class PackOptions : BaseSubOptions HelpText = "Skip building installers.")] public bool SkipInstallers { get; set; } + [Option("skip-await-update", + HelpText = "Skip waiting for the nuget feed update.")] + public bool SkipAwaitUpdate { get; set; } + [Option("release-notes", HelpText = "Overwrite release notes defined in YML manifest.")] public string ReleasesNotes { get; set; } diff --git a/src/Snapx/Options/PromoteOptions.cs b/src/Snapx/Options/PromoteOptions.cs index 7c991e67..dd312fce 100644 --- a/src/Snapx/Options/PromoteOptions.cs +++ b/src/Snapx/Options/PromoteOptions.cs @@ -41,6 +41,11 @@ internal class PromoteOptions : BaseSubOptions [Option("skip-installers", HelpText = "Skip building installers.")] public bool SkipInstallers { get; set; } + + [Option("skip-await-update", + HelpText = "Skip waiting for the nuget feed update.")] + public bool SkipAwaitUpdate { get; set; } + [Value(0, HelpText = "Application id", Required = true)] public string Id { get; [UsedImplicitly] set; } diff --git a/src/Snapx/Program.CommandDemote.cs b/src/Snapx/Program.CommandDemote.cs index 5cdff993..1a789dbe 100644 --- a/src/Snapx/Program.CommandDemote.cs +++ b/src/Snapx/Program.CommandDemote.cs @@ -264,7 +264,7 @@ await PushPackageAsync(nugetService, filesystem, distributedMutex, nuGetPackageS var skipInitialBlock = packageSource.IsLocalOrUncPath(); await BlockUntilSnapUpdatedReleasesNupkgAsync(logger, snapPackageManager, snapAppsReleases, anyRidSnapApp, - anySnapTargetDefaultChannel, TimeSpan.FromSeconds(15), cancellationToken, skipInitialBlock); + anySnapTargetDefaultChannel, TimeSpan.FromSeconds(15), cancellationToken, skipInitialBlock, options.SkipAwaitUpdate); logger.Info('-'.Repeat(TerminalBufferWidth)); diff --git a/src/Snapx/Program.CommandPack.cs b/src/Snapx/Program.CommandPack.cs index bbbc7d16..42f255dd 100644 --- a/src/Snapx/Program.CommandPack.cs +++ b/src/Snapx/Program.CommandPack.cs @@ -418,7 +418,7 @@ await PushPackageAsync(nugetService, filesystem, distributedMutex, var skipInitialBlock = pushFeedPackageSource.IsLocalOrUncPath(); await BlockUntilSnapUpdatedReleasesNupkgAsync(logger, snapPackageManager, snapAppsReleases, - snapApp, snapChannel, TimeSpan.FromSeconds(15), cancellationToken, skipInitialBlock); + snapApp, snapChannel, TimeSpan.FromSeconds(15), cancellationToken, skipInitialBlock,packOptions.SkipAwaitUpdate ); } } } diff --git a/src/Snapx/Program.CommandPromote.cs b/src/Snapx/Program.CommandPromote.cs index 2f4a3e71..50719741 100644 --- a/src/Snapx/Program.CommandPromote.cs +++ b/src/Snapx/Program.CommandPromote.cs @@ -299,7 +299,7 @@ await PushPackageAsync(nugetService, filesystem, distributedMutex, nuGetPackageS var skipInitialBlock = packageSource.IsLocalOrUncPath(); await BlockUntilSnapUpdatedReleasesNupkgAsync(logger, snapPackageManager, - snapAppsReleases, snapApp, channel, TimeSpan.FromSeconds(15), cancellationToken, skipInitialBlock); + snapAppsReleases, snapApp, channel, TimeSpan.FromSeconds(15), cancellationToken, skipInitialBlock,options.SkipAwaitUpdate ); logger.Info($"Successfully uploaded releases nupkg to channel: {channel.Name}."); logger.Info('-'.Repeat(TerminalBufferWidth)); diff --git a/src/Snapx/Program.cs b/src/Snapx/Program.cs index 8053ae09..0dcc3a8b 100644 --- a/src/Snapx/Program.cs +++ b/src/Snapx/Program.cs @@ -568,8 +568,9 @@ static string BuildPackagesDirectory([NotNull] ISnapFilesystem filesystem, [NotN static async Task BlockUntilSnapUpdatedReleasesNupkgAsync([NotNull] ILog logger, [NotNull] ISnapPackageManager snapPackageManager, [NotNull] SnapAppsReleases snapAppsReleases, [NotNull] SnapApp snapApp, - [NotNull] SnapChannel snapChannel, TimeSpan retryInterval, CancellationToken cancellationToken, bool skipInitialBlock = true) + [NotNull] SnapChannel snapChannel, TimeSpan retryInterval, CancellationToken cancellationToken, bool skipInitialBlock = true, bool skipAwaitUpdate=false) { + if (skipAwaitUpdate) return; if (logger == null) throw new ArgumentNullException(nameof(logger)); if (snapPackageManager == null) throw new ArgumentNullException(nameof(snapPackageManager)); if (snapAppsReleases == null) throw new ArgumentNullException(nameof(snapAppsReleases));