Skip to content

Commit

Permalink
Add support for project's "releases_access_level" + a bit more (#591)
Browse files Browse the repository at this point in the history
* Add support for project's "releases_access_level" + a bit more

* review

* update
  • Loading branch information
louis-z authored Dec 6, 2023
1 parent ee644fe commit 1406016
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ jobs:
# Keep in sync with the version in GitLabDockerContainer.cs
# Available tags: https://hub.docker.com/r/gitlab/gitlab-ee/tags
gitlab: [
'gitlab/gitlab-ee:15.4.6-ee.0',
'gitlab/gitlab-ee:15.11.9-ee.0',
'gitlab/gitlab-ee:15.11.13-ee.0',
]
configuration: [ Release ]
fail-fast: false
Expand Down
5 changes: 2 additions & 3 deletions NGitLab.Tests/Docker/GitLabDockerContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Runtime.InteropServices;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -27,7 +26,7 @@ public class GitLabDockerContainer
public const string ImageName = "gitlab/gitlab-ee";

// https://hub.docker.com/r/gitlab/gitlab-ee/tags/
public const string GitLabDockerVersion = "15.4.6-ee.0"; // Keep in sync with .github/workflows/ci.yml
public const string GitLabDockerVersion = "15.11.9-ee.0"; // Keep in sync with .github/workflows/ci.yml

private static string s_creationErrorMessage;
private static readonly SemaphoreSlim s_setupLock = new(initialCount: 1, maxCount: 1);
Expand Down Expand Up @@ -156,7 +155,7 @@ private async Task SpawnDockerContainerAsync()

// Spawn the container
// https://docs.gitlab.com/omnibus/settings/configuration.html
using var conf = new DockerClientConfiguration(new Uri(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "npipe://./pipe/docker_engine" : "unix:///var/run/docker.sock"));
using var conf = new DockerClientConfiguration(new Uri(OperatingSystem.IsWindows() ? "npipe://./pipe/docker_engine" : "unix:///var/run/docker.sock"));
using var client = conf.CreateClient();
await ValidateDockerIsEnabled(client);

Expand Down
8 changes: 4 additions & 4 deletions NGitLab.Tests/Docker/GitLabTestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,11 @@ public async Task<IDisposable> StartRunnerForOneJobAsync(int projectId)
if (!File.Exists(path))
{
Uri url;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (OperatingSystem.IsWindows())
{
url = new Uri($"https://gitlab-runner-downloads.s3.amazonaws.com/v{version}/binaries/gitlab-runner-windows-amd64.exe");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
else if (OperatingSystem.IsLinux())
{
url = new Uri($"https://gitlab-runner-downloads.s3.amazonaws.com/v{version}/binaries/gitlab-runner-linux-amd64");
}
Expand Down Expand Up @@ -335,7 +335,7 @@ public async Task<IDisposable> StartRunnerForOneJobAsync(int projectId)
}

TestContext.WriteLine("Test runner downloaded");
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
if (OperatingSystem.IsLinux())
{
using var chmodProcess = Process.Start("chmod", "+x \"" + path + "\"");
chmodProcess.WaitForExit();
Expand Down Expand Up @@ -379,7 +379,7 @@ public async Task<IDisposable> StartRunnerForOneJobAsync(int projectId)
"run-single",
"--url", DockerContainer.GitLabUrl.ToString(),
"--executor", "shell",
"--shell", RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "powershell" : "pwsh",
"--shell", OperatingSystem.IsWindows() ? "powershell" : "pwsh",
"--builds-dir", buildDir,
"--wait-timeout", "240", // in seconds
"--token", runner.Token,
Expand Down
1 change: 1 addition & 0 deletions NGitLab.Tests/ReleaseClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public async Task Test_release_api()
Description = "test",
});

Assert.AreEqual(ReleasesAccessLevel.Enabled, project.ReleasesAccessLevel);
Assert.That(release.TagName, Is.EqualTo("0.7"));
Assert.That(release.Name, Is.EqualTo("0.7"));
Assert.That(release.Description, Is.EqualTo("test"));
Expand Down
3 changes: 3 additions & 0 deletions NGitLab/Models/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,8 @@ public class Project

[JsonPropertyName("permissions")]
public ProjectPermissions Permissions;

[JsonPropertyName("releases_access_level")]
public ReleasesAccessLevel ReleasesAccessLevel { get; set; }
}
}
8 changes: 8 additions & 0 deletions NGitLab/Models/ReleasesAccessLevel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace NGitLab.Models;

public enum ReleasesAccessLevel
{
Disabled,
Private,
Enabled,
}
6 changes: 6 additions & 0 deletions NGitLab/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2731,6 +2731,8 @@ NGitLab.Models.Project.PrintingMergeRequestsLinkEnabled -> bool
NGitLab.Models.Project.Project() -> void
NGitLab.Models.Project.Public -> bool
NGitLab.Models.Project.PublicJobs -> bool
NGitLab.Models.Project.ReleasesAccessLevel.get -> NGitLab.Models.ReleasesAccessLevel
NGitLab.Models.Project.ReleasesAccessLevel.set -> void
NGitLab.Models.Project.RepositoryAccessLevel -> NGitLab.Models.RepositoryAccessLevel
NGitLab.Models.Project.RepositoryStorage -> string
NGitLab.Models.Project.RequestAccessEnabled -> bool
Expand Down Expand Up @@ -3146,6 +3148,10 @@ NGitLab.Models.ReleaseQuery.PerPage.set -> void
NGitLab.Models.ReleaseQuery.ReleaseQuery() -> void
NGitLab.Models.ReleaseQuery.Sort.get -> string
NGitLab.Models.ReleaseQuery.Sort.set -> void
NGitLab.Models.ReleasesAccessLevel
NGitLab.Models.ReleasesAccessLevel.Disabled = 0 -> NGitLab.Models.ReleasesAccessLevel
NGitLab.Models.ReleasesAccessLevel.Enabled = 2 -> NGitLab.Models.ReleasesAccessLevel
NGitLab.Models.ReleasesAccessLevel.Private = 1 -> NGitLab.Models.ReleasesAccessLevel
NGitLab.Models.ReleaseUpdate
NGitLab.Models.ReleaseUpdate.Description.get -> string
NGitLab.Models.ReleaseUpdate.Description.set -> void
Expand Down

0 comments on commit 1406016

Please sign in to comment.