2using System.Collections.Generic;
6using System.Threading.Tasks;
8using Microsoft.EntityFrameworkCore;
9using Microsoft.Extensions.Logging;
10using Microsoft.Extensions.Options;
34#pragma warning disable CA1506
36#pragma warning restore CA1506
154 => exception is OperationCanceledException
155 ?
"The job was cancelled!"
186 IMetricFactory metricFactory,
188 ILogger<DreamMaker>
logger,
201 ArgumentNullException.ThrowIfNull(metricFactory);
203 this.logger =
logger ??
throw new ArgumentNullException(nameof(
logger));
204 this.metadata =
metadata ??
throw new ArgumentNullException(nameof(
metadata));
206 successfulDeployments = metricFactory.CreateCounter(
"tgs_successful_deployments",
"The number of deployments that have completed successfully");
207 failedDeployments = metricFactory.CreateCounter(
"tgs_failed_deployments",
"The number of deployments that have failed");
208 attemptedDeployments = metricFactory.CreateCounter(
"tgs_total_deployments",
"The number of deployments that have been attempted");
214#pragma warning disable CA1506
219 CancellationToken cancellationToken)
221 ArgumentNullException.ThrowIfNull(job);
222 ArgumentNullException.ThrowIfNull(databaseContextFactory);
223 ArgumentNullException.ThrowIfNull(progressReporter);
236 Models.CompileJob? compileJob =
null;
237 bool success =
false;
240 string? repoOwner =
null;
241 string? repoName =
null;
242 TimeSpan? averageSpan =
null;
243 Models.RepositorySettings? repositorySettings =
null;
244 Models.DreamDaemonSettings? ddSettings =
null;
245 Models.DreamMakerSettings? dreamMakerSettings =
null;
248 Models.RevisionInformation? revInfo =
null;
250 async databaseContext =>
254 ddSettings = await databaseContext
256 .Where(x => x.InstanceId ==
metadata.Id)
257 .Select(x =>
new Models.DreamDaemonSettings
259 StartupTimeout = x.StartupTimeout,
260 LogOutput = x.LogOutput,
262 .FirstOrDefaultAsync(cancellationToken);
263 if (ddSettings ==
default)
266 dreamMakerSettings = await databaseContext
268 .Where(x => x.InstanceId ==
metadata.Id)
269 .FirstAsync(cancellationToken);
270 if (dreamMakerSettings ==
default)
273 repositorySettings = await databaseContext
275 .Where(x => x.InstanceId ==
metadata.Id)
276 .Select(x =>
new Models.RepositorySettings
278 AccessToken = x.AccessToken,
279 AccessUser = x.AccessUser,
280 ShowTestMergeCommitters = x.ShowTestMergeCommitters,
281 PushTestMergeCommits = x.PushTestMergeCommits,
282 PostTestMergeComment = x.PostTestMergeComment,
284 .FirstOrDefaultAsync(cancellationToken);
285 if (repositorySettings ==
default)
297 var repoSha = repo.
Head;
300 revInfo = await databaseContext
301 .RevisionInformations
302 .Where(x => x.CommitSha == repoSha && x.InstanceId ==
metadata.Id)
303 .Include(x => x.ActiveTestMerges!)
304 .ThenInclude(x => x.TestMerge!)
305 .ThenInclude(x => x.MergedBy)
306 .FirstOrDefaultAsync(cancellationToken);
314 OriginCommitSha = repoSha,
319 ActiveTestMerges =
new List<RevInfoTestMerge>(),
323 databaseContext.RevisionInformations.Add(revInfo);
324 databaseContext.Instances.Attach(revInfo.Instance);
325 await databaseContext.Save(cancellationToken);
335 Models.CompileJob? oldCompileJob;
338 var likelyPushedTestMergeCommit =
339 repositorySettings!.PushTestMergeCommits!.Value
340 && repositorySettings.AccessToken !=
null
341 && repositorySettings.AccessUser !=
null;
350 remoteDeploymentManager!,
353 likelyPushedTestMergeCommit,
360 async databaseContext =>
362 var fullJob = compileJob.Job;
363 compileJob.Job =
new Models.Job(job.Require(x => x.Id));
364 var fullRevInfo = compileJob.RevisionInformation;
370 databaseContext.Jobs.Attach(compileJob.Job);
371 databaseContext.RevisionInformations.Attach(compileJob.RevisionInformation);
372 databaseContext.CompileJobs.Add(compileJob);
375 await databaseContext.Save(cancellationToken);
376 logger.LogTrace(
"Created CompileJob {compileJobId}", compileJob.Id);
386 databaseContext.CompileJobs.Remove(compileJob);
389 await databaseContext.Save(CancellationToken.None);
393 compileJob.Job = fullJob;
394 compileJob.RevisionInformation = fullRevInfo;
443#pragma warning restore CA1506
453 throw new InvalidOperationException($
"{nameof(SetSessionControllerFactory)} called multiple times!");
464 var previousCompileJobs = await databaseContext
466 .Where(x => x.Job.Instance!.Id ==
metadata.Id)
467 .OrderByDescending(x => x.Job.StoppedAt)
471 StoppedAt = x.Job.StoppedAt!.Value,
472 StartedAt = x.Job.StartedAt!.Value,
474 .ToListAsync(cancellationToken);
476 TimeSpan? averageSpan =
null;
477 if (previousCompileJobs.Count != 0)
479 var totalSpan = TimeSpan.Zero;
480 foreach (var previousCompileJob
in previousCompileJobs)
481 totalSpan += previousCompileJob.StoppedAt - previousCompileJob.StartedAt;
482 averageSpan = totalSpan / previousCompileJobs.Count;
505 Models.CompileJob? oldCompileJob,
506 Models.RevisionInformation revisionInformation,
507 Api.Models.Internal.DreamMakerSettings dreamMakerSettings,
512 TimeSpan? estimatedDuration,
513 bool localCommitExistsOnRemote,
514 CancellationToken cancellationToken)
516 logger.LogTrace(
"Begin Compile");
518 using var progressCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
520 progressReporter.StageName =
"Reserving BYOND version";
521 var progressTask =
ProgressTask(progressReporter, estimatedDuration, progressCts.Token);
529 DateTimeOffset.UtcNow + estimatedDuration,
532 localCommitExistsOnRemote);
534 var compileJob =
new Models.CompileJob(job, revisionInformation, engineLock.Version.ToString())
536 DirectoryName = Guid.NewGuid(),
537 DmeName = dreamMakerSettings.ProjectName,
538 RepositoryOrigin = repository.
Origin.ToString(),
541 progressReporter.StageName =
"Creating remote deployment notification";
547 logger.LogTrace(
"Deployment will timeout at {timeoutTime}", DateTimeOffset.UtcNow + dreamMakerSettings.Timeout!.Value);
548 using var timeoutTokenSource =
new CancellationTokenSource(dreamMakerSettings.Timeout.Value);
549 var timeoutToken = timeoutTokenSource.Token;
550 using (timeoutToken.Register(() =>
logger.LogWarning(
"Deployment timed out!")))
552 using var combinedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(timeoutToken, cancellationToken);
562 remoteDeploymentManager,
563 combinedTokenSource.Token);
565 catch (OperationCanceledException) when (timeoutToken.IsCancellationRequested)
573 catch (OperationCanceledException)
576 progressReporter.StageName =
"Running CompileCancelled event";
582 progressCts.Cancel();
601 Models.CompileJob job,
602 Api.Models.Internal.DreamMakerSettings dreamMakerSettings,
607 CancellationToken cancellationToken)
609 var outputDirectory = job.DirectoryName!.Value.ToString();
610 logger.LogTrace(
"Compile output GUID: {dirGuid}", outputDirectory);
615 logger.LogTrace(
"Copying repository to game directory");
616 progressReporter.StageName =
"Copying repository";
618 var repoOrigin = repository.
Origin;
619 var repoReference = repository.
Reference;
621 await repository.
CopyTo(resolvedOutputDirectory, cancellationToken);
626 progressReporter.StageName =
"Running PreCompile event";
631 resolvedOutputDirectory,
632 repoOrigin.ToString(),
641 progressReporter.StageName =
"Determining .dme";
642 if (job.DmeName ==
null)
644 logger.LogTrace(
"Searching for available .dmes");
646 var foundPath = foundPaths.FirstOrDefault();
647 if (foundPath ==
default)
649 job.DmeName = foundPath.Substring(
650 resolvedOutputDirectory.Length + 1,
651 foundPath.Length - resolvedOutputDirectory.Length -
DmeExtension.Length - 2);
660 if (!targetDmeExists)
664 logger.LogDebug(
"Selected \"{dmeName}.dme\" for compilation!", job.DmeName);
666 progressReporter.StageName =
"Modifying .dme";
670 progressReporter.StageName =
"Running PreDreamMaker event";
675 resolvedOutputDirectory,
676 repoOrigin.ToString(),
677 engineLock.Version.ToString(),
684 progressReporter.StageName =
"Running Compiler";
685 var compileSuceeded = await
RunDreamMaker(engineLock, job, dreamMakerSettings.CompilerAdditionalArguments, cancellationToken);
688 var engineVersion = engineLock.
Version;
693 if (!compileSuceeded)
696 new JobException($
"Compilation failed:{Environment.NewLine}{Environment.NewLine}{job.Output}"));
700 dreamMakerSettings.ApiValidationSecurityLevel!.Value,
704 dreamMakerSettings.ApiValidationPort!.Value,
705 dreamMakerSettings.DMApiValidationMode!.Value,
712 progressReporter.StageName =
"Running CompileFailure event";
717 resolvedOutputDirectory,
718 compileSuceeded ?
"1" :
"0",
719 engineVersion.ToString(),
727 progressReporter.StageName =
"Running CompileComplete event";
732 resolvedOutputDirectory,
733 engineVersion.ToString(),
739 logger.LogTrace(
"Applying static game file symlinks...");
740 progressReporter.StageName =
"Symlinking GameStaticFiles";
743 await
configuration.SymlinkStaticFilesTo(resolvedOutputDirectory, cancellationToken);
745 logger.LogDebug(
"Compile complete!");
749 progressReporter.StageName =
"Cleaning output directory";
764 double? lastReport = estimatedDuration.HasValue ? 0 :
null;
767 var minimumSleepInterval = TimeSpan.FromMilliseconds(250);
768 var sleepInterval = estimatedDuration.HasValue ? estimatedDuration.Value / 100 : minimumSleepInterval;
770 if (estimatedDuration.HasValue)
772 logger.LogDebug(
"Compile is expected to take: {estimatedDuration}", estimatedDuration);
776 logger.LogTrace(
"No metric to estimate compile time.");
781 for (var iteration = 0; iteration < (estimatedDuration.HasValue ? 99 : Int32.MaxValue); ++iteration)
783 if (estimatedDuration.HasValue)
785 var nextInterval = DateTimeOffset.UtcNow + sleepInterval;
788 var remainingSleepThisInterval = nextInterval - DateTimeOffset.UtcNow;
789 var nextSleepSpan = remainingSleepThisInterval < minimumSleepInterval ? minimumSleepInterval : remainingSleepThisInterval;
791 await asyncDelayer.Delay(nextSleepSpan, cancellationToken);
794 while (DateTimeOffset.UtcNow < nextInterval);
797 await asyncDelayer.Delay(minimumSleepInterval, cancellationToken);
799 lastReport = estimatedDuration.HasValue ? sleepInterval * (iteration + 1) / estimatedDuration.Value :
null;
803 catch (OperationCanceledException ex)
805 logger.LogTrace(ex,
"ProgressTask aborted.");
809 logger.LogError(ex,
"ProgressTask crashed!");
829 Models.CompileJob job,
835 CancellationToken cancellationToken)
839 logger.LogDebug(
"Skipping DMAPI validation");
844 progressReporter.StageName =
"Validating DMAPI";
847 logger.LogTrace(
"Verifying {possiblyRequired}DMAPI...", requireValidate ?
"required " : String.Empty);
850 AllowWebClient =
false,
852 OpenDreamTopicPort = 0,
853 SecurityLevel = securityLevel,
855 StartupTimeout = timeout,
856 TopicRequestTimeout = 0,
857 HealthCheckSeconds = 0,
858 StartProfiler =
false,
859 LogOutput = logOutput,
863 job.MinimumSecurityLevel = securityLevel;
865 if (sessionControllerFactory ==
null)
866 throw new InvalidOperationException($
"{nameof(SetSessionControllerFactory)} was not called!");
870 ioManager.ResolvePath(job.DirectoryName!.Value.ToString()),
873 await
using (var controller = await sessionControllerFactory.
LaunchNew(provider, engineLock, launchParameters,
true, cancellationToken))
875 var launchResult = await controller.LaunchResult.WaitAsync(cancellationToken);
877 if (launchResult.StartupTime.HasValue)
878 await controller.Lifetime.WaitAsync(cancellationToken);
880 if (!controller.Lifetime.IsCompleted)
881 await controller.DisposeAsync();
883 validationStatus = controller.ApiValidationStatus;
885 logger.LogTrace(
"API validation status: {validationStatus}", validationStatus);
887 job.DMApiVersion = controller.DMApiVersion;
890 switch (validationStatus)
911 throw new InvalidOperationException(
912 $
"Session controller returned unexpected ApiValidationStatus: {validationStatus}");
926 Models.CompileJob job,
927 string? additionalCompilerArguments,
928 CancellationToken cancellationToken)
930 var environment = await engineLock.
LoadEnv(logger,
true, cancellationToken);
931 var arguments = engineLock.
FormatCompilerArguments($
"{job.DmeName}.{DmeExtension}", additionalCompilerArguments);
933 await
using var dm = await processExecutor.LaunchProcess(
935 ioManager.ResolvePath(
936 job.DirectoryName!.Value.ToString()),
940 readStandardHandles:
true,
941 noShellExecute:
true);
943 if (sessionConfigurationOptions.CurrentValue.LowPriorityDeploymentProcesses)
944 dm.AdjustPriority(
false);
947 using (cancellationToken.Register(() => dm.Terminate()))
948 exitCode = (await dm.Lifetime).Value;
949 cancellationToken.ThrowIfCancellationRequested();
951 logger.LogDebug(
"DreamMaker exit code: {exitCode}", exitCode);
952 job.Output = $
"{await dm.GetCombinedOutput(cancellationToken)}{Environment.NewLine}{Environment.NewLine}Exit Code: {exitCode}";
953 logger.LogDebug(
"DreamMaker output: {newLine}{output}", Environment.NewLine, job.Output);
955 currentDreamMakerOutput = job.Output;
956 return exitCode == 0;
965 async ValueTask
ModifyDme(Models.CompileJob job, CancellationToken cancellationToken)
967 var dmeFileName = String.Join(
'.', job.DmeName, DmeExtension);
968 var stringDirectoryName = job.DirectoryName!.Value.ToString();
969 var dmePath = ioManager.ConcatPath(stringDirectoryName, dmeFileName);
970 var dmeReadTask = ioManager.ReadAllBytes(dmePath, cancellationToken);
972 var dmeModificationsTask = configuration.CopyDMFilesTo(
974 ioManager.ResolvePath(
975 ioManager.ConcatPath(
977 ioManager.GetDirectoryName(dmeFileName))),
980 var dmeBytes = await dmeReadTask;
981 var dme = Encoding.UTF8.GetString(dmeBytes);
983 var dmeModifications = await dmeModificationsTask;
985 if (dmeModifications ==
null || dmeModifications.TotalDmeOverwrite)
987 if (dmeModifications !=
null)
988 logger.LogDebug(
".dme replacement configured!");
990 logger.LogTrace(
"No .dme modifications required.");
994 var dmeLines =
new List<string>(dme.Split(
'\n', StringSplitOptions.None));
995 for (var dmeLineIndex = 0; dmeLineIndex < dmeLines.Count; ++dmeLineIndex)
997 var line = dmeLines[dmeLineIndex];
998 if (line.Contains(
"BEGIN_INCLUDE", StringComparison.Ordinal) && dmeModifications.HeadIncludeLine !=
null)
1000 var headIncludeLineNumber = dmeLineIndex + 1;
1002 "Inserting HeadInclude.dm at line {lineNumber}: {includeLine}",
1003 headIncludeLineNumber,
1004 dmeModifications.HeadIncludeLine);
1005 dmeLines.Insert(headIncludeLineNumber, dmeModifications.HeadIncludeLine);
1008 else if (line.Contains(
"END_INCLUDE", StringComparison.Ordinal) && dmeModifications.TailIncludeLine !=
null)
1011 "Inserting TailInclude.dm at line {lineNumber}: {includeLine}",
1013 dmeModifications.TailIncludeLine);
1014 dmeLines.Insert(dmeLineIndex, dmeModifications.TailIncludeLine);
1019 dmeBytes = Encoding.UTF8.GetBytes(String.Join(
'\n', dmeLines));
1020 await ioManager.WriteAllBytes(dmePath, dmeBytes, cancellationToken);
1032 async ValueTask CleanDir()
1034 if (sessionConfigurationOptions.CurrentValue.DelayCleaningFailedDeployments)
1036 logger.LogDebug(
"Not cleaning up errored deployment directory {guid} due to config.", job.DirectoryName);
1040 logger.LogTrace(
"Cleaning compile directory...");
1041 var jobPath = job.DirectoryName!.Value.ToString();
1045 await eventConsumer.HandleEvent(
EventType.DeploymentCleanup,
new List<string> { jobPath },
false,
true, CancellationToken.None);
1046 await ioManager.DeleteDirectory(jobPath, CancellationToken.None);
1050 logger.LogWarning(e,
"Error cleaning up compile directory {path}!", ioManager.ResolvePath(jobPath));
1054 var dirCleanTask = CleanDir();
1056 var failRemoteDeployTask = remoteDeploymentManager.
FailDeployment(
1058 FormatExceptionForUsers(exception),
1059 CancellationToken.None);
1063 failRemoteDeployTask);
override string ToString()
Metadata about a server instance.
Launch settings for DreamDaemon.
bool? LogOutput
If process output/error text should be logged.
uint? StartupTimeout
The DreamDaemon startup timeout in seconds.
Extension methods for the ValueTask and ValueTask<TResult> classes.
static async ValueTask WhenAll(IEnumerable< ValueTask > tasks)
Fully await a given list of tasks .
DreamMaker(IEngineManager engineManager, IIOManager ioManager, StaticFiles.IConfiguration configuration, IEventConsumer eventConsumer, IChatManager chatManager, IProcessExecutor processExecutor, ICompileJobSink compileJobConsumer, IRepositoryManager repositoryManager, IRemoteDeploymentManagerFactory remoteDeploymentManagerFactory, IAsyncDelayer asyncDelayer, IMetricFactory metricFactory, IOptionsMonitor< SessionConfiguration > sessionConfigurationOptions, ILogger< DreamMaker > logger, Api.Models.Instance metadata)
Initializes a new instance of the DreamMaker class.
Func< string?, string, Action< bool > >? currentChatCallback
The active callback from IChatManager.QueueDeploymentMessage.
async ValueTask< Models.CompileJob > Compile(Models.Job job, Models.CompileJob? oldCompileJob, Models.RevisionInformation revisionInformation, Api.Models.Internal.DreamMakerSettings dreamMakerSettings, DreamDaemonLaunchParameters launchParameters, IRepository repository, IRemoteDeploymentManager remoteDeploymentManager, JobProgressReporter progressReporter, TimeSpan? estimatedDuration, bool localCommitExistsOnRemote, CancellationToken cancellationToken)
Run the compile implementation.
readonly IRepositoryManager repositoryManager
The IRepositoryManager for DreamMaker.
ValueTask CleanupFailedCompile(Models.CompileJob job, IRemoteDeploymentManager remoteDeploymentManager, Exception exception)
Cleans up a failed compile job .
async ValueTask ProgressTask(JobProgressReporter progressReporter, TimeSpan? estimatedDuration, CancellationToken cancellationToken)
Gradually triggers a given progressReporter over a given estimatedDuration .
async ValueTask VerifyApi(uint timeout, DreamDaemonSecurity securityLevel, Models.CompileJob job, JobProgressReporter progressReporter, IEngineExecutableLock engineLock, ushort portToUse, DMApiValidationMode validationMode, bool logOutput, CancellationToken cancellationToken)
Run a quick DD instance to test the DMAPI is installed on the target code.
readonly ILogger< DreamMaker > logger
The ILogger for DreamMaker.
async ValueTask RunCompileJob(JobProgressReporter progressReporter, Models.CompileJob job, Api.Models.Internal.DreamMakerSettings dreamMakerSettings, DreamDaemonLaunchParameters launchParameters, IEngineExecutableLock engineLock, IRepository repository, IRemoteDeploymentManager remoteDeploymentManager, CancellationToken cancellationToken)
Executes and populate a given job .
readonly StaticFiles.IConfiguration configuration
The StaticFiles.IConfiguration for DreamMaker.
const string DmeExtension
Extension for .dmes.
async ValueTask DeploymentProcess(Models.Job job, IDatabaseContextFactory databaseContextFactory, JobProgressReporter progressReporter, CancellationToken cancellationToken)
Create and a compile job and insert it into the database. Meant to be called by a IJobManager....
string? currentDreamMakerOutput
Cached for currentChatCallback.
async ValueTask< TimeSpan?> CalculateExpectedDeploymentTime(IDatabaseContext databaseContext, CancellationToken cancellationToken)
Calculate the average length of a deployment using a given databaseContext .
readonly IIOManager ioManager
The IIOManager for DreamMaker.
readonly IRemoteDeploymentManagerFactory remoteDeploymentManagerFactory
The IRemoteDeploymentManagerFactory for DreamMaker.
readonly Counter successfulDeployments
The number of successful deployments.
readonly Counter attemptedDeployments
The number of attempted deployments.
readonly Counter failedDeployments
The number of failed deployments.
static string FormatExceptionForUsers(Exception exception)
Format a given Exception for display to users.
readonly IProcessExecutor processExecutor
The IProcessExecutor for DreamMaker.
void SetSessionControllerFactory(ISessionControllerFactory sessionControllerFactory)
Set the sessionControllerFactory for the DreamMaker. Must be called exactly once after construction b...
bool deploying
If a compile job is running.
readonly IEngineManager engineManager
The IEngineManager for DreamMaker.
readonly ICompileJobSink compileJobConsumer
The ICompileJobSink for DreamMaker.
readonly IEventConsumer eventConsumer
The IEventConsumer for DreamMaker.
readonly Api.Models.Instance metadata
The Instance DreamMaker belongs to.
ISessionControllerFactory? sessionControllerFactory
The ISessionControllerFactory for DreamMaker.
async ValueTask ModifyDme(Models.CompileJob job, CancellationToken cancellationToken)
Adds server side includes to the .dme being compiled.
readonly IOptionsMonitor< SessionConfiguration > sessionConfigurationOptions
The IOptionsMonitor<TOptions> of SessionConfiguration for DreamMaker.
readonly IChatManager chatManager
The IChatManager for DreamMaker.
async ValueTask< bool > RunDreamMaker(IEngineExecutableLock engineLock, Models.CompileJob job, string? additionalCompilerArguments, CancellationToken cancellationToken)
Compiles a .dme with DreamMaker.
readonly object deploymentLock
lock object for deploying.
readonly IAsyncDelayer asyncDelayer
The IAsyncDelayer for DreamMaker.
Repository(LibGit2Sharp.IRepository libGitRepo, ILibGit2Commands commands, IIOManager ioManager, IEventConsumer eventConsumer, ICredentialsProvider credentialsProvider, IPostWriteHandler postWriteHandler, IGitRemoteFeaturesFactory gitRemoteFeaturesFactory, ILibGit2RepositoryFactory submoduleFactory, IOptionsMonitor< GeneralConfiguration > generalConfigurationOptions, ILogger< Repository > logger, Action disposeAction)
Initializes a new instance of the Repository class.
Operation exceptions thrown from the context of a Models.Job.
Progress reporter for a Job.
void ReportProgress(double? progress)
Report progress.
Represents an Api.Models.Instance in the database.
For managing connected chat services.
Func< string?, string, Action< bool > > QueueDeploymentMessage(Models.RevisionInformation revisionInformation, Models.RevisionInformation? previousRevisionInformation, Api.Models.EngineVersion engineVersion, DateTimeOffset? estimatedCompletionTime, string? gitHubOwner, string? gitHubRepo, bool localCommitPushed)
Send the message for a deployment to configured deployment channels.
ValueTask LoadCompileJob(CompileJob job, Action< bool >? activationAction, CancellationToken cancellationToken)
Load a new job into the ICompileJobSink.
For managing the compiler.
ValueTask< CompileJob?> LatestCompileJob()
Gets the latest CompileJob.
Factory for creating IRemoteDeploymentManagers.
IRemoteDeploymentManager CreateRemoteDeploymentManager(Api.Models.Instance metadata, RemoteGitProvider remoteGitProvider)
Creates a IRemoteDeploymentManager for a given remoteGitProvider .
Creates and updates remote deployments.
ValueTask PostDeploymentComments(CompileJob compileJob, RevisionInformation? previousRevisionInformation, RepositorySettings repositorySettings, string? repoOwner, string? repoName, CancellationToken cancellationToken)
Post deployment comments to the test merge ticket.
ValueTask StartDeployment(Api.Models.Internal.IGitRemoteInformation remoteInformation, CompileJob compileJob, CancellationToken cancellationToken)
Start a deployment for a given compileJob .
ValueTask FailDeployment(CompileJob compileJob, string errorMessage, CancellationToken cancellationToken)
Fail a deployment for a given compileJob .
Represents usage of the two primary BYOND server executables.
string FormatCompilerArguments(string dmePath, string? additionalArguments)
Return the command line arguments for compiling a given dmePath if compilation is necessary.
ValueTask< Dictionary< string, string >?> LoadEnv(ILogger logger, bool forCompiler, CancellationToken cancellationToken)
Loads the environment settings for either the server or compiler.
EngineVersion Version
The EngineVersion of the IEngineInstallation.
string CompilerExePath
The full path to the dm/DreamMaker executable.
For managing the engine installations.
ValueTask< IEngineExecutableLock > UseExecutables(EngineVersion? requiredVersion, string? trustDmbFullPath, CancellationToken cancellationToken)
Lock the current installation's location and return a IEngineExecutableLock.
Consumes EventTypes and takes the appropriate actions.
ValueTask HandleEvent(EventType eventType, IEnumerable< string?> parameters, bool sensitiveParameters, bool deploymentPipeline, CancellationToken cancellationToken)
Handle a given eventType .
Represents an on-disk git repository.
Task< DateTimeOffset > TimestampCommit(string sha, CancellationToken cancellationToken)
Gets the DateTimeOffset a given sha was created on.
string Reference
The current reference the IRepository HEAD is using. This can be a branch or tag.
ValueTask CopyTo(string path, CancellationToken cancellationToken)
Copies the current working directory to a given path .
string Head
The SHA of the IRepository HEAD.
Uri Origin
The current origin remote the IRepository is using.
Factory for creating and loading IRepositorys.
ValueTask< IRepository?> LoadRepository(CancellationToken cancellationToken)
Attempt to load the IRepository from the default location.
Factory for ISessionControllers.
ValueTask< ISessionController > LaunchNew(IDmbProvider dmbProvider, IEngineExecutableLock? currentByondLock, DreamDaemonLaunchParameters launchParameters, bool apiValidate, CancellationToken cancellationToken)
Create a ISessionController from a freshly launch DreamDaemon instance.
For managing the Configuration directory.
Factory for scoping usage of IDatabaseContexts. Meant for use by Components.
ValueTask UseContext(Func< IDatabaseContext, ValueTask > operation)
Run an operation in the scope of an IDatabaseContext.
IDatabaseCollection< CompileJob > CompileJobs
The CompileJobs in the IDatabaseContext.
Interface for using filesystems.
Task< bool > PathIsChildOf(string parentPath, string childPath, CancellationToken cancellationToken)
Check if a given parentPath is a parent of a given parentPath .
string ResolvePath()
Retrieve the full path of the current working directory.
string ConcatPath(params string[] paths)
Combines an array of strings into a path.
Task< bool > FileExists(string path, CancellationToken cancellationToken)
Check that the file at path exists.
Task< List< string > > GetFilesWithExtension(string path, string extension, bool recursive, CancellationToken cancellationToken)
Gets a list of files in path with the given extension .
For waiting asynchronously.
ErrorCode
Types of Response.ErrorMessageResponses that the API may return.
DreamDaemonVisibility
The visibility setting for DreamDaemon.
DreamDaemonSecurity
DreamDaemon's security level.
DMApiValidationMode
The DMAPI validation setting for deployments.
EventType
Types of events. Mirror in tgs.dm. Prefer last listed name for script.
ApiValidationStatus
Status of DMAPI validation.