Skip to content

Commit

Permalink
3.21.1 (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
krankenbro authored Mar 25, 2024
1 parent 11477b4 commit e516895
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 32 deletions.
8 changes: 4 additions & 4 deletions shelltests/packages.test
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Install Bundle #4
vc-build install -stable -v 4
# Install Bundle #5
vc-build install -stable -v 5
>>>2
>>>= 0

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

Expand Down
3 changes: 2 additions & 1 deletion src/VirtoCommerce.Build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -883,9 +883,10 @@ public static int Main(string[] args)

CreateNukeDirectory();

var exitCode = Execute<Build>(x => x.Compile);

ClearTempOnExit();

var exitCode = Execute<Build>(x => x.Compile);
return _exitCode ?? exitCode;
}

Expand Down
49 changes: 32 additions & 17 deletions src/VirtoCommerce.Build/Cloud/Build.SaaS.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Security.Policy;
using System.Text.Json.Nodes;
using System.Text;
using System.Net;
using System.Threading.Tasks;
using Cloud.Client;
using Cloud.Models;
using Microsoft.TeamFoundation.Build.WebApi;
using Nuke.Common;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
Expand All @@ -19,10 +16,6 @@
using Serilog;
using VirtoCloud.Client.Api;
using VirtoCloud.Client.Model;
using System.Net;
using System.Diagnostics;
using Microsoft.AspNetCore.Identity;
using System.Runtime.InteropServices;

namespace VirtoCommerce.Build;

Expand Down Expand Up @@ -65,6 +58,16 @@ internal partial class Build

[Parameter("Organization name", Name = "Organization")] public string SaaSOrganizationName { get; set; }


[Parameter("Url to Dockerfile which will use to build the docker image in the CloudDeploy/CloudUp Target")]
public static string DockerfileUrl { get; set; } = "https://raw.githubusercontent.com/VirtoCommerce/vc-docker/feat/net8/linux/platform/Dockerfile";
[Parameter("Url to Wake-script which will use to build the docker image in the CloudDeploy/CloudUp Target")]
public static string WaitScriptUrl { get; set; } = "https://raw.githubusercontent.com/VirtoCommerce/vc-docker/feat/net8/linux/platform/wait-for-it.sh";

public Target WaitForStatus => _ => _
.Executes(() => Log.Warning("Target WaitForStatus is obsolete. Use CloudEnvStatus."))
.Triggers(CloudEnvStatus);

public Target CloudEnvStatus => _ => _
.Executes(async () =>
{
Expand Down Expand Up @@ -121,23 +124,23 @@ private static bool CheckAppServiceStatus(string expected, string actual)

return false;
}

public static string DockerfileUrl { get; set; } = "https://raw.githubusercontent.com/krankenbro/vc-ci-test/master/Dockerfile";
public Target PrepareDockerContext => _ => _
.Before(InitPlatform, DockerLogin, BuildImage, PushImage, BuildAndPush)
.Before(DockerLogin, BuildImage, PushImage, CloudInit)
.Triggers(InitPlatform)
.Executes(async () => await PrepareDockerContextMethod());

private async Task PrepareDockerContextMethod()
{
var dockerBuildContext = ArtifactsDirectory / "docker";
var platformDirectory = dockerBuildContext / "platform";
var platformDirectory = dockerBuildContext / "publish";
var modulesPath = platformDirectory / "modules";
var dockerfilePath = dockerBuildContext / "Dockerfile";
var waitScriptPath = dockerBuildContext / "wait-for-it.sh";

dockerBuildContext.CreateOrCleanDirectory();

await HttpTasks.HttpDownloadFileAsync(DockerfileUrl, dockerfilePath);
await HttpTasks.HttpDownloadFileAsync(WaitScriptUrl, waitScriptPath);

var modulesSourcePath = Solution?.Path != null
? WebProject.Directory / "modules"
Expand All @@ -151,7 +154,7 @@ private async Task PrepareDockerContextMethod()

if (string.IsNullOrWhiteSpace(DockerImageName))
{
DockerImageName = $"{DockerUsername}/{EnvironmentName}";
DockerImageName = $"{DockerUsername}/{EnvironmentName.ToLowerInvariant()}";
}

DockerImageTag ??= DateTime.Now.ToString("MMddyyHHmmss");
Expand Down Expand Up @@ -338,7 +341,7 @@ private void SaveCloudToken(string token)
});

