Skip to content

Commit 1406016

Browse files
authored
Add support for project's "releases_access_level" + a bit more (#591)
* Add support for project's "releases_access_level" + a bit more * review * update
1 parent ee644fe commit 1406016

File tree

7 files changed

+25
-8
lines changed

7 files changed

+25
-8
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ jobs:
5151
# Keep in sync with the version in GitLabDockerContainer.cs
5252
# Available tags: https://hub.docker.com/r/gitlab/gitlab-ee/tags
5353
gitlab: [
54-
'gitlab/gitlab-ee:15.4.6-ee.0',
5554
'gitlab/gitlab-ee:15.11.9-ee.0',
55+
'gitlab/gitlab-ee:15.11.13-ee.0',
5656
]
5757
configuration: [ Release ]
5858
fail-fast: false

NGitLab.Tests/Docker/GitLabDockerContainer.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Linq;
99
using System.Net;
1010
using System.Net.Http;
11-
using System.Runtime.InteropServices;
1211
using System.Text.Json;
1312
using System.Threading;
1413
using System.Threading.Tasks;
@@ -27,7 +26,7 @@ public class GitLabDockerContainer
2726
public const string ImageName = "gitlab/gitlab-ee";
2827

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

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

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

NGitLab.Tests/Docker/GitLabTestContext.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,11 @@ public async Task<IDisposable> StartRunnerForOneJobAsync(int projectId)
300300
if (!File.Exists(path))
301301
{
302302
Uri url;
303-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
303+
if (OperatingSystem.IsWindows())
304304
{
305305
url = new Uri($"https://gitlab-runner-downloads.s3.amazonaws.com/v{version}/binaries/gitlab-runner-windows-amd64.exe");
306306
}
307-
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
307+
else if (OperatingSystem.IsLinux())
308308
{
309309
url = new Uri($"https://gitlab-runner-downloads.s3.amazonaws.com/v{version}/binaries/gitlab-runner-linux-amd64");
310310
}
@@ -335,7 +335,7 @@ public async Task<IDisposable> StartRunnerForOneJobAsync(int projectId)
335335
}
336336

337337
TestContext.WriteLine("Test runner downloaded");
338-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
338+
if (OperatingSystem.IsLinux())
339339
{
340340
using var chmodProcess = Process.Start("chmod", "+x \"" + path + "\"");
341341
chmodProcess.WaitForExit();
@@ -379,7 +379,7 @@ public async Task<IDisposable> StartRunnerForOneJobAsync(int projectId)
379379
"run-single",
380380
"--url", DockerContainer.GitLabUrl.ToString(),
381381
"--executor", "shell",
382-
"--shell", RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "powershell" : "pwsh",
382+
"--shell", OperatingSystem.IsWindows() ? "powershell" : "pwsh",
383383
"--builds-dir", buildDir,
384384
"--wait-timeout", "240", // in seconds
385385
"--token", runner.Token,

NGitLab.Tests/ReleaseClientTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public async Task Test_release_api()
3030
Description = "test",
3131
});
3232

33+
Assert.AreEqual(ReleasesAccessLevel.Enabled, project.ReleasesAccessLevel);
3334
Assert.That(release.TagName, Is.EqualTo("0.7"));
3435
Assert.That(release.Name, Is.EqualTo("0.7"));
3536
Assert.That(release.Description, Is.EqualTo("test"));

NGitLab/Models/Project.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,5 +212,8 @@ public class Project
212212

213213
[JsonPropertyName("permissions")]
214214
public ProjectPermissions Permissions;
215+
216+
[JsonPropertyName("releases_access_level")]
217+
public ReleasesAccessLevel ReleasesAccessLevel { get; set; }
215218
}
216219
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace NGitLab.Models;
2+
3+
public enum ReleasesAccessLevel
4+
{
5+
Disabled,
6+
Private,
7+
Enabled,
8+
}

NGitLab/PublicAPI.Unshipped.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2731,6 +2731,8 @@ NGitLab.Models.Project.PrintingMergeRequestsLinkEnabled -> bool
27312731
NGitLab.Models.Project.Project() -> void
27322732
NGitLab.Models.Project.Public -> bool
27332733
NGitLab.Models.Project.PublicJobs -> bool
2734+
NGitLab.Models.Project.ReleasesAccessLevel.get -> NGitLab.Models.ReleasesAccessLevel
2735+
NGitLab.Models.Project.ReleasesAccessLevel.set -> void
27342736
NGitLab.Models.Project.RepositoryAccessLevel -> NGitLab.Models.RepositoryAccessLevel
27352737
NGitLab.Models.Project.RepositoryStorage -> string
27362738
NGitLab.Models.Project.RequestAccessEnabled -> bool
@@ -3146,6 +3148,10 @@ NGitLab.Models.ReleaseQuery.PerPage.set -> void
31463148
NGitLab.Models.ReleaseQuery.ReleaseQuery() -> void
31473149
NGitLab.Models.ReleaseQuery.Sort.get -> string
31483150
NGitLab.Models.ReleaseQuery.Sort.set -> void
3151+
NGitLab.Models.ReleasesAccessLevel
3152+
NGitLab.Models.ReleasesAccessLevel.Disabled = 0 -> NGitLab.Models.ReleasesAccessLevel
3153+
NGitLab.Models.ReleasesAccessLevel.Enabled = 2 -> NGitLab.Models.ReleasesAccessLevel
3154+
NGitLab.Models.ReleasesAccessLevel.Private = 1 -> NGitLab.Models.ReleasesAccessLevel
31493155
NGitLab.Models.ReleaseUpdate
31503156
NGitLab.Models.ReleaseUpdate.Description.get -> string
31513157
NGitLab.Models.ReleaseUpdate.Description.set -> void

0 commit comments

Comments
 (0)