Skip to content

Commit

Permalink
Merge branch 'release/3.803.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
vc-ci committed Aug 12, 2024
2 parents acdfd54 + b88b0a1 commit d02ea93
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 48 deletions.
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ jobs:
id: image
with:
projectType: "platform"
releaseBranch: "main"

- name: Add version suffix
if: ${{ github.ref != 'refs/heads/main' }}
Expand Down
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.802.0</VersionPrefix>
<VersionPrefix>3.803.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<VersionSuffix Condition=" '$(VersionSuffix)' != '' AND '$(BuildNumber)' != '' ">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
</PropertyGroup>
Expand Down
29 changes: 26 additions & 3 deletions src/VirtoCommerce.Build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Microsoft.Build.Locator;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NuGet.Packaging;
using Nuke.Common;
using Nuke.Common.Execution;
using Nuke.Common.Git;
Expand Down Expand Up @@ -90,8 +91,7 @@ public static Solution Solution
[Parameter] public static string Source { get; set; } = "https://api.nuget.org/v3/index.json";

[Parameter]
public static string GlobalModuleIgnoreFileUrl { get; set; } =
"https://raw.githubusercontent.com/VirtoCommerce/vc-platform/dev/module.ignore";
public static string GlobalModuleIgnoreFileUrl { get; set; }

[Parameter] public static string SonarAuthToken { get; set; } = "";

