Skip to content

Commit

Permalink
VCI-796: Improve comments for skipped targets (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
krankenbro authored Mar 11, 2024
1 parent da200a5 commit f10f886
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/VirtoCommerce.Build/Docker/Build.Docker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ internal partial class Build

private static string DockerImageFullName => string.IsNullOrEmpty(DockerImageTag) ? DockerImageName : DockerImageName.Append($":{DockerImageTag}");

public static bool DockerCredentialsPassed => !string.IsNullOrEmpty(DockerUsername) && !string.IsNullOrEmpty(DockerPassword);
Target DockerLogin => _ => _
.Before(BuildImage, PushImage)
.OnlyWhenDynamic(() => !string.IsNullOrEmpty(DockerUsername) && !string.IsNullOrEmpty(DockerPassword))
.OnlyWhenDynamic(() => DockerCredentialsPassed)
.Executes(() =>
{
DockerTasks.DockerLogger = (_, m) => Log.Debug(m);
Expand Down
31 changes: 18 additions & 13 deletions src/VirtoCommerce.Build/PlatformTools/Build.PackageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,21 +180,24 @@ private static IEnumerable<ModuleItem> ParseModuleParameter(string[] moduleStrin
}
}

private static bool IsModulesInstallation()
{
return !PlatformParameter && (!Module?.IsEmpty() ?? false);
}
private static bool IsModulesInstallation => !PlatformParameter && (!Module?.IsEmpty() ?? false);

private static bool PlatformVersionChanged()
private static bool PlatformVersionChanged
{
var manifest = PackageManager.FromFile(PackageManifestPath);
return IsPlatformInstallationNeeded(manifest.PlatformVersion);
get
{
var manifest = PackageManager.FromFile(PackageManifestPath);
return IsPlatformInstallationNeeded(manifest.PlatformVersion);
}
}

private static bool IsNotServerBuild => !IsServerBuild;
private static bool ThereAreFilesToBackup => Directory.EnumerateFileSystemEntries(RootDirectory).Any(p => !p.Contains(".nuke"));

public Target Backup => _ => _
.Triggers(Rollback, RemoveBackup)
.Before(Install, Update, InstallPlatform, InstallModules)
.OnlyWhenDynamic(() => !IsServerBuild && Directory.EnumerateFileSystemEntries(RootDirectory).Any())
.OnlyWhenDynamic(() => IsNotServerBuild && ThereAreFilesToBackup)
.ProceedAfterFailure()
.Executes(() =>
{
Expand All @@ -208,23 +211,25 @@ private static bool PlatformVersionChanged()
CompressionExtensions.TarGZipTo(RootDirectory, BackupFile, filter: f => !f.ToFileInfo().FullName.StartsWith(RootDirectory / ".nuke") && !symlinks.Exists(s => f.ToFileInfo().FullName.StartsWith(s)));
});

public bool ThereAreFailedTargets => FailedTargets.Count > 0 && SucceededTargets.Contains(Backup);
public Target Rollback => _ => _
.DependsOn(Backup)
.After(Backup, Install, Update, InstallPlatform, InstallModules)
.OnlyWhenDynamic(() => FailedTargets.Count > 0 && SucceededTargets.Contains(Backup))
.OnlyWhenDynamic(() => ThereAreFailedTargets)
.AssuredAfterFailure()
.Executes(() => CompressionExtensions.UnTarGZipTo(BackupFile, RootDirectory));

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

public Target InstallPlatform => _ => _
.OnlyWhenDynamic(() => PlatformVersionChanged() && !IsModulesInstallation())
.OnlyWhenDynamic(() => PlatformVersionChanged && !IsModulesInstallation)
.Executes(async () =>
{
var packageManifest = PackageManager.FromFile(PackageManifestPath);
Expand Down Expand Up @@ -367,7 +372,7 @@ private static bool IsPlatformInstallationNeeded(string version)
{
if (m.Level == ProgressMessageLevel.Error)
{
Assert.Fail(m.Message);
Assert.Fail(m.Message);
}
else
{
Expand Down Expand Up @@ -666,7 +671,7 @@ private async static Task<ManifestBase> CreateManifestFromEnvironment(AbsolutePa
if (!modulesInCatalog.Contains(manifest.Id))
{
Log.Warning("There is no module {0}:{1} in external catalog. You should add it in manifest manually.", manifest.Id, manifest.Version);

}
else
{
Expand Down

0 comments on commit f10f886

Please sign in to comment.