Skip to content

Commit

Permalink
Release v1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
operate-services-sdk-bot committed Jul 18, 2024
1 parent 5f95e87 commit ef644ac
Show file tree
Hide file tree
Showing 40 changed files with 805 additions and 88 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ All notable changes to UGS CLI will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [1.6.0] - 2024-07-18

### Changed
- [Game Server Hosting] Mark options: `--speed`, `--cores` and `--memory` for CREATE and UPDATE of `gsh build configuration` as deprecated to allow for backwards compatibility.
New usage should be set on the fleet using [server density configuration](https://docs.unity.com/ugs/en-us/manual/game-server-hosting/manual/guides/configure-server-density)

### Fixed
- [Remote Config] Fixed import and export on an empty environment.
- [Cloud Content Delivery] Now normalizing the path to always use forward slashes even on windows platform.

### Added
- [Game Server Hosting] Added support for Google Cloud Storage (GCS) as a source for Builds and Build Configurations.

## [1.5.0] - 2024-06-12

Expand Down Expand Up @@ -97,7 +109,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added Deployment Definitions to the Deploy and Fetch commands.
- Added analytics related to command usage and options used.
- Deploy/Fetch return an array in a table-like format with -json flag enabled.
- Leaderboards now supports the `ugs deploy` and `ugs fetch` commands at the root
- Leaderboards now supports the `ugs deploy` and `ugs fetch` commands at the root
- Deploy sends file configurations into the service
- Fetch updates local files based on service configuration
- Leaderboards now supports `new-file`, to create an empty file for leaderboards
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void InitializeChangeProperties()
Assert.That(m_ProjectAccessClient.CancellationToken, Is.EqualTo(CancellationToken.None));
});
CancellationToken cancellationToken = new(true);
m_ProjectAccessClient!.Initialize( k_TestEnvironmentId, k_TestProjectId, cancellationToken);
m_ProjectAccessClient!.Initialize(k_TestEnvironmentId, k_TestProjectId, cancellationToken);
Assert.Multiple(() =>
{
Assert.That(m_ProjectAccessClient.ProjectId, Is.SameAs(k_TestProjectId));
Expand Down Expand Up @@ -68,7 +68,7 @@ public async Task GetAsyncForPolicyWithNoStatements()
[Test]
public async Task GetAsyncForPolicyWithStatements()
{
var policy = TestMocks.GetPolicy(new List<ProjectStatement>(){TestMocks.GetProjectStatement()});
var policy = TestMocks.GetPolicy(new List<ProjectStatement>() { TestMocks.GetProjectStatement() });
m_MockAccessService.Setup(r => r.GetPolicyAsync(k_TestProjectId, k_TestEnvironmentId, CancellationToken.None)).ReturnsAsync(policy);

var authoringStatements = new List<AccessControlStatement>()
Expand All @@ -85,17 +85,17 @@ public async Task GetAsyncForPolicyWithStatements()
[Test]
public async Task UpsertAsyncSuccessfully()
{
var authoringStatements = new List<AccessControlStatement>(){TestMocks.GetAuthoringStatement("sid-1"), TestMocks.GetAuthoringStatement("sid-2")};
var policy = TestMocks.GetPolicy(new List<ProjectStatement>(){TestMocks.GetProjectStatement("sid-1"), TestMocks.GetProjectStatement("sid-2")});
var authoringStatements = new List<AccessControlStatement>() { TestMocks.GetAuthoringStatement("sid-1"), TestMocks.GetAuthoringStatement("sid-2") };
var policy = TestMocks.GetPolicy(new List<ProjectStatement>() { TestMocks.GetProjectStatement("sid-1"), TestMocks.GetProjectStatement("sid-2") });
await m_ProjectAccessClient!.UpsertAsync(authoringStatements);
m_MockAccessService.Verify(ac => ac.UpsertProjectAccessCaCAsync(k_TestProjectId, k_TestEnvironmentId, policy, CancellationToken.None), Times.Once);
}

[Test]
public async Task DeleteAsyncSuccessfully()
{
var authoringStatements = new List<AccessControlStatement>(){TestMocks.GetAuthoringStatement("sid-1"), TestMocks.GetAuthoringStatement("sid-2")};
var deleteOptions = TestMocks.GetDeleteOptions(new List<string>(){"sid-1", "sid-2"});
var authoringStatements = new List<AccessControlStatement>() { TestMocks.GetAuthoringStatement("sid-1"), TestMocks.GetAuthoringStatement("sid-2") };
var deleteOptions = TestMocks.GetDeleteOptions(new List<string>() { "sid-1", "sid-2" });
await m_ProjectAccessClient!.DeleteAsync(authoringStatements);
m_MockAccessService.Verify(ac => ac.DeleteProjectAccessCaCAsync(k_TestProjectId, k_TestEnvironmentId, deleteOptions, CancellationToken.None), Times.Once);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public void UpsertProjectAccessCaCAsync_Invalid_ApiThrowsError()
[Test]
public async Task DeleteProjectAccessCaCAsync_Valid()
{
var statementIDs = new List<string>(){"statement-1"};
var statementIDs = new List<string>() { "statement-1" };
m_ProjectPolicyApi.Setup(a => a.DeletePolicyStatementsAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<DeleteOptions>(), It.IsAny<int>(), CancellationToken.None));

await m_AccessService!.DeleteProjectAccessCaCAsync(TestValues.ValidProjectId, TestValues.ValidEnvironmentId, TestMocks.GetDeleteOptions(statementIDs),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public async Task<List<AccessControlStatement>> GetAsync()
{
var policy = await m_Service.GetPolicyAsync(ProjectId, EnvironmentId, CancellationToken);

return (policy.Statements == null || policy.Statements?.Count == 0) ? new List<AccessControlStatement>() : GetAuthoringStatementsFromPolicy(policy);
return (policy.Statements == null || policy.Statements?.Count == 0) ? new List<AccessControlStatement>() : GetAuthoringStatementsFromPolicy(policy);
}

public async Task UpsertAsync(IReadOnlyList<AccessControlStatement> authoringStatements)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ public async Task ExportAsync(ExportInput input, CancellationToken cancellationT
var configs = await ListConfigsAsync(projectId, environmentId, cancellationToken);
var state = new ExportState<T>(configs.Select(ToImportExportEntry).ToList());

if (!configs.Any())
{
m_Logger.LogInformation("No content to export.");
return;
}

if (!input.DryRun)
{
await ExportToZipAsync(input.OutputDirectory, fileName, state, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Net;
using System.Runtime.InteropServices;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NUnit.Framework;
Expand Down Expand Up @@ -103,4 +104,46 @@ public void ValidateParseMetadata_InvalidJson_ThrowsException()
Assert.Throws<CliException>(() => CcdUtils.ParseMetadata("[invalid]"));
}

[Test]
public void AdjustPathForPlatform_ValidInput_ReturnsAdjustedPath()
{
const string input = "images/image.jpg";
const string expectedBackwardSlashes = "images\\image.jpg";
const string expectedForwardSlashes = "images/image.jpg";

string result = CcdUtils.AdjustPathForPlatform(input);

if (Path.DirectorySeparatorChar == '\\')
{
Assert.That(result, Is.EqualTo(expectedBackwardSlashes), "The adjusted path should use backward slashes.");
}
else
{
Assert.That(result, Is.EqualTo(expectedForwardSlashes), "The adjusted path should use forward slashes.");
}

}

[Test]
public void AdjustPathForWindowsUsers_EmptyOrNullInput_ReturnsSame()
{
Assert.That(CcdUtils.AdjustPathForPlatform(""), Is.EqualTo(""), "The result should be an empty string when the input is an empty string.");
}

[Test]
public void ConvertPathToForwardSlashes_ValidInput_ReturnsConvertedPath()
{
const string input = "images\\image.jpg";
const string expected = "images/image.jpg";

var result = CcdUtils.ConvertPathToForwardSlashes(input);
Assert.That(result, Is.EqualTo(expected), "The converted path should match the expected result.");
}

[Test]
public void ConvertPathToForwardSlashes_EmptyOrNullInput_ReturnsSame()
{
Assert.That(CcdUtils.ConvertPathToForwardSlashes(""), Is.EqualTo(""), "The result should be an empty string when the input is an empty string.");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ await m_EntriesApi.DeleteEntryEnvAsync(
m_ContentDeliveryValidator.ValidatePath(localPath);
m_ContentDeliveryValidator.ValidatePath(remotePath);

localPath = CcdUtils.AdjustPathForPlatform(localPath);
remotePath = CcdUtils.ConvertPathToForwardSlashes(remotePath);

await using var filestream = m_FileSystem.File.OpenRead(localPath);
var contentSize = m_UploadContentClient.GetContentSize(filestream);
var contentType = m_UploadContentClient.GetContentType(localPath);
Expand All @@ -192,6 +195,7 @@ await m_EntriesApi.DeleteEntryEnvAsync(
labels,
entryMetadata,
true);

var entry = await m_EntriesApi.CreateOrUpdateEntryByPathEnvAsync(
environmentId,
bucketId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Text.RegularExpressions;
using Microsoft.Extensions.Logging;
using Unity.Services.Cli.CloudContentDelivery.Model;
using Unity.Services.Cli.CloudContentDelivery.Utils;
using Unity.Services.Cli.Common.Exceptions;
using Unity.Services.Cli.ServiceAccountAuthentication;
using Unity.Services.Cli.ServiceAccountAuthentication.Token;
Expand Down Expand Up @@ -192,11 +193,12 @@ public SyncResult CalculateDifference(

foreach (var remoteEntry in remoteEntries)
{
var path = remoteEntry.Path;
var path = CcdUtils.ConvertPathToForwardSlashes(remoteEntry.Path);

if (localFiles.Contains(path))
{
var filePath = Path.Combine(localFolder, path);
filePath = CcdUtils.AdjustPathForPlatform(filePath);
try
{
using (var filestream = m_FileSystem.File.OpenRead(filePath))
Expand Down Expand Up @@ -268,6 +270,7 @@ public SyncResult CalculateDifference(
foreach (var path in localFiles)
{
var filePath = Path.Combine(localFolder, path);
filePath = CcdUtils.AdjustPathForPlatform(filePath);
using var filestream = m_FileSystem.File.OpenRead(filePath);
var contentSize = m_UploadContentClient.GetContentSize(filestream);
var contentType = m_UploadContentClient.GetContentType(filePath);
Expand Down Expand Up @@ -452,6 +455,7 @@ await ThrottledRetryPolicyAsync(
try
{
var filePath = Path.Combine(localFolder, createdEntry.Path);
filePath = CcdUtils.AdjustPathForPlatform(filePath);
await using var filestream = m_FileSystem.File.OpenRead(filePath);
var response = await m_UploadContentClient.UploadContentToCcd(
createdEntry.SignedUrl,
Expand Down Expand Up @@ -631,7 +635,7 @@ public HashSet<string> GetFilesFromDir(
}

return new HashSet<string>(
files.Select(filePath => m_FileSystem.Path.GetRelativePath(directoryPath, filePath)));
files.Select(filePath => CcdUtils.ConvertPathToForwardSlashes(m_FileSystem.Path.GetRelativePath(directoryPath, filePath))));
}

public async Task AuthorizeServiceAsync(CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Runtime.InteropServices;
using Newtonsoft.Json;
using Unity.Services.Cli.Common.Exceptions;
using Unity.Services.Gateway.ContentDeliveryManagementApiV1.Generated.Client;
Expand Down Expand Up @@ -47,4 +48,25 @@ 2. Include the -b <bucket-name> option when running the command.
}
}


public static string AdjustPathForPlatform(string path)
{
if (string.IsNullOrEmpty(path) || Path.DirectorySeparatorChar == '/')
{
return path;
}
return path.Replace('/', Path.DirectorySeparatorChar);
}

public static string ConvertPathToForwardSlashes(string path)
{
if (string.IsNullOrEmpty(path))
{
return path;
}

path = path.Replace("\\", "/");

return path;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<PackageReference Include="Unity.Services.Gateway.SchedulerApiV1.Generated" Version="1.0.0" />
<PackageReference Include="Unity.Services.TelemetryApi.Generated" Version="1.0.1" />
<PackageReference Include="Unity.Services.MpsLobby.LobbyApiV1.Generated" Version="0.11.1" />
<PackageReference Include="Unity.Services.Gateway.GameServerHostingApiV1.Generated" Version="0.11.0" />
<PackageReference Include="Unity.Services.Gateway.GameServerHostingApiV1.Generated" Version="0.12.2" />
<PackageReference Include="UnityAnalytic.Modules.Sender" Version="0.1.0" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static class GameServerHostingUnitTestsConstants
public const long ValidBuildIdBucket = 201;
public const long ValidBuildIdContainer = 202;
public const long ValidBuildIdFileUpload = 203;
public const long ValidBuildIdGcs = 204;
public const long SyncingBuildId = 333;

// Filenames
Expand Down
Loading

0 comments on commit ef644ac

Please sign in to comment.