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!"
188 IMetricFactory metricFactory,
190 ILogger<DreamMaker>
logger,
204 ArgumentNullException.ThrowIfNull(metricFactory);
206 this.logger =
logger ??
throw new ArgumentNullException(nameof(
logger));
207 this.metadata =
metadata ??
throw new ArgumentNullException(nameof(
metadata));
209 successfulDeployments = metricFactory.CreateCounter(
"tgs_successful_deployments",
"The number of deployments that have completed successfully");
210 failedDeployments = metricFactory.CreateCounter(
"tgs_failed_deployments",
"The number of deployments that have failed");
211 attemptedDeployments = metricFactory.CreateCounter(
"tgs_total_deployments",
"The number of deployments that have been attempted");
217#pragma warning disable CA1506
222 CancellationToken cancellationToken)
224 ArgumentNullException.ThrowIfNull(job);
225 ArgumentNullException.ThrowIfNull(databaseContextFactory);
226 ArgumentNullException.ThrowIfNull(progressReporter);
239 Models.CompileJob? compileJob =
null;
240 bool success =
false;
243 string? repoOwner =
null;
244 string? repoName =
null;
245 TimeSpan? averageSpan =
null;
246 Models.RepositorySettings? repositorySettings =
null;
247 Models.DreamDaemonSettings? ddSettings =
null;
248 Models.DreamMakerSettings? dreamMakerSettings =
null;
251 Models.RevisionInformation? revInfo =
null;
253 async databaseContext =>
257 ddSettings = await databaseContext
259 .Where(x => x.InstanceId ==
metadata.Id)
260 .Select(x =>
new Models.DreamDaemonSettings
262 StartupTimeout = x.StartupTimeout,
263 LogOutput = x.LogOutput,
265 .FirstOrDefaultAsync(cancellationToken);
266 if (ddSettings ==
default)
269 dreamMakerSettings = await databaseContext
271 .Where(x => x.InstanceId ==
metadata.Id)
272 .FirstAsync(cancellationToken);
273 if (dreamMakerSettings ==
default)
276 repositorySettings = await databaseContext
278 .Where(x => x.InstanceId ==
metadata.Id)
279 .Select(x =>
new Models.RepositorySettings
281 AccessToken = x.AccessToken,
282 AccessUser = x.AccessUser,
283 ShowTestMergeCommitters = x.ShowTestMergeCommitters,
284 PushTestMergeCommits = x.PushTestMergeCommits,
285 PostTestMergeComment = x.PostTestMergeComment,
287 .FirstOrDefaultAsync(cancellationToken);
288 if (repositorySettings ==
default)
300 var repoSha = repo.
Head;
303 revInfo = await databaseContext
304 .RevisionInformations
305 .Where(x => x.CommitSha == repoSha && x.InstanceId ==
metadata.Id)
306 .Include(x => x.ActiveTestMerges!)
307 .ThenInclude(x => x.TestMerge!)
308 .ThenInclude(x => x.MergedBy)
309 .FirstOrDefaultAsync(cancellationToken);
317 OriginCommitSha = repoSha,
322 ActiveTestMerges =
new List<RevInfoTestMerge>(),
326 databaseContext.RevisionInformations.Add(revInfo);
327 databaseContext.Instances.Attach(revInfo.Instance);
328 await databaseContext.Save(cancellationToken);
338 Models.CompileJob? oldCompileJob;
341 var likelyPushedTestMergeCommit =
342 repositorySettings!.PushTestMergeCommits!.Value
343 && repositorySettings.AccessToken !=
null
344 && repositorySettings.AccessUser !=
null;
353 remoteDeploymentManager!,
356 likelyPushedTestMergeCommit,
363 async databaseContext =>
365 var fullJob = compileJob.Job;
366 compileJob.Job =
new Models.Job(job.Require(x => x.Id));
367 var fullRevInfo = compileJob.RevisionInformation;
373 databaseContext.Jobs.Attach(compileJob.Job);
374 databaseContext.RevisionInformations.Attach(compileJob.RevisionInformation);
375 databaseContext.CompileJobs.Add(compileJob);
378 await databaseContext.Save(cancellationToken);
379 logger.LogTrace(
"Created CompileJob {compileJobId}", compileJob.Id);
389 databaseContext.CompileJobs.Remove(compileJob);
392 await databaseContext.Save(CancellationToken.None);
396 compileJob.Job = fullJob;
397 compileJob.RevisionInformation = fullRevInfo;
446#pragma warning restore CA1506
456 var previousCompileJobs = await databaseContext
458 .Where(x => x.Job.Instance!.Id ==
metadata.Id)
459 .OrderByDescending(x => x.Job.StoppedAt)
463 StoppedAt = x.Job.StoppedAt!.Value,
464 StartedAt = x.Job.StartedAt!.Value,
466 .ToListAsync(cancellationToken);
468 TimeSpan? averageSpan =
null;
469 if (previousCompileJobs.Count != 0)
471 var totalSpan = TimeSpan.Zero;
472 foreach (var previousCompileJob
in previousCompileJobs)
473 totalSpan += previousCompileJob.StoppedAt - previousCompileJob.StartedAt;
474 averageSpan = totalSpan / previousCompileJobs.Count;
497 Models.CompileJob? oldCompileJob,
498 Models.RevisionInformation revisionInformation,
499 Api.Models.Internal.DreamMakerSettings dreamMakerSettings,
504 TimeSpan? estimatedDuration,
505 bool localCommitExistsOnRemote,
506 CancellationToken cancellationToken)
508 logger.LogTrace(
"Begin Compile");
510 using var progressCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
512 progressReporter.StageName =
"Reserving BYOND version";
513 var progressTask =
ProgressTask(progressReporter, estimatedDuration, progressCts.Token);
521 DateTimeOffset.UtcNow + estimatedDuration,
524 localCommitExistsOnRemote);
526 var compileJob =
new Models.CompileJob(job, revisionInformation, engineLock.Version.ToString())
528 DirectoryName = Guid.NewGuid(),
529 DmeName = dreamMakerSettings.ProjectName,
530 RepositoryOrigin = repository.
Origin.ToString(),
533 progressReporter.StageName =
"Creating remote deployment notification";
539 logger.LogTrace(
"Deployment will timeout at {timeoutTime}", DateTimeOffset.UtcNow + dreamMakerSettings.Timeout!.Value);
540 using var timeoutTokenSource =
new CancellationTokenSource(dreamMakerSettings.Timeout.Value);
541 var timeoutToken = timeoutTokenSource.Token;
542 using (timeoutToken.Register(() =>
logger.LogWarning(
"Deployment timed out!")))
544 using var combinedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(timeoutToken, cancellationToken);
554 remoteDeploymentManager,
555 combinedTokenSource.Token);
557 catch (OperationCanceledException) when (timeoutToken.IsCancellationRequested)
565 catch (OperationCanceledException)
568 progressReporter.StageName =
"Running CompileCancelled event";
574 progressCts.Cancel();
593 Models.CompileJob job,
594 Api.Models.Internal.DreamMakerSettings dreamMakerSettings,
599 CancellationToken cancellationToken)
601 var outputDirectory = job.DirectoryName!.Value.ToString();
602 logger.LogTrace(
"Compile output GUID: {dirGuid}", outputDirectory);
607 logger.LogTrace(
"Copying repository to game directory");
608 progressReporter.StageName =
"Copying repository";
610 var repoOrigin = repository.
Origin;
611 var repoReference = repository.
Reference;
613 await repository.
CopyTo(resolvedOutputDirectory, cancellationToken);
618 progressReporter.StageName =
"Running PreCompile event";
623 resolvedOutputDirectory,
624 repoOrigin.ToString(),
632 progressReporter.StageName =
"Determining .dme";
633 if (job.DmeName ==
null)
635 logger.LogTrace(
"Searching for available .dmes");
637 var foundPath = foundPaths.FirstOrDefault();
638 if (foundPath ==
default)
640 job.DmeName = foundPath.Substring(
641 resolvedOutputDirectory.Length + 1,
642 foundPath.Length - resolvedOutputDirectory.Length -
DmeExtension.Length - 2);
651 if (!targetDmeExists)
655 logger.LogDebug(
"Selected \"{dmeName}.dme\" for compilation!", job.DmeName);
657 progressReporter.StageName =
"Modifying .dme";
661 progressReporter.StageName =
"Running PreDreamMaker event";
666 resolvedOutputDirectory,
667 repoOrigin.ToString(),
668 engineLock.Version.ToString(),
674 progressReporter.StageName =
"Running Compiler";
675 var compileSuceeded = await
RunDreamMaker(engineLock, job, dreamMakerSettings.CompilerAdditionalArguments, cancellationToken);
678 var engineVersion = engineLock.
Version;
683 if (!compileSuceeded)
686 new JobException($
"Compilation failed:{Environment.NewLine}{Environment.NewLine}{job.Output}"));
690 dreamMakerSettings.ApiValidationSecurityLevel!.Value,
694 dreamMakerSettings.ApiValidationPort!.Value,
695 dreamMakerSettings.DMApiValidationMode!.Value,
702 progressReporter.StageName =
"Running CompileFailure event";
707 resolvedOutputDirectory,
708 compileSuceeded ?
"1" :
"0",
709 engineVersion.ToString(),
716 progressReporter.StageName =
"Running CompileComplete event";
721 resolvedOutputDirectory,
722 engineVersion.ToString(),
727 logger.LogTrace(
"Applying static game file symlinks...");
728 progressReporter.StageName =
"Symlinking GameStaticFiles";
731 await
configuration.SymlinkStaticFilesTo(resolvedOutputDirectory, cancellationToken);
733 logger.LogDebug(
"Compile complete!");
737 progressReporter.StageName =
"Cleaning output directory";
752 double? lastReport = estimatedDuration.HasValue ? 0 :
null;
755 var minimumSleepInterval = TimeSpan.FromMilliseconds(250);
756 var sleepInterval = estimatedDuration.HasValue ? estimatedDuration.Value / 100 : minimumSleepInterval;
758 if (estimatedDuration.HasValue)
760 logger.LogDebug(
"Compile is expected to take: {estimatedDuration}", estimatedDuration);
764 logger.LogTrace(
"No metric to estimate compile time.");
769 for (var iteration = 0; iteration < (estimatedDuration.HasValue ? 99 : Int32.MaxValue); ++iteration)
771 if (estimatedDuration.HasValue)
773 var nextInterval = DateTimeOffset.UtcNow + sleepInterval;
776 var remainingSleepThisInterval = nextInterval - DateTimeOffset.UtcNow;
777 var nextSleepSpan = remainingSleepThisInterval < minimumSleepInterval ? minimumSleepInterval : remainingSleepThisInterval;
779 await asyncDelayer.Delay(nextSleepSpan, cancellationToken);
782 while (DateTimeOffset.UtcNow < nextInterval);
785 await asyncDelayer.Delay(minimumSleepInterval, cancellationToken);
787 lastReport = estimatedDuration.HasValue ? sleepInterval * (iteration + 1) / estimatedDuration.Value :
null;
791 catch (OperationCanceledException ex)
793 logger.LogTrace(ex,
"ProgressTask aborted.");
797 logger.LogError(ex,
"ProgressTask crashed!");
817 Models.CompileJob job,
823 CancellationToken cancellationToken)
827 logger.LogDebug(
"Skipping DMAPI validation");
832 progressReporter.StageName =
"Validating DMAPI";
835 logger.LogTrace(
"Verifying {possiblyRequired}DMAPI...", requireValidate ?
"required " : String.Empty);
838 AllowWebClient =
false,
840 OpenDreamTopicPort = 0,
841 SecurityLevel = securityLevel,
843 StartupTimeout = timeout,
844 TopicRequestTimeout = 0,
845 HealthCheckSeconds = 0,
846 StartProfiler =
false,
847 LogOutput = logOutput,
851 job.MinimumSecurityLevel = securityLevel;
855 ioManager.ResolvePath(job.DirectoryName!.Value.ToString()),
858 await
using (var controller = await sessionControllerFactory.LaunchNew(provider, engineLock, launchParameters,
true, cancellationToken))
860 var launchResult = await controller.LaunchResult.WaitAsync(cancellationToken);
862 if (launchResult.StartupTime.HasValue)
863 await controller.Lifetime.WaitAsync(cancellationToken);
865 if (!controller.Lifetime.IsCompleted)
866 await controller.DisposeAsync();
868 validationStatus = controller.ApiValidationStatus;
870 logger.LogTrace(
"API validation status: {validationStatus}", validationStatus);
872 job.DMApiVersion = controller.DMApiVersion;
875 switch (validationStatus)
896 throw new InvalidOperationException(
897 $
"Session controller returned unexpected ApiValidationStatus: {validationStatus}");
911 Models.CompileJob job,
912 string? additionalCompilerArguments,
913 CancellationToken cancellationToken)
915 var environment = await engineLock.
LoadEnv(logger,
true, cancellationToken);
916 var arguments = engineLock.
FormatCompilerArguments($
"{job.DmeName}.{DmeExtension}", additionalCompilerArguments);
918 await
using var dm = await processExecutor.LaunchProcess(
920 ioManager.ResolvePath(
921 job.DirectoryName!.Value.ToString()),
925 readStandardHandles:
true,
926 noShellExecute:
true);
928 if (sessionConfigurationOptions.CurrentValue.LowPriorityDeploymentProcesses)
929 dm.AdjustPriority(
false);
932 using (cancellationToken.Register(() => dm.Terminate()))
933 exitCode = (await dm.Lifetime).Value;
934 cancellationToken.ThrowIfCancellationRequested();
936 logger.LogDebug(
"DreamMaker exit code: {exitCode}", exitCode);
937 job.Output = $
"{await dm.GetCombinedOutput(cancellationToken)}{Environment.NewLine}{Environment.NewLine}Exit Code: {exitCode}";
938 logger.LogDebug(
"DreamMaker output: {newLine}{output}", Environment.NewLine, job.Output);
940 currentDreamMakerOutput = job.Output;
941 return exitCode == 0;
950 async ValueTask
ModifyDme(Models.CompileJob job, CancellationToken cancellationToken)
952 var dmeFileName = String.Join(
'.', job.DmeName, DmeExtension);
953 var stringDirectoryName = job.DirectoryName!.Value.ToString();
954 var dmePath = ioManager.ConcatPath(stringDirectoryName, dmeFileName);
955 var dmeReadTask = ioManager.ReadAllBytes(dmePath, cancellationToken);
957 var dmeModificationsTask = configuration.CopyDMFilesTo(
959 ioManager.ResolvePath(
960 ioManager.ConcatPath(
962 ioManager.GetDirectoryName(dmeFileName))),
965 var dmeBytes = await dmeReadTask;
966 var dme = Encoding.UTF8.GetString(dmeBytes);
968 var dmeModifications = await dmeModificationsTask;
970 if (dmeModifications ==
null || dmeModifications.TotalDmeOverwrite)
972 if (dmeModifications !=
null)
973 logger.LogDebug(
".dme replacement configured!");
975 logger.LogTrace(
"No .dme modifications required.");
979 var dmeLines =
new List<string>(dme.Split(
'\n', StringSplitOptions.None));
980 for (var dmeLineIndex = 0; dmeLineIndex < dmeLines.Count; ++dmeLineIndex)
982 var line = dmeLines[dmeLineIndex];
983 if (line.Contains(
"BEGIN_INCLUDE", StringComparison.Ordinal) && dmeModifications.HeadIncludeLine !=
null)
985 var headIncludeLineNumber = dmeLineIndex + 1;
987 "Inserting HeadInclude.dm at line {lineNumber}: {includeLine}",
988 headIncludeLineNumber,
989 dmeModifications.HeadIncludeLine);
990 dmeLines.Insert(headIncludeLineNumber, dmeModifications.HeadIncludeLine);
993 else if (line.Contains(
"END_INCLUDE", StringComparison.Ordinal) && dmeModifications.TailIncludeLine !=
null)
996 "Inserting TailInclude.dm at line {lineNumber}: {includeLine}",
998 dmeModifications.TailIncludeLine);
999 dmeLines.Insert(dmeLineIndex, dmeModifications.TailIncludeLine);
1004 dmeBytes = Encoding.UTF8.GetBytes(String.Join(
'\n', dmeLines));
1005 await ioManager.WriteAllBytes(dmePath, dmeBytes, cancellationToken);
1017 async ValueTask CleanDir()
1019 if (sessionConfigurationOptions.CurrentValue.DelayCleaningFailedDeployments)
1021 logger.LogDebug(
"Not cleaning up errored deployment directory {guid} due to config.", job.DirectoryName);
1025 logger.LogTrace(
"Cleaning compile directory...");
1026 var jobPath = job.DirectoryName!.Value.ToString();
1030 await eventConsumer.HandleEvent(
EventType.DeploymentCleanup,
new List<string> { jobPath },
true, CancellationToken.None);
1031 await ioManager.DeleteDirectory(jobPath, CancellationToken.None);
1035 logger.LogWarning(e,
"Error cleaning up compile directory {path}!", ioManager.ResolvePath(jobPath));
1039 var dirCleanTask = CleanDir();
1041 var failRemoteDeployTask = remoteDeploymentManager.
FailDeployment(
1043 FormatExceptionForUsers(exception),
1044 CancellationToken.None);
1048 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 .
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 ISessionControllerFactory sessionControllerFactory
The ISessionControllerFactory for DreamMaker.
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.
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.
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.
DreamMaker(IEngineManager engineManager, IIOManager ioManager, StaticFiles.IConfiguration configuration, ISessionControllerFactory sessionControllerFactory, 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.
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 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.
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.