2using System.Collections.Generic;
5using System.Threading.Tasks;
7using Microsoft.Extensions.Logging;
27 protected ILogger<BaseRemoteDeploymentManager>
Logger {
get; }
36 Logger = logger ??
throw new ArgumentNullException(nameof(logger));
37 Metadata = metadata ??
throw new ArgumentNullException(nameof(metadata));
47 CancellationToken cancellationToken)
49 if (repositorySettings?.AccessToken ==
null)
53 if ((previousRevisionInformation !=
null && previousRevisionInformation.
CommitSha == deployedRevisionInformation.CommitSha)
58 previousRevisionInformation.ActiveTestMerges ??=
new List<RevInfoTestMerge>();
60 deployedRevisionInformation.ActiveTestMerges ??=
new List<RevInfoTestMerge>();
61 var tasks =
new List<Task>();
64 var addedTestMerges = deployedRevisionInformation
66 .Select(x => x.TestMerge)
67 .Where(x => !previousRevisionInformation
69 .Any(y => y.TestMerge.Number == x.Number))
71 var removedTestMerges = previousRevisionInformation
73 .Select(x => x.TestMerge)
74 .Where(x => !deployedRevisionInformation
76 .Any(y => y.TestMerge.Number == x.Number))
78 var updatedTestMerges = deployedRevisionInformation
80 .Select(x => x.TestMerge)
81 .Where(x => previousRevisionInformation
83 .Any(y => y.TestMerge.Number == x.Number))
86 if (!addedTestMerges.Any() && !removedTestMerges.Any() && !updatedTestMerges.Any())
90 "Commenting on {0} added, {1} removed, and {2} updated test merge sources...",
91 addedTestMerges.Count,
92 removedTestMerges.Count,
93 updatedTestMerges.Count);
94 foreach (var addedTestMerge
in addedTestMerges)
107 addedTestMerge.Number,
110 foreach (var removedTestMerge
in removedTestMerges)
116 "#### Test Merge Removed",
117 removedTestMerge.Number,
120 foreach (var updatedTestMerge
in updatedTestMerges)
133 updatedTestMerge.Number,
137 await Task.WhenAll(tasks);
154 CancellationToken cancellationToken);
161 Api.Models.Internal.IGitRemoteInformation remoteInformation,
163 CancellationToken cancellationToken);
179 string remoteRepositoryOwner,
180 string remoteRepositoryName,
195 string remoteRepositoryOwner,
196 string remoteRepositoryName,
199 CancellationToken cancellationToken);
Metadata about a server instance.
bool? PostTestMergeComment
If test merging should create a comment. Requires AccessToken to be set to function.
Base class for implementing IRemoteDeploymentManagers.
abstract Task CommentOnTestMergeSource(RepositorySettings repositorySettings, string remoteRepositoryOwner, string remoteRepositoryName, string comment, int testMergeNumber, CancellationToken cancellationToken)
Create a comment of a given testMergeNumber 's source.
Api.Models.Instance Metadata
The Api.Models.Instance for the BaseRemoteDeploymentManager.
abstract Task StageDeployment(CompileJob compileJob, CancellationToken cancellationToken)
Stage a given compileJob 's deployment. A Task representing the running operation.
abstract Task< IReadOnlyCollection< TestMerge > > RemoveMergedTestMerges(IRepository repository, RepositorySettings repositorySettings, RevisionInformation revisionInformation, CancellationToken cancellationToken)
Get the updated list of TestMerges for an origin merge. A Task<TResult> resulting in the IReadOnlyCol...
abstract string FormatTestMerge(RepositorySettings repositorySettings, CompileJob compileJob, TestMerge testMerge, string remoteRepositoryOwner, string remoteRepositoryName, bool updated)
Formats a comment for a given testMerge .
abstract Task FailDeployment(CompileJob compileJob, string errorMessage, CancellationToken cancellationToken)
Fail a deployment for a given compileJob . A Task representing the running operation.
abstract Task MarkInactive(CompileJob compileJob, CancellationToken cancellationToken)
Mark the deplotment for a given compileJob as inactive. A Task representing the running operation.
async Task PostDeploymentComments(CompileJob compileJob, RevisionInformation previousRevisionInformation, RepositorySettings repositorySettings, string repoOwner, string repoName, CancellationToken cancellationToken)
Post deployment comments to the test merge ticket. A Task representing the running operation.
abstract Task StartDeployment(Api.Models.Internal.IGitRemoteInformation remoteInformation, CompileJob compileJob, CancellationToken cancellationToken)
Start a deployment for a given compileJob . A Task representing the running operation.
BaseRemoteDeploymentManager(ILogger< BaseRemoteDeploymentManager > logger, Api.Models.Instance metadata)
Initializes a new instance of the BaseRemoteDeploymentManager class.
ILogger< BaseRemoteDeploymentManager > Logger
The ILogger for the BaseRemoteDeploymentManager.
abstract Task ApplyDeployment(CompileJob compileJob, CompileJob oldCompileJob, CancellationToken cancellationToken)
Stage a given compileJob 's deployment. A Task representing the running operation.
RevisionInformation RevisionInformation
See CompileJobResponse.RevisionInformation.
Creates and updates remote deployments.
Represents an on-disk git repository.