Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
peters committed Mar 7, 2021
2 parents 501f905 + aaedc3a commit 7b5b158
Show file tree
Hide file tree
Showing 20 changed files with 68 additions and 51 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
next-version: 3.0.9
next-version: 3.0.11
mode: ContinuousDeployment
continuous-delivery-fallback-tag: ''
branches:
Expand Down
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
4 changes: 2 additions & 2 deletions src/Snap.Installer.Tests/Snap.Installer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

<ItemGroup>
<PackageReference Include="Castle.Core" Version="4.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="Moq" Version="4.16.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="System.CodeDom" Version="5.0.0" />
<PackageReference Include="System.Security.Permissions" Version="5.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
2 changes: 1 addition & 1 deletion src/Snap.Installer/Snap.Installer.Deps.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.ReactiveUI" Version="$(AvaloniaVersion)" />
<PackageReference Include="LightInject" Version="6.4.0" />
<PackageReference Include="NLog" Version="4.7.7" />
<PackageReference Include="NLog" Version="4.7.8" />
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions src/Snap.Shared.Tests/Snap.Shared.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Include="Moq" Version="4.16.0" />
<PackageReference Include="XunitXml.TestLogger" Version="2.1.26" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="XunitXml.TestLogger" Version="3.0.62" />
</ItemGroup>

<ItemGroup>
Expand Down
15 changes: 7 additions & 8 deletions src/Snap.Tests/Core/SnapPackTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions src/Snap.Tests/Snap.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

<ItemGroup>
<PackageReference Include="Castle.Core" Version="4.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="Moq" Version="4.16.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="System.CodeDom" Version="5.0.0" />
<PackageReference Include="System.Security.Permissions" Version="5.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
21 changes: 12 additions & 9 deletions src/Snap/Core/SnapPack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SnapApp> GetSnapAppAsync([NotNull] IAsyncPackageCoreReader asyncPackageCoreReader, CancellationToken cancellationToken = default);
Expand Down Expand Up @@ -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,
Expand Down
16 changes: 5 additions & 11 deletions src/Snap/Core/SnapPackageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Snap/Snap.Deps.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<ItemGroup>
<PackageReference Include="Mono.Cecil" Version="0.11.3"/>
<PackageReference Include="YamlDotNet" Version="9.1.4"/>
<PackageReference Include="SharpCompress" Version="0.27.1"/>
<PackageReference Include="SharpCompress" Version="0.28.1"/>
<PackageReference Include="MessagePack" Version="2.2.85" />
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NuGet.Packaging" Version="5.8.0"/>
<PackageReference Include="NuGet.Protocol" Version="5.8.0"/>
<PackageReference Include="NuGet.Packaging" Version="5.9.0"/>
<PackageReference Include="NuGet.Protocol" Version="5.9.0"/>
<!-- Force compatible version with net5.0 -->
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Snapx.Tests/Snapx.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

<ItemGroup>
<PackageReference Include="Castle.Core" Version="4.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="Moq" Version="4.16.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="System.CodeDom" Version="5.0.0" />
<PackageReference Include="System.Security.Permissions" Version="5.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
4 changes: 4 additions & 0 deletions src/Snapx/Options/DemoteOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 4 additions & 0 deletions src/Snapx/Options/PackOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
5 changes: 5 additions & 0 deletions src/Snapx/Options/PromoteOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
2 changes: 1 addition & 1 deletion src/Snapx/Program.CommandDemote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
2 changes: 1 addition & 1 deletion src/Snapx/Program.CommandPack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}
}
2 changes: 1 addition & 1 deletion src/Snapx/Program.CommandPromote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
3 changes: 2 additions & 1 deletion src/Snapx/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 7b5b158

Please sign in to comment.