protected override ExtendedRichDescription GetDescription(IOperationConfiguration config) { return(new ExtendedRichDescription( new RichDescription( "Upload ", new MaskHilite(config[nameof(this.Includes)], config[nameof(this.Excludes)]), " to S3" ), new RichDescription( "from ", new DirectoryHilite(config[nameof(this.SourceDirectory)]), " to ", new Hilite(config[nameof(this.BucketName)] + AH.ConcatNE("/", config[nameof(this.KeyPrefix)])) ) )); }
public override async Task ExecuteAsync(IOperationExecutionContext context) { var startInfo = new RemoteProcessStartInfo { FileName = this.PythonExePath, Arguments = "-m pip install --progress-bar=off --no-color", WorkingDirectory = context.WorkingDirectory }; if (this.InstallFromRequirements) { startInfo.Arguments += " -r requirements.txt"; } startInfo.Arguments += AH.ConcatNE(" ", this.AdditionalArguments); await this.WrapInVirtualEnv(context, startInfo); await this.ExecuteCommandLineAsync(context, startInfo); }
protected async Task <(List <(bool error, string line)> output, int exitCode)> ExecutePHPAsync(IOperationExecutionContext context, string args) { var output = new List <(bool error, string line)>(); var procExec = await context.Agent.GetServiceAsync <IRemoteProcessExecuter>(); using (var proc = procExec.CreateProcess(new RemoteProcessStartInfo { FileName = await this.GetPHPExePathAsync(context), Arguments = args + AH.ConcatNE(" ", this.AdditionalArgs), WorkingDirectory = context.WorkingDirectory })) { proc.OutputDataReceived += (s, e) => output.Add((false, e.Data)); proc.ErrorDataReceived += (s, e) => output.Add((true, e.Data)); proc.Start(); await proc.WaitAsync(context.CancellationToken); return(output, proc.ExitCode ?? -1); } }
public override async Task ExecuteAsync(IOperationExecutionContext context) { var startInfo = new RemoteProcessStartInfo { FileName = this.PythonExePath, Arguments = "-m pip list --local --not-required --format=json", WorkingDirectory = context.WorkingDirectory }; startInfo.Arguments += AH.ConcatNE(" ", this.AdditionalArguments); await this.WrapInVirtualEnv(context, startInfo); var procExec = await context.Agent.GetServiceAsync <IRemoteProcessExecuter>(); var output = new StringBuilder(); using (var process = procExec.CreateProcess(startInfo)) { process.OutputDataReceived += (s, e) => output.Append(e.Data); process.ErrorDataReceived += (s, e) => this.LogWarning(e.Data); await process.WaitAsync(context.CancellationToken); if (process.ExitCode != 0) { this.LogError($"Process exited with code {process.ExitCode}"); return; } } var installedPackages = JsonConvert.DeserializeAnonymousType(output.ToString(), new[] { new { name = string.Empty, version = string.Empty } }); this.LogInformation("Installed packages:"); foreach (var package in installedPackages) { this.LogInformation($"{package.name} v{package.version}"); } }
public override async Task ExecuteAsync(IOperationExecutionContext context) { var client = new GitHubClient(this.ApiUrl, this.UserName, this.Password, this.OrganizationName); var url = $"{SDK.BaseUrl.TrimEnd('/')}/executions/execution-in-progress?executionId={context.ExecutionId}"; var statusContext = "ci/" + SDK.ProductName.ToLower() + AH.ConcatNE("/", this.AdditionalContext); if (this.Status == StatusType.auto) { switch (context.ExecutionStatus) { case ExecutionStatus.Normal: this.Status = StatusType.success; this.Description = this.NormalDescription; break; case ExecutionStatus.Warning: this.Status = StatusType.success; this.Description = this.WarningDescription; break; case ExecutionStatus.Error: this.Status = StatusType.failure; this.Description = this.ErrorDescription; break; case ExecutionStatus.Fault: default: this.Status = StatusType.error; this.Description = this.ErrorDescription; break; } } this.LogInformation($"Assigning '{this.Status}' status to the commit on GitHub..."); await client.CreateStatusAsync(AH.CoalesceString(this.OrganizationName, this.UserName), this.RepositoryName, this.CommitHash, this.Status.ToString(), url, this.Description, statusContext, context.CancellationToken).ConfigureAwait(false); }
private void ResetForm() { this.TypeSelect = new SelectList( from rt in Internals.RaftTypes select new SelectListItem( rt.name + AH.ConcatNE(" - ", rt.description), rt.type.FullName + "," + rt.type.Assembly.GetName().Name, this.RaftType == rt.type, rt.extension?.Name ) ) { Attributes = { ["name"] = "raft-type" }, AutoPostBack = true }; this.Form.Controls.Clear(); this.Form.Controls.Add(new SlimFormField("Raft Name:", this.RaftName)); this.Form.Controls.Add(new SlimFormField("Raft Type:", this.TypeSelect)); if (this.RaftEditor != null) { this.Form.Controls.Add(this.RaftEditor.EditorControl); } }
public override async Task ConfigureAsync(IOperationExecutionContext context) { var github = new GitHubClient(this.Template.ApiUrl, this.Template.UserName, this.Template.Password, this.Template.OrganizationName); var number = await github.CreateMilestoneAsync(this.Template.Title, AH.CoalesceString(this.Template.OrganizationName, this.Template.UserName), this.Template.RepositoryName, context.CancellationToken).ConfigureAwait(false); var data = new Dictionary <string, object> { ["title"] = this.Template.Title }; if (this.Template.DueDate != null) { data.Add("due_on", AH.NullIf(AH.ConcatNE(this.Template.DueDate, "T", DateTime.UtcNow.ToString("HH:mm:ss"), "Z"), string.Empty)); } if (this.Template.Description != null) { data.Add("description", this.Template.Description); } if (this.Template.State.HasValue) { data.Add("state", this.Template.State.ToString()); } await github.UpdateMilestoneAsync(number, AH.CoalesceString(this.Template.OrganizationName, this.Template.UserName), this.Template.RepositoryName, data, context.CancellationToken).ConfigureAwait(false); }
private async Task <ChocolateyInstalledConfiguration> CollectAsync(IOperationExecutionContext context) { if (this.Collected == null) { var output = await this.ExecuteChocolateyAsync(context, "upgrade --what-if --limit-output " + AH.ConcatNE("--source \"", this.Template.Source, "\" ") + "chocolatey", true); if (output == null) { this.Collected = new ChocolateyInstalledConfiguration { Version = "not-installed" }; } else { this.Collected = new ChocolateyInstalledConfiguration { Version = output[0][1], LatestVersion = output[0][2] }; } } return(this.Collected); }
public override async Task ExecuteAsync(IOperationExecutionContext context) { var recorder = await context.TryGetServiceAsync <IUnitTestRecorder>() ?? throw new ExecutionFailureException("This operation requires a unit test recorder."); await this.RunTestsAsync(context); foreach (var test in this.Events.Where(e => e.Test != null).GroupBy(e => e.Test)) { await recorder.RecordUnitTestAsync( groupName : test.Key.Group, testName : test.Key.Name, testStatus : getStatus(test), testResult : getTestLog(test), startTime : getStartTime(test), duration : getDuration(test) ); } UnitTestStatus getStatus(IGrouping <TestCaseID, TestEvent> test) { foreach (var e in test) { switch (e.Type) { case EventType.Success: case EventType.ExpectedFailure: return(UnitTestStatus.Passed); case EventType.Error: case EventType.Failure: case EventType.UnexpectedSuccess: return(UnitTestStatus.Failed); case EventType.Skip: return(UnitTestStatus.Inconclusive); } } return(UnitTestStatus.Inconclusive); } string getTestLog(IGrouping <TestCaseID, TestEvent> test) { var end = test.FirstOrDefault(e => e.Type == EventType.StopCase); var result = (test.FirstOrDefault(e => e.Type == EventType.Error || e.Type == EventType.Failure || e.Type == EventType.UnexpectedSuccess || e.Type == EventType.Skip) ?? test.FirstOrDefault(e => e.Type == EventType.Success || e.Type == EventType.ExpectedFailure))?.Type; var stdout = end?.Output; var stderr = end?.Error; var skipReason = test.FirstOrDefault(e => e.Type == EventType.Skip)?.Message; var exceptions = test.Select(e => e.Err).Where(e => e != null).ToArray(); return("Test: " + test.Key.ID + AH.ConcatNE("\n", test.Key.Desc) + "\n\nResult: " + AH.CoalesceString(result, "Unknown") + AH.ConcatNE(" (", skipReason, ")") + AH.ConcatNE("\n\nOutput:\n", stdout) + AH.ConcatNE("\n\nError:\n", stderr) + (exceptions.Any() ? "\n\nExceptions:\n\n" + string.Join("\n\n", exceptions) : string.Empty) + "\n"); } DateTimeOffset getStartTime(IGrouping <TestCaseID, TestEvent> test) { return((test.FirstOrDefault(e => e.Type == EventType.StartCase) ?? test.First()).NowTime); } TimeSpan getDuration(IGrouping <TestCaseID, TestEvent> test) { var start = (test.FirstOrDefault(e => e.Type == EventType.StartCase) ?? test.First()).Time; var end = (test.FirstOrDefault(e => e.Type == EventType.StopCase) ?? test.Last()).Time; return(TimeSpan.FromSeconds(end - start)); } }