public Target CloudInit => _ => _
.Before(PrepareDockerContext, BuildAndPush, CloudDeploy)
.After(PrepareDockerContext, DockerLogin, BuildImage, PushImage, BuildAndPush)
.Requires(() => EnvironmentName)
.Executes(async () =>
{
Expand All @@ -349,9 +352,21 @@ private void SaveCloudToken(string token)
ServicePlan = ServicePlan,
Cluster = ClusterName,
DbProvider = DbProvider,
DbName = DbName
DbName = DbName,
Helm = new HelmObject(new Dictionary<string, string> ())
};

if(!string.IsNullOrEmpty(DockerImageName))
{
model.Helm.Parameters["platform.image.repository"] = DockerImageName;
}

if(!string.IsNullOrEmpty(DockerImageTag))
{
model.Helm.Parameters["platform.image.tag"] = DockerImageTag;
}


var cloudClient = CreateVirtocloudClient(CloudUrl, await GetCloudTokenAsync());
await cloudClient.EnvironmentsCreateAsync(model);
});
Expand All @@ -367,7 +382,7 @@ private void SaveCloudToken(string token)
});

public Target CloudUp => _ => _
.DependsOn(CloudInit, CloudDeploy);
.DependsOn(PrepareDockerContext, BuildAndPush, CloudInit);

private static SaaSDeploymentApi CreateVirtocloudClient(string url, string token)
{
Expand Down
17 changes: 16 additions & 1 deletion src/VirtoCommerce.Build/Docker/Build.Docker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,21 @@ namespace VirtoCommerce.Build
internal partial class Build
{
[Parameter("Connection String")] public static string DockerConnectionString { get; set; }
[Parameter("Docker Username")] public static string DockerUsername { get; set; }

private static string _dockerUsername = string.Empty;
[Parameter("Docker Username")]
public static string DockerUsername
{
get
{
return _dockerUsername;
}
set
{
_dockerUsername = value?.ToLowerInvariant();
}
}

[Parameter("Docker Password")] public static string DockerPassword { get; set; }
[Parameter("Docker Registry Url")] public static string DockerRegistryUrl { get; set; }
[Parameter("Docker Image Name")] public static string DockerImageName { get; set; }
Expand Down Expand Up @@ -56,6 +70,7 @@ internal partial class Build
});

public Target BuildAndPush => _ => _
.Before(CloudInit)
.DependsOn(DockerLogin, BuildImage, PushImage);
}
}
16 changes: 8 additions & 8 deletions src/VirtoCommerce.Build/PlatformTools/Build.PackageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ private static bool IsPlatformInstallationNeeded(string version)
public Target InstallModules => _ => _
.After(InstallPlatform)
.OnlyWhenDynamic(() => !PlatformParameter)
.ProceedAfterFailure()
.Executes(async () =>
{
if (!RunningTargets.Contains(Install))
Expand Down Expand Up @@ -395,11 +394,13 @@ private static bool IsPlatformInstallationNeeded(string version)
{
if (m.Level == ProgressMessageLevel.Error)
{
Assert.Fail(m.Message);
ExitCode = 1;
Log.Error(m.Message);

}
else
{
Log.Information(m.Message);
Log.Information(m.Message);
}
});

Expand All @@ -415,12 +416,11 @@ private static bool IsPlatformInstallationNeeded(string version)
modulesToInstall.AddRange(missingModules);
}
modulesToInstall.ForEach(module => module.DependsOn.Clear());
try
{
moduleInstaller.Install(modulesToInstall, progress);
} catch (Exception ex)
moduleInstaller.Install(modulesToInstall, progress);

if (ExitCode > 0)
{
Assert.Fail(ex.Message);
Assert.Fail("Errors occurred while installing modules.");
}

foreach (var moduleSource in moduleSources)
Expand Down
2 changes: 1 addition & 1 deletion src/VirtoCommerce.Build/VirtoCommerce.Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<None Include="..\appveyor.yml" LinkBase="ci" Condition="Exists('..\appveyor.yml')" />
<None Include="..\.travis.yml" LinkBase="ci" Condition="Exists('..\.travis.yml')" />
<None Remove="Microsoft.TeamFoundationServer.Client" />

<None Remove="YamlDotNet" />
<None Remove="Cloud\Models\" />
<None Remove="Utils\" />
Expand Down

0 comments on commit e516895

Please sign in to comment.