Expand Down Expand Up @@ -1249,7 +1249,30 @@ private void CompressExecuteMethod()
{
if (IsModule)
{
var ignoredFiles = HttpTasks.HttpDownloadString(GlobalModuleIgnoreFileUrl).SplitLineBreaks();
const string moduleIgnoreUrlTemplate = "https://raw.githubusercontent.com/VirtoCommerce/vc-platform/{0}/module.ignore";
if(string.IsNullOrEmpty(GlobalModuleIgnoreFileUrl))
{
Version.TryParse(ModuleManifest.PlatformVersion, out var platformVersion);

const int MajorMinorPatch = 3;
GlobalModuleIgnoreFileUrl = string.Format(moduleIgnoreUrlTemplate, platformVersion?.ToString(MajorMinorPatch) ?? "dev");
}

string[] ignoredFiles;
if (GlobalModuleIgnoreFileUrl.StartsWith("http"))
{
var responseString = HttpTasks.HttpDownloadString(GlobalModuleIgnoreFileUrl);
if (responseString.StartsWith("404:"))
{
responseString = HttpTasks.HttpDownloadString(string.Format(moduleIgnoreUrlTemplate, "dev"));
}
ignoredFiles = responseString.SplitLineBreaks();
}
else
{
ignoredFiles = File.ReadAllLines(GlobalModuleIgnoreFileUrl);
}


if (ModuleIgnoreFile.FileExists())
{
Expand Down
39 changes: 36 additions & 3 deletions src/VirtoCommerce.Build/Cloud/Build.SaaS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public string CloudAuthProvider
for (var i = 0; i < AttemptsNumber; i++)
{
Log.Information($"Attempt #{i + 1}");
var env = await cloudClient.GetEnvironment(EnvironmentName);
var env = await cloudClient.GetEnvironmentAsync(EnvironmentName);
Log.Information(
$"Actual Health Status is {env.Status} - expected is {HealthStatus ?? "Not expected"}\n Actual Sync Status is {env.SyncStatus} - expected is {SyncStatus ?? "Not expected"}");
if (CheckAppServiceStatus(HealthStatus, env.Status) &&
Expand All @@ -106,12 +106,37 @@ public string CloudAuthProvider
Assert.True(isSuccess, $"Statuses {HealthStatus} {SyncStatus} were not obtained for the number of attempts: {AttemptsNumber}");
});

private static async Task<bool> WaitForEnvironmentState(Func<Task<CloudEnvironment>> cloudEnvProvider, Func<CloudEnvironment, bool> condition, int delay, int attempts)
{
for (var i = 0; i < attempts; i++)
{
var env = await cloudEnvProvider();
Log.Information($"Attempt #{i + 1}");
Log.Information($"Health Status is {env.Status}\nSync Status is {env.SyncStatus}");
if (condition(env))
{
return true;
}

await Task.Delay(TimeSpan.FromSeconds(delay));
}

return false;
}
public Target CloudEnvSetParameter => _ => _
.Executes(async () =>
{
var cloudClient = new VirtoCloudClient(CloudUrl, await GetCloudTokenAsync());
var env = await cloudClient.GetEnvironment(EnvironmentName, SaaSOrganizationName);

var isProgressing = await WaitForEnvironmentState(async () => await cloudClient.GetEnvironmentAsync(EnvironmentName, SaaSOrganizationName),
env => env.Status != "Progressing", Delay, AttemptsNumber);

if (!isProgressing)
{
Assert.Fail("Environment is in 'Progressing' status for too long.");
}

var env = await cloudClient.GetEnvironmentAsync(EnvironmentName, SaaSOrganizationName);

var envHelmParameters = env.Helm.Parameters;
foreach (var parameter in HelmParameters)
Expand Down Expand Up @@ -259,7 +284,7 @@ private static void CopyPlatformDirectory(AbsolutePath platformDirectory, Absolu
.Executes(async () =>
{
var cloudClient = new VirtoCloudClient(CloudUrl, await GetCloudTokenAsync());
var env = await cloudClient.GetEnvironment(EnvironmentName, SaaSOrganizationName);
var env = await cloudClient.GetEnvironmentAsync(EnvironmentName, SaaSOrganizationName);

var envHelmParameters = env.Helm.Parameters;

Expand Down Expand Up @@ -293,6 +318,14 @@ private static void CopyPlatformDirectory(AbsolutePath platformDirectory, Absolu
SaveCloudToken(apiKey);
});

public Target CloudDownloadManifest => _ => _
.Executes(async () =>
{
var cloudClient = new VirtoCloudClient(CloudUrl, await GetCloudTokenAsync());
var manifest = await cloudClient.GetManifest(EnvironmentName, SaaSOrganizationName);
File.WriteAllText(string.IsNullOrWhiteSpace(Manifest) ? Path.Combine(Directory.GetCurrentDirectory(), $"{EnvironmentName}.yml") : Manifest, manifest);
});

private async Task<string> GetCloudTokenAsync()
{
if (!string.IsNullOrEmpty(CloudToken))
Expand Down
21 changes: 18 additions & 3 deletions src/VirtoCommerce.Build/Cloud/Client/VirtoCloudClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Cloud.Models;
using Nuke.Common;
using Nuke.Common.IO;
using Nuke.Common.Utilities;
using VirtoCloud.Client.Model;

namespace Cloud.Client;

Expand Down Expand Up @@ -52,7 +51,7 @@ public async Task UpdateEnvironmentAsync(CloudEnvironment environment)
}
}

public async Task<CloudEnvironment> GetEnvironment(string environmentName, string orgName = null)
public async Task<CloudEnvironment> GetEnvironmentAsync(string environmentName, string orgName = null)
{
var relativeUri = string.IsNullOrWhiteSpace(orgName) ? $"api/saas/environments/{environmentName}" : $"api/saas/environments/{orgName}/{environmentName}";
var response = await _client.SendAsync(new HttpRequestMessage
Expand All @@ -69,4 +68,20 @@ public async Task<CloudEnvironment> GetEnvironment(string environmentName, strin
var env = JsonExtensions.GetJson<CloudEnvironment>(responseContent);
return env;
}

public async Task<string> GetManifest(string environmentName, string orgName = null)
{
var relativeUri = string.IsNullOrWhiteSpace(orgName) ? $"api/saas/environments/{environmentName}/manifest" : $"api/saas/environments/manifest/{orgName}/{environmentName}";
var response = await _client.SendAsync(new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri(relativeUri, UriKind.Relative)
});
if (!response.IsSuccessStatusCode)
{
Assert.Fail($"{response.ReasonPhrase}: {await response.Content.ReadAsStringAsync()}");
}

return await response.Content.ReadAsStringAsync();
}
}
28 changes: 0 additions & 28 deletions src/VirtoCommerce.Build/Cloud/Models/CloudEnvironment.cs

This file was deleted.

9 changes: 0 additions & 9 deletions src/VirtoCommerce.Build/Cloud/Models/Helm.cs

This file was deleted.

0 comments on commit d02ea93

Please sign in to comment.