|
16 | 16 | using System.Threading.Tasks;
|
17 | 17 | using Redpoint.Concurrency;
|
18 | 18 | using Redpoint.Uet.BuildPipeline.BuildGraph.PreBuild;
|
| 19 | + using System.Collections.Specialized; |
19 | 20 |
|
20 | 21 | public class GitLabBuildNodeExecutor : IBuildNodeExecutor
|
21 | 22 | {
|
@@ -60,6 +61,42 @@ private class NodeNameExecutionState
|
60 | 61 | public string? NodeName;
|
61 | 62 | }
|
62 | 63 |
|
| 64 | + private async Task<IWorkspace> GetGitWorkspaceAsync( |
| 65 | + string repository, |
| 66 | + string commit, |
| 67 | + string branch, |
| 68 | + IReadOnlyList<string> nodeNames, |
| 69 | + BuildSpecification buildSpecification, |
| 70 | + CancellationToken cancellationToken) |
| 71 | + { |
| 72 | + NameValueCollection? queryString = null; |
| 73 | + if (buildSpecification.Engine.IsNonConcurrent) |
| 74 | + { |
| 75 | + _logger.LogInformation("Requesting non-concurrent Git workspace, because the engine is non-concurrent."); |
| 76 | + queryString = new NameValueCollection |
| 77 | + { |
| 78 | + { "concurrent", "false" } |
| 79 | + }; |
| 80 | + } |
| 81 | + |
| 82 | + return await _workspaceProvider.GetWorkspaceAsync( |
| 83 | + new GitWorkspaceDescriptor |
| 84 | + { |
| 85 | + RepositoryUrl = repository, |
| 86 | + RepositoryCommitOrRef = commit, |
| 87 | + RepositoryBranchForReservationParameters = branch, |
| 88 | + AdditionalFolderLayers = Array.Empty<string>(), |
| 89 | + AdditionalFolderZips = Array.Empty<string>(), |
| 90 | + WorkspaceDisambiguators = nodeNames, |
| 91 | + ProjectFolderName = buildSpecification.ProjectFolderName, |
| 92 | + BuildType = GitWorkspaceDescriptorBuildType.Generic, |
| 93 | + WindowsSharedGitCachePath = null, |
| 94 | + MacSharedGitCachePath = null, |
| 95 | + QueryString = queryString, |
| 96 | + }, |
| 97 | + cancellationToken).ConfigureAwait(false); |
| 98 | + } |
| 99 | + |
63 | 100 | public async Task<int> ExecuteBuildNodesAsync(
|
64 | 101 | BuildSpecification buildSpecification,
|
65 | 102 | BuildConfigDynamic<BuildConfigPluginDistribution, IPrepareProvider>[]? preparePlugin,
|
@@ -247,20 +284,12 @@ async Task<int> ExecuteNodesInWorkspaceAsync(
|
247 | 284 | _logger.LogTrace($"Executing build with engine build type of 'CurrentWorkspace', obtaining single workspace and using it as the engine directory as well.");
|
248 | 285 |
|
249 | 286 | _logger.LogTrace($"Obtaining workspace for build.");
|
250 |
| - await using ((await _workspaceProvider.GetWorkspaceAsync( |
251 |
| - new GitWorkspaceDescriptor |
252 |
| - { |
253 |
| - RepositoryUrl = repository, |
254 |
| - RepositoryCommitOrRef = commit, |
255 |
| - RepositoryBranchForReservationParameters = branch, |
256 |
| - AdditionalFolderLayers = Array.Empty<string>(), |
257 |
| - AdditionalFolderZips = Array.Empty<string>(), |
258 |
| - WorkspaceDisambiguators = nodeNames, |
259 |
| - ProjectFolderName = buildSpecification.ProjectFolderName, |
260 |
| - BuildType = GitWorkspaceDescriptorBuildType.Generic, |
261 |
| - WindowsSharedGitCachePath = null, |
262 |
| - MacSharedGitCachePath = null, |
263 |
| - }, |
| 287 | + await using ((await GetGitWorkspaceAsync( |
| 288 | + repository, |
| 289 | + commit, |
| 290 | + branch, |
| 291 | + nodeNames, |
| 292 | + buildSpecification, |
264 | 293 | cancellationToken).ConfigureAwait(false)).AsAsyncDisposable(out var targetWorkspace).ConfigureAwait(false))
|
265 | 294 | {
|
266 | 295 | _logger.LogTrace($"Calling ExecuteNodesInWorkspaceAsync inside allocated workspace.");
|
@@ -291,20 +320,12 @@ async Task<int> ExecuteNodesInWorkspaceAsync(
|
291 | 320 | _logger.LogTrace($"Executing build with engine build type of 'None', obtained engine workspace and obtaining target workspace separately.");
|
292 | 321 |
|
293 | 322 | _logger.LogTrace($"Obtaining workspace for build.");
|
294 |
| - await using ((await _workspaceProvider.GetWorkspaceAsync( |
295 |
| - new GitWorkspaceDescriptor |
296 |
| - { |
297 |
| - RepositoryUrl = repository, |
298 |
| - RepositoryCommitOrRef = commit, |
299 |
| - RepositoryBranchForReservationParameters = branch, |
300 |
| - AdditionalFolderLayers = Array.Empty<string>(), |
301 |
| - AdditionalFolderZips = Array.Empty<string>(), |
302 |
| - WorkspaceDisambiguators = nodeNames, |
303 |
| - ProjectFolderName = buildSpecification.ProjectFolderName, |
304 |
| - BuildType = GitWorkspaceDescriptorBuildType.Generic, |
305 |
| - WindowsSharedGitCachePath = null, |
306 |
| - MacSharedGitCachePath = null, |
307 |
| - }, |
| 323 | + await using ((await GetGitWorkspaceAsync( |
| 324 | + repository, |
| 325 | + commit, |
| 326 | + branch, |
| 327 | + nodeNames, |
| 328 | + buildSpecification, |
308 | 329 | cancellationToken).ConfigureAwait(false)).AsAsyncDisposable(out var targetWorkspace).ConfigureAwait(false))
|
309 | 330 | {
|
310 | 331 | _logger.LogTrace($"Calling ExecuteNodesInWorkspaceAsync inside allocated workspace.");
|
|
0 commit comments