Skip to content

Commit

Permalink
Merge branch 'release/3.20.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
krankenbro committed Jan 25, 2024
2 parents b354dca + 5b536aa commit fb12f55
Show file tree
Hide file tree
Showing 58 changed files with 15,783 additions and 387 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Copyright>Copyright © VirtoCommerce 2011-2022</Copyright>
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>3.19.0</VersionPrefix>
<VersionPrefix>3.20.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<VersionSuffix Condition=" '$(VersionSuffix)' != '' AND '$(BuildNumber)' != '' ">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
</PropertyGroup>
Expand Down
9 changes: 9 additions & 0 deletions VirtoCommerce.Build.sln
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 17.0.32112.339
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VirtoCommerce.Build", "src\VirtoCommerce.Build\VirtoCommerce.Build.csproj", "{826FB1DE-BF4F-4314-AA00-FC5BC7627D7F}"
ProjectSection(ProjectDependencies) = postProject
{46099661-167D-4212-AFBE-855179D6F67D} = {46099661-167D-4212-AFBE-855179D6F67D}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VirtoCommerce.Build.Tests", "src\VirtoCommerce.Build.Tests\VirtoCommerce.Build.Tests.csproj", "{9E6E4723-DBA4-4A4B-807D-F9184D792DCF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VirtoCloud.Client", "src\Virtocloud.Client\src\VirtoCloud.Client\VirtoCloud.Client.csproj", "{46099661-167D-4212-AFBE-855179D6F67D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,6 +26,10 @@ Global
{9E6E4723-DBA4-4A4B-807D-F9184D792DCF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9E6E4723-DBA4-4A4B-807D-F9184D792DCF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9E6E4723-DBA4-4A4B-807D-F9184D792DCF}.Release|Any CPU.Build.0 = Release|Any CPU
{46099661-167D-4212-AFBE-855179D6F67D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{46099661-167D-4212-AFBE-855179D6F67D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{46099661-167D-4212-AFBE-855179D6F67D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{46099661-167D-4212-AFBE-855179D6F67D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion shelltests/packages.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ vc-build install -stable -v 4
>>>= 0

# Update to Bundle #5
vc-build update -v 4
vc-build update -v 5
>>>2
>>>= 0

Expand Down
183 changes: 94 additions & 89 deletions src/VirtoCommerce.Build/Build.cs

Large diffs are not rendered by default.

324 changes: 239 additions & 85 deletions src/VirtoCommerce.Build/Cloud/Build.SaaS.cs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/VirtoCommerce.Build/GrabMigrator/Build.GrabMigrator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Nuke.Common;
using GrabMigratorNamespace = GrabMigrator;

namespace VirtoCommerce.Build
{
Expand All @@ -11,7 +12,7 @@ internal partial class Build
.Requires(() => GrabMigratorConfig)
.Executes(() =>
{
new GrabMigrator.GrabMigrator().Do(GrabMigratorConfig);
GrabMigratorNamespace.GrabMigrator.Do(GrabMigratorConfig);
});
}
}
243 changes: 130 additions & 113 deletions src/VirtoCommerce.Build/GrabMigrator/GrabMigrator.cs

Large diffs are not rendered by default.

69 changes: 34 additions & 35 deletions src/VirtoCommerce.Build/PlatformTools/Build.PackageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ internal partial class Build
.Executes(async () =>
{
var platformRelease = await GithubManager.GetPlatformRelease(GitHubToken, VersionToInstall);
var packageManifest = PackageManager.CreatePackageManifest(platformRelease.TagName, platformRelease.Assets.First().BrowserDownloadUrl);
var packageManifest = PackageManager.CreatePackageManifest(platformRelease.TagName, platformRelease.Assets[0].BrowserDownloadUrl);
PackageManager.ToFile(packageManifest, PackageManifestPath);
});

Expand Down Expand Up @@ -95,7 +95,7 @@ internal partial class Build
PackageManager.ToFile(packageManifest, PackageManifestPath);
});

private void UpdateModules(string[] modulesArg, IModuleCatalog externalModuleCatalog, List<ModuleItem> modules)
private static void UpdateModules(string[] modulesArg, IModuleCatalog externalModuleCatalog, List<ModuleItem> modules)
{
foreach (var module in ParseModuleParameter(modulesArg))
{
Expand All @@ -118,7 +118,7 @@ private void UpdateModules(string[] modulesArg, IModuleCatalog externalModuleCat
module.Id = externalModule.Id;
module.Version = module.Version.EmptyToNull() ?? externalModule.Version.ToString();

var existingModule = modules.FirstOrDefault(m => m.Id == module.Id);
var existingModule = modules.Find(m => m.Id == module.Id);

if (existingModule == null)
{
Expand Down Expand Up @@ -149,7 +149,7 @@ private static void AddCommerceModules(IModuleCatalog externalModuleCatalog, Lis
modules.AddRange(commerceModules);
}

private IEnumerable<ModuleItem> ParseModuleParameter(string[] moduleStrings)
private static IEnumerable<ModuleItem> ParseModuleParameter(string[] moduleStrings)
{
foreach (var moduleString in moduleStrings)
{
Expand All @@ -159,7 +159,7 @@ private IEnumerable<ModuleItem> ParseModuleParameter(string[] moduleStrings)

if (parts.Length > 1)
{
moduleId = parts.First();
moduleId = parts[0];
moduleVersion = parts.Last();
}
else if (moduleStrings.Length == 1 && !string.IsNullOrEmpty(VersionToInstall))
Expand Down Expand Up @@ -210,21 +210,15 @@ private static bool PlatformVersionChanged()
.After(Backup, Install, Update, InstallPlatform, InstallModules)
.OnlyWhenDynamic(() => FailedTargets.Any() && SucceededTargets.Contains(Backup))
.AssuredAfterFailure()
.Executes(() =>
{
CompressionTasks.UncompressTarGZip(BackupFile, RootDirectory);
});
.Executes(() => CompressionTasks.UncompressTarGZip(BackupFile, RootDirectory));

public Target RemoveBackup => _ => _
.After(Backup, Rollback)
.OnlyWhenDynamic(() => FinishedTargets.Contains(Backup) && File.Exists(BackupFile))
.AssuredAfterFailure()
.Unlisted()
.DependsOn(Backup)
.Executes(() =>
{
FileSystemTasks.DeleteFile(BackupFile);
});
.Executes(() => FileSystemTasks.DeleteFile(BackupFile));

public Target InstallPlatform => _ => _
.OnlyWhenDynamic(() => PlatformVersionChanged() && !IsModulesInstallation())
Expand Down Expand Up @@ -287,12 +281,12 @@ private static async Task InstallPlatformAsync(string platformVersion, string pl
}
else
{
Log.Information($"appsettings.json was restored");
Log.Information("appsettings.json was restored");
}
}
}

private string GetDiscoveryPath()
private static string GetDiscoveryPath()
{
var configuration = AppSettings.GetConfiguration(RootDirectory, AppsettingsPath);
return DiscoveryPath.EmptyToNull() ?? configuration.GetModulesDiscoveryPath();
Expand Down Expand Up @@ -388,10 +382,7 @@ private static bool IsPlatformInstallationNeeded(string version)

modulesToInstall.AddRange(missingModules);
}
modulesToInstall.ForEach(module =>
{
module.DependsOn.Clear();
});
modulesToInstall.ForEach(module => module.DependsOn.Clear());
try
{
moduleInstaller.Install(modulesToInstall, progress);
Expand All @@ -414,6 +405,11 @@ private static bool IsPlatformInstallationNeeded(string version)

private static ManifestModuleInfo LoadModuleInfo(ModuleItem module, ManifestModuleInfo externalModule)
{
if (!externalModule.Ref.Contains(externalModule.Version.ToString()))
{
Log.Error("Error in file modules_v3.json for module {0}: Version {1} not found in Reference {2}", externalModule.Id, externalModule.Version.ToString(), externalModule.Ref);
}

var currentModule = new ModuleManifest
{
Id = module.Id,
Expand Down Expand Up @@ -453,7 +449,7 @@ private static ManifestModuleInfo LoadModuleInfo(ModuleItem module, ManifestModu
return moduleInfo;
}

private ModulesInstallerBase GetModuleInstaller(ModuleSource moduleSource) => moduleSource switch
private static ModulesInstallerBase GetModuleInstaller(ModuleSource moduleSource) => moduleSource switch
{
AzurePipelineArtifacts => new AzurePipelineArtifactsModuleInstaller(AzureToken, GetDiscoveryPath()),
AzureUniversalPackages => new AzureUniversalPackagesModuleInstaller(AzureToken, GetDiscoveryPath()),
Expand Down Expand Up @@ -502,7 +498,7 @@ private static ManifestModuleInfo LoadModuleInfo(ModuleItem module, ManifestModu
PackageManager.ToFile(manifest, PackageManifestPath);
});

private async Task<ManifestBase> UpdateEdgeAsync(ManifestBase manifest, bool platformOnly)
private static async Task<ManifestBase> UpdateEdgeAsync(ManifestBase manifest, bool platformOnly)
{
manifest = await UpdateEdgePlatformAsync(manifest);
if(!platformOnly)
Expand Down Expand Up @@ -534,14 +530,14 @@ private static Task<ManifestBase> UpdateStablePlatformAsync(ManifestBase manifes

private Task<ManifestBase> UpdateStableModulesAsync(MixedPackageManifest manifest, MixedPackageManifest bundle)
{
var githubModules = (GithubReleases)manifest.Sources.FirstOrDefault(s => s.Name == nameof(GithubReleases));
var githubModules = (GithubReleases)manifest.Sources.Find(s => s.Name == nameof(GithubReleases));
if(githubModules == null)
{
Assert.Fail("There is no GithubReleases source in the manifest");
return Task.FromResult((ManifestBase)manifest); // for sonarQube
}

var bundleGithubModules = (GithubReleases)bundle.Sources.FirstOrDefault(s => s.Name == nameof(GithubReleases));
var bundleGithubModules = (GithubReleases)bundle.Sources.Find(s => s.Name == nameof(GithubReleases));
if(bundleGithubModules == null)
{
Assert.Fail($"Github releases not found in the bundle {BundleName}");
Expand All @@ -550,7 +546,7 @@ private Task<ManifestBase> UpdateStableModulesAsync(MixedPackageManifest manifes

foreach (var module in githubModules.Modules)
{
var bundleModule = bundleGithubModules.Modules.FirstOrDefault(m => m.Id == module.Id);
var bundleModule = bundleGithubModules.Modules.Find(m => m.Id == module.Id);
if(bundleModule != null)
{
module.Version = bundleModule.Version;
Expand All @@ -565,7 +561,7 @@ private static async Task<ManifestBase> UpdateEdgePlatformAsync(ManifestBase man
return manifest;
}

private async Task<ManifestBase> UpdateEdgeModulesAsync(ManifestBase manifest)
private static async Task<ManifestBase> UpdateEdgeModulesAsync(ManifestBase manifest)
{
var githubModules = PackageManager.GetGithubModules(manifest);
var githubModuleManifests = PackageManager.GetGithubModuleManifests(manifest);
Expand All @@ -575,52 +571,55 @@ private async Task<ManifestBase> UpdateEdgeModulesAsync(ManifestBase manifest)

foreach (var module in githubModules)
{
var externalModule = externalModuleCatalog.Modules.OfType<ManifestModuleInfo>().Where(m => m.Id == module.Id).FirstOrDefault(m => m.Ref.Contains("github.com"));
var externalModule = externalModuleCatalog.Modules.OfType<ManifestModuleInfo>().FirstOrDefault(m => m.Id == module.Id);

if (externalModule == null)
{
var errorMessage = $"No module {module.Id} found";
Assert.Fail(errorMessage);
throw new ArgumentNullException(errorMessage); // for sonarQube
}
else if (externalModule.Ref.StartsWith("file:///"))
{
Log.Information($"{module.Id} already installed.");
continue;
}

module.Version = externalModule.Version.ToString();
}

return manifest;
}

private async Task<ManifestBase> OpenOrCreateManifest(string packageManifestPath, bool isEdge)
private static async Task<ManifestBase> OpenOrCreateManifest(string packageManifestPath, bool isEdge)
{
ManifestBase packageManifest;
var platformWebDllPath = Path.Combine(Directory.GetParent(packageManifestPath).FullName, "VirtoCommerce.Platform.Web.dll");
if (!isEdge)
{
SkipDependencySolving = true;
if(!File.Exists(packageManifestPath))
if (!File.Exists(packageManifestPath))
{
await DownloadBundleManifest(BundleName, packageManifestPath);
}
packageManifest = PackageManager.FromFile(packageManifestPath);
}
return PackageManager.FromFile(packageManifestPath);
}
else if (!File.Exists(packageManifestPath) && File.Exists(platformWebDllPath))
{
var discoveryAbsolutePath = Path.GetFullPath(GetDiscoveryPath());
packageManifest = CreateManifestFromEnvironment(RootDirectory, (AbsolutePath)discoveryAbsolutePath);
return CreateManifestFromEnvironment(RootDirectory, (AbsolutePath)discoveryAbsolutePath);
}
else if (!File.Exists(packageManifestPath))
{
Log.Information("vc-package.json does not exist.");
Log.Information("Looking for the platform release");
var platformRelease = await GithubManager.GetPlatformRelease(GitHubToken, VersionToInstall);
packageManifest = PackageManager.CreatePackageManifest(platformRelease.TagName);
return PackageManager.CreatePackageManifest(platformRelease.TagName);
}
else
{
SkipDependencySolving = true;
packageManifest = PackageManager.FromFile(PackageManifestPath);
return PackageManager.FromFile(PackageManifestPath);
}
return packageManifest;
}

private static async Task DownloadBundleManifest(string bundleName, string outFile)
Expand Down
50 changes: 15 additions & 35 deletions src/VirtoCommerce.Build/PlatformTools/LocalCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace PlatformTools
{
public class LocalCatalog : LocalStorageModuleCatalog
{

private readonly LocalStorageModuleCatalogOptions _options;
private readonly ILogger<LocalStorageModuleCatalog> _logger;
private readonly IInternalDistributedLockService _distributedLockProvider;
Expand Down Expand Up @@ -108,25 +107,21 @@ private string GetSourceMark()
{
if (File.Exists(markerFilePath))
{
using (var stream = File.OpenText(markerFilePath))
{
marker = stream.ReadToEnd();
}
using var stream = File.OpenText(markerFilePath);
marker = stream.ReadToEnd();
}
else
{
// Non-marked storage, mark by placing a file with resource id.
using (var stream = File.CreateText(markerFilePath))
{
stream.Write(marker);
}
using var stream = File.CreateText(markerFilePath);
stream.Write(marker);
}
}
catch (IOException exc)
{
throw new PlatformException($"An IO error occurred while marking local modules storage.", exc);
throw new PlatformException("An IO error occurred while marking local modules storage.", exc);
}
return $@"{nameof(LocalStorageModuleCatalog)}-{marker}";
return $"{nameof(LocalStorageModuleCatalog)}-{marker}";
}

private static string GetFileAbsoluteUri(string rootPath, string relativePath)
Expand Down Expand Up @@ -169,18 +164,14 @@ private void CopyAssemblies(string sourceParentPath, string targetDirectoryPath)

if (Directory.Exists(sourceDirectoryPath))
{
foreach (var sourceFilePath in Directory.EnumerateFiles(sourceDirectoryPath, "*.*", SearchOption.AllDirectories))
foreach (var sourceFilePath in Directory.EnumerateFiles(sourceDirectoryPath, "*.*", SearchOption.AllDirectories).Where(f => IsAssemblyRelatedFile(f)))
{
// Copy all assembly related files except assemblies that are inlcuded in TPA list
if (IsAssemblyRelatedFile(sourceFilePath))
{
// Copy localization resource files to related subfolders
var targetFilePath = Path.Combine(
IsLocalizationFile(sourceFilePath) ? Path.Combine(targetDirectoryPath, Path.GetFileName(Path.GetDirectoryName(sourceFilePath)))
: targetDirectoryPath,
Path.GetFileName(sourceFilePath));
CopyFile(sourceFilePath, targetFilePath);
}
// Copy localization resource files to related subfolders
var targetFilePath = Path.Combine(
IsLocalizationFile(sourceFilePath) ? Path.Combine(targetDirectoryPath, Path.GetFileName(Path.GetDirectoryName(sourceFilePath)))
: targetDirectoryPath,
Path.GetFileName(sourceFilePath));
CopyFile(sourceFilePath, targetFilePath);
}
}
}
Expand Down Expand Up @@ -220,22 +211,11 @@ private void CopyFile(string sourceFilePath, string targetFilePath)
{
File.Copy(sourceFilePath, targetFilePath, true);
}
catch (IOException)
catch (IOException) when (versionsAreSameButLaterDate)
{
// VP-3719: Need to catch to avoid possible problem when different instances are trying to update the same file with the same version but different dates in the probing folder.
// We should not fail platform start in that case - just add warning into the log. In case of unability to place newer version - should fail platform start.
if (versionsAreSameButLaterDate)
{
_logger.LogWarning("File '{TargetFilePath}' was not updated by '{SourceFilePath}' of the same version but later modified date, because probably it was used by another process", targetFilePath, sourceFilePath);
}
else
{
throw;
}
_logger.LogWarning("File '{TargetFilePath}' was not updated by '{SourceFilePath}' of the same version but later modified date, because probably it was used by another process", targetFilePath, sourceFilePath);
}
}
}
}


}
Loading

0 comments on commit fb12f55

Please sign in to comment.