mirror of
https://github.com/actions/runner.git
synced 2025-12-10 12:36:23 +00:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5904d5da8 | ||
|
|
99b28c4143 | ||
|
|
c7b8552edf | ||
|
|
b75246e0fe | ||
|
|
a41a9ba8c7 | ||
|
|
c18643e529 | ||
|
|
0face6e3af | ||
|
|
306be41266 | ||
|
|
4e85b8f3b7 | ||
|
|
476640fd51 | ||
|
|
d05b9111c6 | ||
|
|
444332ca88 | ||
|
|
e6eb9e381d | ||
|
|
3a76a2e291 | ||
|
|
9976cb92a0 | ||
|
|
d900654c42 | ||
|
|
65e3ec86b4 | ||
|
|
a7f205593a | ||
|
|
55f60a4ffc |
@@ -1,13 +1,11 @@
|
|||||||
## Features
|
## Features
|
||||||
- Continued improvements to Composite Actions code and documentation (#616, #625, #626, #641, #645, #657, #658)
|
- Allow registry credentials for job/service containers (#694)
|
||||||
|
|
||||||
## Bugs
|
## Bugs
|
||||||
- Fix feature flag check; omit context for generated context names (#638)
|
- N/A
|
||||||
- Fix endgroup maker (#640)
|
|
||||||
|
|
||||||
## Misc
|
## Misc
|
||||||
- Adding help text for the new runnergroup feature (#626)
|
- N/A
|
||||||
- Updating virtual environment terminology in readme.md (#651)
|
|
||||||
|
|
||||||
## Windows x64
|
## Windows x64
|
||||||
We recommend configuring the runner in a root folder of the Windows drive (e.g. "C:\actions-runner"). This will help avoid issues related to service identity folder permissions and long file path restrictions on Windows.
|
We recommend configuring the runner in a root folder of the Windows drive (e.g. "C:\actions-runner"). This will help avoid issues related to service identity folder permissions and long file path restrictions on Windows.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
2.273.0
|
2.273.3
|
||||||
@@ -56,6 +56,10 @@ namespace GitHub.Runner.Common
|
|||||||
Add<T>(extensions, "GitHub.Runner.Worker.EndGroupCommandExtension, Runner.Worker");
|
Add<T>(extensions, "GitHub.Runner.Worker.EndGroupCommandExtension, Runner.Worker");
|
||||||
Add<T>(extensions, "GitHub.Runner.Worker.EchoCommandExtension, Runner.Worker");
|
Add<T>(extensions, "GitHub.Runner.Worker.EchoCommandExtension, Runner.Worker");
|
||||||
break;
|
break;
|
||||||
|
case "GitHub.Runner.Worker.IFileCommandExtension":
|
||||||
|
Add<T>(extensions, "GitHub.Runner.Worker.AddPathFileCommand, Runner.Worker");
|
||||||
|
Add<T>(extensions, "GitHub.Runner.Worker.SetEnvFileCommand, Runner.Worker");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// This should never happen.
|
// This should never happen.
|
||||||
throw new NotSupportedException($"Unexpected extension type: '{typeof(T).FullName}'");
|
throw new NotSupportedException($"Unexpected extension type: '{typeof(T).FullName}'");
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ namespace GitHub.Runner.Common
|
|||||||
// logging and console
|
// logging and console
|
||||||
Task<TaskLog> AppendLogContentAsync(Guid scopeIdentifier, string hubName, Guid planId, int logId, Stream uploadStream, CancellationToken cancellationToken);
|
Task<TaskLog> AppendLogContentAsync(Guid scopeIdentifier, string hubName, Guid planId, int logId, Stream uploadStream, CancellationToken cancellationToken);
|
||||||
Task AppendTimelineRecordFeedAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, Guid timelineRecordId, Guid stepId, IList<string> lines, CancellationToken cancellationToken);
|
Task AppendTimelineRecordFeedAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, Guid timelineRecordId, Guid stepId, IList<string> lines, CancellationToken cancellationToken);
|
||||||
|
Task AppendTimelineRecordFeedAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, Guid timelineRecordId, Guid stepId, IList<string> lines, long startLine, CancellationToken cancellationToken);
|
||||||
Task<TaskAttachment> CreateAttachmentAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, Guid timelineRecordId, String type, String name, Stream uploadStream, CancellationToken cancellationToken);
|
Task<TaskAttachment> CreateAttachmentAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, Guid timelineRecordId, String type, String name, Stream uploadStream, CancellationToken cancellationToken);
|
||||||
Task<TaskLog> CreateLogAsync(Guid scopeIdentifier, string hubName, Guid planId, TaskLog log, CancellationToken cancellationToken);
|
Task<TaskLog> CreateLogAsync(Guid scopeIdentifier, string hubName, Guid planId, TaskLog log, CancellationToken cancellationToken);
|
||||||
Task<Timeline> CreateTimelineAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, CancellationToken cancellationToken);
|
Task<Timeline> CreateTimelineAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, CancellationToken cancellationToken);
|
||||||
@@ -79,6 +80,12 @@ namespace GitHub.Runner.Common
|
|||||||
return _taskClient.AppendTimelineRecordFeedAsync(scopeIdentifier, hubName, planId, timelineId, timelineRecordId, stepId, lines, cancellationToken: cancellationToken);
|
return _taskClient.AppendTimelineRecordFeedAsync(scopeIdentifier, hubName, planId, timelineId, timelineRecordId, stepId, lines, cancellationToken: cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task AppendTimelineRecordFeedAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, Guid timelineRecordId, Guid stepId, IList<string> lines, long startLine, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
CheckConnection();
|
||||||
|
return _taskClient.AppendTimelineRecordFeedAsync(scopeIdentifier, hubName, planId, timelineId, timelineRecordId, stepId, lines, startLine, cancellationToken: cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
public Task<TaskAttachment> CreateAttachmentAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, Guid timelineRecordId, string type, string name, Stream uploadStream, CancellationToken cancellationToken)
|
public Task<TaskAttachment> CreateAttachmentAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, Guid timelineRecordId, string type, string name, Stream uploadStream, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
CheckConnection();
|
CheckConnection();
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace GitHub.Runner.Common
|
|||||||
event EventHandler<ThrottlingEventArgs> JobServerQueueThrottling;
|
event EventHandler<ThrottlingEventArgs> JobServerQueueThrottling;
|
||||||
Task ShutdownAsync();
|
Task ShutdownAsync();
|
||||||
void Start(Pipelines.AgentJobRequestMessage jobRequest);
|
void Start(Pipelines.AgentJobRequestMessage jobRequest);
|
||||||
void QueueWebConsoleLine(Guid stepRecordId, string line);
|
void QueueWebConsoleLine(Guid stepRecordId, string line, long? lineNumber = null);
|
||||||
void QueueFileUpload(Guid timelineId, Guid timelineRecordId, string type, string name, string path, bool deleteSource);
|
void QueueFileUpload(Guid timelineId, Guid timelineRecordId, string type, string name, string path, bool deleteSource);
|
||||||
void QueueTimelineRecordUpdate(Guid timelineId, TimelineRecord timelineRecord);
|
void QueueTimelineRecordUpdate(Guid timelineId, TimelineRecord timelineRecord);
|
||||||
}
|
}
|
||||||
@@ -155,10 +155,10 @@ namespace GitHub.Runner.Common
|
|||||||
Trace.Info("All queue process tasks have been stopped, and all queues are drained.");
|
Trace.Info("All queue process tasks have been stopped, and all queues are drained.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void QueueWebConsoleLine(Guid stepRecordId, string line)
|
public void QueueWebConsoleLine(Guid stepRecordId, string line, long? lineNumber)
|
||||||
{
|
{
|
||||||
Trace.Verbose("Enqueue web console line queue: {0}", line);
|
Trace.Verbose("Enqueue web console line queue: {0}", line);
|
||||||
_webConsoleLineQueue.Enqueue(new ConsoleLineInfo(stepRecordId, line));
|
_webConsoleLineQueue.Enqueue(new ConsoleLineInfo(stepRecordId, line, lineNumber));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void QueueFileUpload(Guid timelineId, Guid timelineRecordId, string type, string name, string path, bool deleteSource)
|
public void QueueFileUpload(Guid timelineId, Guid timelineRecordId, string type, string name, string path, bool deleteSource)
|
||||||
@@ -214,7 +214,7 @@ namespace GitHub.Runner.Common
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Group consolelines by timeline record of each step
|
// Group consolelines by timeline record of each step
|
||||||
Dictionary<Guid, List<string>> stepsConsoleLines = new Dictionary<Guid, List<string>>();
|
Dictionary<Guid, List<TimelineRecordLogLine>> stepsConsoleLines = new Dictionary<Guid, List<TimelineRecordLogLine>>();
|
||||||
List<Guid> stepRecordIds = new List<Guid>(); // We need to keep lines in order
|
List<Guid> stepRecordIds = new List<Guid>(); // We need to keep lines in order
|
||||||
int linesCounter = 0;
|
int linesCounter = 0;
|
||||||
ConsoleLineInfo lineInfo;
|
ConsoleLineInfo lineInfo;
|
||||||
@@ -222,7 +222,7 @@ namespace GitHub.Runner.Common
|
|||||||
{
|
{
|
||||||
if (!stepsConsoleLines.ContainsKey(lineInfo.StepRecordId))
|
if (!stepsConsoleLines.ContainsKey(lineInfo.StepRecordId))
|
||||||
{
|
{
|
||||||
stepsConsoleLines[lineInfo.StepRecordId] = new List<string>();
|
stepsConsoleLines[lineInfo.StepRecordId] = new List<TimelineRecordLogLine>();
|
||||||
stepRecordIds.Add(lineInfo.StepRecordId);
|
stepRecordIds.Add(lineInfo.StepRecordId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +232,7 @@ namespace GitHub.Runner.Common
|
|||||||
lineInfo.Line = $"{lineInfo.Line.Substring(0, 1024)}...";
|
lineInfo.Line = $"{lineInfo.Line.Substring(0, 1024)}...";
|
||||||
}
|
}
|
||||||
|
|
||||||
stepsConsoleLines[lineInfo.StepRecordId].Add(lineInfo.Line);
|
stepsConsoleLines[lineInfo.StepRecordId].Add(new TimelineRecordLogLine(lineInfo.Line, lineInfo.LineNumber));
|
||||||
linesCounter++;
|
linesCounter++;
|
||||||
|
|
||||||
// process at most about 500 lines of web console line during regular timer dequeue task.
|
// process at most about 500 lines of web console line during regular timer dequeue task.
|
||||||
@@ -247,13 +247,13 @@ namespace GitHub.Runner.Common
|
|||||||
{
|
{
|
||||||
// Split consolelines into batch, each batch will container at most 100 lines.
|
// Split consolelines into batch, each batch will container at most 100 lines.
|
||||||
int batchCounter = 0;
|
int batchCounter = 0;
|
||||||
List<List<string>> batchedLines = new List<List<string>>();
|
List<List<TimelineRecordLogLine>> batchedLines = new List<List<TimelineRecordLogLine>>();
|
||||||
foreach (var line in stepsConsoleLines[stepRecordId])
|
foreach (var line in stepsConsoleLines[stepRecordId])
|
||||||
{
|
{
|
||||||
var currentBatch = batchedLines.ElementAtOrDefault(batchCounter);
|
var currentBatch = batchedLines.ElementAtOrDefault(batchCounter);
|
||||||
if (currentBatch == null)
|
if (currentBatch == null)
|
||||||
{
|
{
|
||||||
batchedLines.Add(new List<string>());
|
batchedLines.Add(new List<TimelineRecordLogLine>());
|
||||||
currentBatch = batchedLines.ElementAt(batchCounter);
|
currentBatch = batchedLines.ElementAt(batchCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +275,6 @@ namespace GitHub.Runner.Common
|
|||||||
{
|
{
|
||||||
Trace.Info($"Skip {batchedLines.Count - 2} batches web console lines for last run");
|
Trace.Info($"Skip {batchedLines.Count - 2} batches web console lines for last run");
|
||||||
batchedLines = batchedLines.TakeLast(2).ToList();
|
batchedLines = batchedLines.TakeLast(2).ToList();
|
||||||
batchedLines[0].Insert(0, "...");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int errorCount = 0;
|
int errorCount = 0;
|
||||||
@@ -284,7 +283,15 @@ namespace GitHub.Runner.Common
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// we will not requeue failed batch, since the web console lines are time sensitive.
|
// we will not requeue failed batch, since the web console lines are time sensitive.
|
||||||
await _jobServer.AppendTimelineRecordFeedAsync(_scopeIdentifier, _hubName, _planId, _jobTimelineId, _jobTimelineRecordId, stepRecordId, batch, default(CancellationToken));
|
if (batch[0].LineNumber.HasValue)
|
||||||
|
{
|
||||||
|
await _jobServer.AppendTimelineRecordFeedAsync(_scopeIdentifier, _hubName, _planId, _jobTimelineId, _jobTimelineRecordId, stepRecordId, batch.Select(logLine => logLine.Line).ToList(), batch[0].LineNumber.Value, default(CancellationToken));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await _jobServer.AppendTimelineRecordFeedAsync(_scopeIdentifier, _hubName, _planId, _jobTimelineId, _jobTimelineRecordId, stepRecordId, batch.Select(logLine => logLine.Line).ToList(), default(CancellationToken));
|
||||||
|
}
|
||||||
|
|
||||||
if (_firstConsoleOutputs)
|
if (_firstConsoleOutputs)
|
||||||
{
|
{
|
||||||
HostContext.WritePerfCounter($"WorkerJobServerQueueAppendFirstConsoleOutput_{_planId.ToString()}");
|
HostContext.WritePerfCounter($"WorkerJobServerQueueAppendFirstConsoleOutput_{_planId.ToString()}");
|
||||||
@@ -653,13 +660,15 @@ namespace GitHub.Runner.Common
|
|||||||
|
|
||||||
internal class ConsoleLineInfo
|
internal class ConsoleLineInfo
|
||||||
{
|
{
|
||||||
public ConsoleLineInfo(Guid recordId, string line)
|
public ConsoleLineInfo(Guid recordId, string line, long? lineNumber)
|
||||||
{
|
{
|
||||||
this.StepRecordId = recordId;
|
this.StepRecordId = recordId;
|
||||||
this.Line = line;
|
this.Line = line;
|
||||||
|
this.LineNumber = lineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Guid StepRecordId { get; set; }
|
public Guid StepRecordId { get; set; }
|
||||||
public string Line { get; set; }
|
public string Line { get; set; }
|
||||||
|
public long? LineNumber { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,6 +145,10 @@ namespace GitHub.Runner.Worker
|
|||||||
stepHost = containerStepHost;
|
stepHost = containerStepHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Setup File Command Manager
|
||||||
|
var fileCommandManager = HostContext.CreateService<IFileCommandManager>();
|
||||||
|
fileCommandManager.InitializeFiles(ExecutionContext, null);
|
||||||
|
|
||||||
// Load the inputs.
|
// Load the inputs.
|
||||||
ExecutionContext.Debug("Loading inputs");
|
ExecutionContext.Debug("Loading inputs");
|
||||||
var templateEvaluator = ExecutionContext.ToPipelineTemplateEvaluator();
|
var templateEvaluator = ExecutionContext.ToPipelineTemplateEvaluator();
|
||||||
@@ -238,7 +242,15 @@ namespace GitHub.Runner.Worker
|
|||||||
handler.PrintActionDetails(Stage);
|
handler.PrintActionDetails(Stage);
|
||||||
|
|
||||||
// Run the task.
|
// Run the task.
|
||||||
await handler.RunAsync(Stage);
|
try
|
||||||
|
{
|
||||||
|
await handler.RunAsync(Stage);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
fileCommandManager.ProcessFiles(ExecutionContext, ExecutionContext.Global.Container);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryEvaluateDisplayName(DictionaryContextData contextData, IExecutionContext context)
|
public bool TryEvaluateDisplayName(DictionaryContextData contextData, IExecutionContext context)
|
||||||
|
|||||||
@@ -717,7 +717,8 @@ namespace GitHub.Runner.Worker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_jobServerQueue.QueueWebConsoleLine(_record.Id, msg);
|
_jobServerQueue.QueueWebConsoleLine(_record.Id, msg, totalLines);
|
||||||
|
|
||||||
return totalLines;
|
return totalLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
262
src/Runner.Worker/FileCommandManager.cs
Normal file
262
src/Runner.Worker/FileCommandManager.cs
Normal file
@@ -0,0 +1,262 @@
|
|||||||
|
using GitHub.DistributedTask.WebApi;
|
||||||
|
using GitHub.Runner.Worker.Container;
|
||||||
|
using GitHub.Runner.Common;
|
||||||
|
using GitHub.Runner.Sdk;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace GitHub.Runner.Worker
|
||||||
|
{
|
||||||
|
[ServiceLocator(Default = typeof(FileCommandManager))]
|
||||||
|
public interface IFileCommandManager : IRunnerService
|
||||||
|
{
|
||||||
|
void InitializeFiles(IExecutionContext context, ContainerInfo container);
|
||||||
|
void ProcessFiles(IExecutionContext context, ContainerInfo container);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class FileCommandManager : RunnerService, IFileCommandManager
|
||||||
|
{
|
||||||
|
private const string _folderName = "_runner_file_commands";
|
||||||
|
private List<IFileCommandExtension> _commandExtensions;
|
||||||
|
private string _fileSuffix = String.Empty;
|
||||||
|
private string _fileCommandDirectory;
|
||||||
|
private Tracing _trace;
|
||||||
|
|
||||||
|
public override void Initialize(IHostContext hostContext)
|
||||||
|
{
|
||||||
|
base.Initialize(hostContext);
|
||||||
|
_trace = HostContext.GetTrace(nameof(FileCommandManager));
|
||||||
|
|
||||||
|
_fileCommandDirectory = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Temp), _folderName);
|
||||||
|
if (!Directory.Exists(_fileCommandDirectory))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(_fileCommandDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
var extensionManager = hostContext.GetService<IExtensionManager>();
|
||||||
|
_commandExtensions = extensionManager.GetExtensions<IFileCommandExtension>() ?? new List<IFileCommandExtension>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InitializeFiles(IExecutionContext context, ContainerInfo container)
|
||||||
|
{
|
||||||
|
var oldSuffix = _fileSuffix;
|
||||||
|
_fileSuffix = Guid.NewGuid().ToString();
|
||||||
|
foreach (var fileCommand in _commandExtensions)
|
||||||
|
{
|
||||||
|
var oldPath = Path.Combine(_fileCommandDirectory, fileCommand.FilePrefix + oldSuffix);
|
||||||
|
if (oldSuffix != String.Empty && File.Exists(oldPath))
|
||||||
|
{
|
||||||
|
TryDeleteFile(oldPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
var newPath = Path.Combine(_fileCommandDirectory, fileCommand.FilePrefix + _fileSuffix);
|
||||||
|
TryDeleteFile(newPath);
|
||||||
|
File.Create(newPath).Dispose();
|
||||||
|
|
||||||
|
var pathToSet = container != null ? container.TranslateToContainerPath(newPath) : newPath;
|
||||||
|
context.SetGitHubContext(fileCommand.ContextName, pathToSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ProcessFiles(IExecutionContext context, ContainerInfo container)
|
||||||
|
{
|
||||||
|
foreach (var fileCommand in _commandExtensions)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fileCommand.ProcessCommand(context, Path.Combine(_fileCommandDirectory, fileCommand.FilePrefix + _fileSuffix),container);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
context.Error($"Unable to process file command '{fileCommand.ContextName}' successfully.");
|
||||||
|
context.Error(ex);
|
||||||
|
context.CommandResult = TaskResult.Failed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool TryDeleteFile(string path)
|
||||||
|
{
|
||||||
|
if (!File.Exists(path))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Delete(path);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_trace.Warning($"Unable to delete file {path} for reason: {e.ToString()}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IFileCommandExtension : IExtension
|
||||||
|
{
|
||||||
|
string ContextName { get; }
|
||||||
|
string FilePrefix { get; }
|
||||||
|
|
||||||
|
void ProcessCommand(IExecutionContext context, string filePath, ContainerInfo container);
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class AddPathFileCommand : RunnerService, IFileCommandExtension
|
||||||
|
{
|
||||||
|
public string ContextName => "path";
|
||||||
|
public string FilePrefix => "add_path_";
|
||||||
|
|
||||||
|
public Type ExtensionType => typeof(IFileCommandExtension);
|
||||||
|
|
||||||
|
public void ProcessCommand(IExecutionContext context, string filePath, ContainerInfo container)
|
||||||
|
{
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
var lines = File.ReadAllLines(filePath, Encoding.UTF8);
|
||||||
|
foreach(var line in lines)
|
||||||
|
{
|
||||||
|
if (line == string.Empty)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
context.Global.PrependPath.RemoveAll(x => string.Equals(x, line, StringComparison.CurrentCulture));
|
||||||
|
context.Global.PrependPath.Add(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class SetEnvFileCommand : RunnerService, IFileCommandExtension
|
||||||
|
{
|
||||||
|
public string ContextName => "env";
|
||||||
|
public string FilePrefix => "set_env_";
|
||||||
|
|
||||||
|
public Type ExtensionType => typeof(IFileCommandExtension);
|
||||||
|
|
||||||
|
public void ProcessCommand(IExecutionContext context, string filePath, ContainerInfo container)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var text = File.ReadAllText(filePath) ?? string.Empty;
|
||||||
|
var index = 0;
|
||||||
|
var line = ReadLine(text, ref index);
|
||||||
|
while (line != null)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(line))
|
||||||
|
{
|
||||||
|
var equalsIndex = line.IndexOf("=", StringComparison.Ordinal);
|
||||||
|
var heredocIndex = line.IndexOf("<<", StringComparison.Ordinal);
|
||||||
|
|
||||||
|
// Normal style NAME=VALUE
|
||||||
|
if (equalsIndex >= 0 && (heredocIndex < 0 || equalsIndex < heredocIndex))
|
||||||
|
{
|
||||||
|
var split = line.Split(new[] { '=' }, 2, StringSplitOptions.None);
|
||||||
|
if (string.IsNullOrEmpty(line))
|
||||||
|
{
|
||||||
|
throw new Exception($"Invalid environment variable format '{line}'. Environment variable name must not be empty");
|
||||||
|
}
|
||||||
|
SetEnvironmentVariable(context, split[0], split[1]);
|
||||||
|
}
|
||||||
|
// Heredoc style NAME<<EOF
|
||||||
|
else if (heredocIndex >= 0 && (equalsIndex < 0 || heredocIndex < equalsIndex))
|
||||||
|
{
|
||||||
|
var split = line.Split(new[] { "<<" }, 2, StringSplitOptions.None);
|
||||||
|
if (string.IsNullOrEmpty(split[0]) || string.IsNullOrEmpty(split[1]))
|
||||||
|
{
|
||||||
|
throw new Exception($"Invalid environment variable format '{line}'. Environment variable name must not be empty and delimiter must not be empty");
|
||||||
|
}
|
||||||
|
var name = split[0];
|
||||||
|
var delimiter = split[1];
|
||||||
|
var startIndex = index; // Start index of the value (inclusive)
|
||||||
|
var endIndex = index; // End index of the value (exclusive)
|
||||||
|
var tempLine = ReadLine(text, ref index, out var newline);
|
||||||
|
while (!string.Equals(tempLine, delimiter, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
if (tempLine == null)
|
||||||
|
{
|
||||||
|
throw new Exception($"Invalid environment variable value. Matching delimiter not found '{delimiter}'");
|
||||||
|
}
|
||||||
|
endIndex = index - newline.Length;
|
||||||
|
tempLine = ReadLine(text, ref index, out newline);
|
||||||
|
}
|
||||||
|
|
||||||
|
var value = endIndex > startIndex ? text.Substring(startIndex, endIndex - startIndex) : string.Empty;
|
||||||
|
SetEnvironmentVariable(context, name, value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"Invalid environment variable format '{line}'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
line = ReadLine(text, ref index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (DirectoryNotFoundException)
|
||||||
|
{
|
||||||
|
context.Debug($"Environment variables file does not exist '{filePath}'");
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException)
|
||||||
|
{
|
||||||
|
context.Debug($"Environment variables file does not exist '{filePath}'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetEnvironmentVariable(
|
||||||
|
IExecutionContext context,
|
||||||
|
string name,
|
||||||
|
string value)
|
||||||
|
{
|
||||||
|
context.Global.EnvironmentVariables[name] = value;
|
||||||
|
context.SetEnvContext(name, value);
|
||||||
|
context.Debug($"{name}='{value}'");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ReadLine(
|
||||||
|
string text,
|
||||||
|
ref int index)
|
||||||
|
{
|
||||||
|
return ReadLine(text, ref index, out _);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ReadLine(
|
||||||
|
string text,
|
||||||
|
ref int index,
|
||||||
|
out string newline)
|
||||||
|
{
|
||||||
|
if (index >= text.Length)
|
||||||
|
{
|
||||||
|
newline = null;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var originalIndex = index;
|
||||||
|
var lfIndex = text.IndexOf("\n", index, StringComparison.Ordinal);
|
||||||
|
if (lfIndex < 0)
|
||||||
|
{
|
||||||
|
index = text.Length;
|
||||||
|
newline = null;
|
||||||
|
return text.Substring(originalIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if OS_WINDOWS
|
||||||
|
var crLFIndex = text.IndexOf("\r\n", index, StringComparison.Ordinal);
|
||||||
|
if (crLFIndex >= 0 && crLFIndex < lfIndex)
|
||||||
|
{
|
||||||
|
index = crLFIndex + 2; // Skip over CRLF
|
||||||
|
newline = "\r\n";
|
||||||
|
return text.Substring(originalIndex, crLFIndex - originalIndex);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
index = lfIndex + 1; // Skip over LF
|
||||||
|
newline = "\n";
|
||||||
|
return text.Substring(originalIndex, lfIndex - originalIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,18 +6,20 @@ namespace GitHub.Runner.Worker
|
|||||||
{
|
{
|
||||||
public sealed class GitHubContext : DictionaryContextData, IEnvironmentContextData
|
public sealed class GitHubContext : DictionaryContextData, IEnvironmentContextData
|
||||||
{
|
{
|
||||||
private readonly HashSet<string> _contextEnvWhitelist = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
private readonly HashSet<string> _contextEnvAllowlist = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||||
{
|
{
|
||||||
"action",
|
"action",
|
||||||
"action_path",
|
"action_path",
|
||||||
"actor",
|
"actor",
|
||||||
"api_url",
|
"api_url",
|
||||||
"base_ref",
|
"base_ref",
|
||||||
|
"env",
|
||||||
"event_name",
|
"event_name",
|
||||||
"event_path",
|
"event_path",
|
||||||
"graphql_url",
|
"graphql_url",
|
||||||
"head_ref",
|
"head_ref",
|
||||||
"job",
|
"job",
|
||||||
|
"path",
|
||||||
"ref",
|
"ref",
|
||||||
"repository",
|
"repository",
|
||||||
"repository_owner",
|
"repository_owner",
|
||||||
@@ -33,11 +35,23 @@ namespace GitHub.Runner.Worker
|
|||||||
{
|
{
|
||||||
foreach (var data in this)
|
foreach (var data in this)
|
||||||
{
|
{
|
||||||
if (_contextEnvWhitelist.Contains(data.Key) && data.Value is StringContextData value)
|
if (_contextEnvAllowlist.Contains(data.Key) && data.Value is StringContextData value)
|
||||||
{
|
{
|
||||||
yield return new KeyValuePair<string, string>($"GITHUB_{data.Key.ToUpperInvariant()}", value);
|
yield return new KeyValuePair<string, string>($"GITHUB_{data.Key.ToUpperInvariant()}", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GitHubContext ShallowCopy()
|
||||||
|
{
|
||||||
|
var copy = new GitHubContext();
|
||||||
|
|
||||||
|
foreach (var pair in this)
|
||||||
|
{
|
||||||
|
copy[pair.Key] = pair.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,9 +32,6 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
ArgUtil.NotNull(Inputs, nameof(Inputs));
|
ArgUtil.NotNull(Inputs, nameof(Inputs));
|
||||||
ArgUtil.NotNull(Data.Steps, nameof(Data.Steps));
|
ArgUtil.NotNull(Data.Steps, nameof(Data.Steps));
|
||||||
|
|
||||||
var githubContext = ExecutionContext.ExpressionValues["github"] as GitHubContext;
|
|
||||||
ArgUtil.NotNull(githubContext, nameof(githubContext));
|
|
||||||
|
|
||||||
// Resolve action steps
|
// Resolve action steps
|
||||||
var actionSteps = Data.Steps;
|
var actionSteps = Data.Steps;
|
||||||
|
|
||||||
@@ -56,14 +53,6 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
childScopeName = $"__{Guid.NewGuid()}";
|
childScopeName = $"__{Guid.NewGuid()}";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the github context so that we don't modify the original pointer
|
|
||||||
// We can't use PipelineContextData.Clone() since that creates a null pointer exception for copying a GitHubContext
|
|
||||||
var compositeGitHubContext = new GitHubContext();
|
|
||||||
foreach (var pair in githubContext)
|
|
||||||
{
|
|
||||||
compositeGitHubContext[pair.Key] = pair.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (Pipelines.ActionStep actionStep in actionSteps)
|
foreach (Pipelines.ActionStep actionStep in actionSteps)
|
||||||
{
|
{
|
||||||
var actionRunner = HostContext.CreateService<IActionRunner>();
|
var actionRunner = HostContext.CreateService<IActionRunner>();
|
||||||
@@ -73,8 +62,13 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
|
|
||||||
var step = ExecutionContext.CreateCompositeStep(childScopeName, actionRunner, inputsData, Environment);
|
var step = ExecutionContext.CreateCompositeStep(childScopeName, actionRunner, inputsData, Environment);
|
||||||
|
|
||||||
|
// Shallow copy github context
|
||||||
|
var gitHubContext = step.ExecutionContext.ExpressionValues["github"] as GitHubContext;
|
||||||
|
ArgUtil.NotNull(gitHubContext, nameof(gitHubContext));
|
||||||
|
gitHubContext = gitHubContext.ShallowCopy();
|
||||||
|
step.ExecutionContext.ExpressionValues["github"] = gitHubContext;
|
||||||
|
|
||||||
// Set GITHUB_ACTION_PATH
|
// Set GITHUB_ACTION_PATH
|
||||||
step.ExecutionContext.ExpressionValues["github"] = compositeGitHubContext;
|
|
||||||
step.ExecutionContext.SetGitHubContext("action_path", ActionDirectory);
|
step.ExecutionContext.SetGitHubContext("action_path", ActionDirectory);
|
||||||
|
|
||||||
compositeSteps.Add(step);
|
compositeSteps.Add(step);
|
||||||
|
|||||||
@@ -161,16 +161,21 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
Directory.CreateDirectory(tempHomeDirectory);
|
Directory.CreateDirectory(tempHomeDirectory);
|
||||||
this.Environment["HOME"] = tempHomeDirectory;
|
this.Environment["HOME"] = tempHomeDirectory;
|
||||||
|
|
||||||
|
var tempFileCommandDirectory = Path.Combine(tempDirectory, "_runner_file_commands");
|
||||||
|
ArgUtil.Directory(tempFileCommandDirectory, nameof(tempFileCommandDirectory));
|
||||||
|
|
||||||
var tempWorkflowDirectory = Path.Combine(tempDirectory, "_github_workflow");
|
var tempWorkflowDirectory = Path.Combine(tempDirectory, "_github_workflow");
|
||||||
ArgUtil.Directory(tempWorkflowDirectory, nameof(tempWorkflowDirectory));
|
ArgUtil.Directory(tempWorkflowDirectory, nameof(tempWorkflowDirectory));
|
||||||
|
|
||||||
container.MountVolumes.Add(new MountVolume("/var/run/docker.sock", "/var/run/docker.sock"));
|
container.MountVolumes.Add(new MountVolume("/var/run/docker.sock", "/var/run/docker.sock"));
|
||||||
container.MountVolumes.Add(new MountVolume(tempHomeDirectory, "/github/home"));
|
container.MountVolumes.Add(new MountVolume(tempHomeDirectory, "/github/home"));
|
||||||
container.MountVolumes.Add(new MountVolume(tempWorkflowDirectory, "/github/workflow"));
|
container.MountVolumes.Add(new MountVolume(tempWorkflowDirectory, "/github/workflow"));
|
||||||
|
container.MountVolumes.Add(new MountVolume(tempFileCommandDirectory, "/github/file_commands"));
|
||||||
container.MountVolumes.Add(new MountVolume(defaultWorkingDirectory, "/github/workspace"));
|
container.MountVolumes.Add(new MountVolume(defaultWorkingDirectory, "/github/workspace"));
|
||||||
|
|
||||||
container.AddPathTranslateMapping(tempHomeDirectory, "/github/home");
|
container.AddPathTranslateMapping(tempHomeDirectory, "/github/home");
|
||||||
container.AddPathTranslateMapping(tempWorkflowDirectory, "/github/workflow");
|
container.AddPathTranslateMapping(tempWorkflowDirectory, "/github/workflow");
|
||||||
|
container.AddPathTranslateMapping(tempFileCommandDirectory, "/github/file_commands");
|
||||||
container.AddPathTranslateMapping(defaultWorkingDirectory, "/github/workspace");
|
container.AddPathTranslateMapping(defaultWorkingDirectory, "/github/workspace");
|
||||||
|
|
||||||
container.ContainerWorkDirectory = "/github/workspace";
|
container.ContainerWorkDirectory = "/github/workspace";
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace GitHub.DistributedTask.WebApi
|
|||||||
: base(baseUrl, pipeline, disposeHandler)
|
: base(baseUrl, pipeline, disposeHandler)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task AppendTimelineRecordFeedAsync(
|
public Task AppendTimelineRecordFeedAsync(
|
||||||
Guid scopeIdentifier,
|
Guid scopeIdentifier,
|
||||||
String planType,
|
String planType,
|
||||||
@@ -91,6 +91,28 @@ namespace GitHub.DistributedTask.WebApi
|
|||||||
userState,
|
userState,
|
||||||
cancellationToken);
|
cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task AppendTimelineRecordFeedAsync(
|
||||||
|
Guid scopeIdentifier,
|
||||||
|
String planType,
|
||||||
|
Guid planId,
|
||||||
|
Guid timelineId,
|
||||||
|
Guid recordId,
|
||||||
|
Guid stepId,
|
||||||
|
IList<String> lines,
|
||||||
|
long startLine,
|
||||||
|
CancellationToken cancellationToken = default(CancellationToken),
|
||||||
|
Object userState = null)
|
||||||
|
{
|
||||||
|
return AppendTimelineRecordFeedAsync(scopeIdentifier,
|
||||||
|
planType,
|
||||||
|
planId,
|
||||||
|
timelineId,
|
||||||
|
recordId,
|
||||||
|
new TimelineRecordFeedLinesWrapper(stepId, lines, startLine),
|
||||||
|
userState,
|
||||||
|
cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task RaisePlanEventAsync<T>(
|
public async Task RaisePlanEventAsync<T>(
|
||||||
Guid scopeIdentifier,
|
Guid scopeIdentifier,
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ namespace GitHub.DistributedTask.WebApi
|
|||||||
this.Count = lines.Count;
|
this.Count = lines.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TimelineRecordFeedLinesWrapper(Guid stepId, IList<string> lines, Int64 startLine)
|
||||||
|
: this(stepId, lines)
|
||||||
|
{
|
||||||
|
this.StartLine = startLine;
|
||||||
|
}
|
||||||
|
|
||||||
[DataMember(Order = 0)]
|
[DataMember(Order = 0)]
|
||||||
public Int32 Count { get; private set; }
|
public Int32 Count { get; private set; }
|
||||||
|
|
||||||
@@ -31,5 +37,8 @@ namespace GitHub.DistributedTask.WebApi
|
|||||||
|
|
||||||
[DataMember(EmitDefaultValue = false)]
|
[DataMember(EmitDefaultValue = false)]
|
||||||
public Guid StepId { get; set; }
|
public Guid StepId { get; set; }
|
||||||
|
|
||||||
|
[DataMember (EmitDefaultValue = false)]
|
||||||
|
public Int64? StartLine { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
29
src/Sdk/DTWebApi/WebApi/TimelineRecordLogLine.cs
Normal file
29
src/Sdk/DTWebApi/WebApi/TimelineRecordLogLine.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
|
namespace GitHub.DistributedTask.WebApi
|
||||||
|
{
|
||||||
|
[DataContract]
|
||||||
|
public sealed class TimelineRecordLogLine
|
||||||
|
{
|
||||||
|
public TimelineRecordLogLine(String line, long? lineNumber)
|
||||||
|
{
|
||||||
|
this.Line = line;
|
||||||
|
this.LineNumber = lineNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
public String Line
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DataMember (EmitDefaultValue = false)]
|
||||||
|
public long? LineNumber
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -60,6 +60,7 @@ namespace GitHub.Runner.Common.Tests
|
|||||||
{
|
{
|
||||||
typeof(IActionCommandExtension),
|
typeof(IActionCommandExtension),
|
||||||
typeof(IExecutionContext),
|
typeof(IExecutionContext),
|
||||||
|
typeof(IFileCommandExtension),
|
||||||
typeof(IHandler),
|
typeof(IHandler),
|
||||||
typeof(IJobExtension),
|
typeof(IJobExtension),
|
||||||
typeof(IStep),
|
typeof(IStep),
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
private TestHostContext _hc;
|
private TestHostContext _hc;
|
||||||
private ActionRunner _actionRunner;
|
private ActionRunner _actionRunner;
|
||||||
private IActionManifestManager _actionManifestManager;
|
private IActionManifestManager _actionManifestManager;
|
||||||
|
private Mock<IFileCommandManager> _fileCommandManager;
|
||||||
|
|
||||||
private DictionaryContextData _context = new DictionaryContextData();
|
private DictionaryContextData _context = new DictionaryContextData();
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -362,6 +364,7 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
_handlerFactory = new Mock<IHandlerFactory>();
|
_handlerFactory = new Mock<IHandlerFactory>();
|
||||||
_defaultStepHost = new Mock<IDefaultStepHost>();
|
_defaultStepHost = new Mock<IDefaultStepHost>();
|
||||||
_actionManifestManager = new ActionManifestManager();
|
_actionManifestManager = new ActionManifestManager();
|
||||||
|
_fileCommandManager = new Mock<IFileCommandManager>();
|
||||||
_actionManifestManager.Initialize(_hc);
|
_actionManifestManager.Initialize(_hc);
|
||||||
|
|
||||||
var githubContext = new GitHubContext();
|
var githubContext = new GitHubContext();
|
||||||
@@ -394,6 +397,8 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
|
|
||||||
_hc.EnqueueInstance<IDefaultStepHost>(_defaultStepHost.Object);
|
_hc.EnqueueInstance<IDefaultStepHost>(_defaultStepHost.Object);
|
||||||
|
|
||||||
|
_hc.EnqueueInstance(_fileCommandManager.Object);
|
||||||
|
|
||||||
// Instance to test.
|
// Instance to test.
|
||||||
_actionRunner = new ActionRunner();
|
_actionRunner = new ActionRunner();
|
||||||
_actionRunner.Initialize(_hc);
|
_actionRunner.Initialize(_hc);
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
var pagingLogger = new Mock<IPagingLogger>();
|
var pagingLogger = new Mock<IPagingLogger>();
|
||||||
var jobServerQueue = new Mock<IJobServerQueue>();
|
var jobServerQueue = new Mock<IJobServerQueue>();
|
||||||
jobServerQueue.Setup(x => x.QueueTimelineRecordUpdate(It.IsAny<Guid>(), It.IsAny<TimelineRecord>()));
|
jobServerQueue.Setup(x => x.QueueTimelineRecordUpdate(It.IsAny<Guid>(), It.IsAny<TimelineRecord>()));
|
||||||
jobServerQueue.Setup(x => x.QueueWebConsoleLine(It.IsAny<Guid>(), It.IsAny<string>())).Callback((Guid id, string msg) => { hc.GetTrace().Info(msg); });
|
jobServerQueue.Setup(x => x.QueueWebConsoleLine(It.IsAny<Guid>(), It.IsAny<string>(),It.IsAny<long>())).Callback((Guid id, string msg, long? lineNumber) => { hc.GetTrace().Info(msg); });
|
||||||
|
|
||||||
hc.EnqueueInstance(pagingLogger.Object);
|
hc.EnqueueInstance(pagingLogger.Object);
|
||||||
hc.SetSingleton(jobServerQueue.Object);
|
hc.SetSingleton(jobServerQueue.Object);
|
||||||
@@ -137,7 +137,7 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
|
|
||||||
ec.Complete();
|
ec.Complete();
|
||||||
|
|
||||||
jobServerQueue.Verify(x => x.QueueWebConsoleLine(It.IsAny<Guid>(), It.IsAny<string>()), Times.Exactly(10));
|
jobServerQueue.Verify(x => x.QueueWebConsoleLine(It.IsAny<Guid>(), It.IsAny<string>(), It.IsAny<long?>()), Times.Exactly(10));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
var pagingLogger5 = new Mock<IPagingLogger>();
|
var pagingLogger5 = new Mock<IPagingLogger>();
|
||||||
var jobServerQueue = new Mock<IJobServerQueue>();
|
var jobServerQueue = new Mock<IJobServerQueue>();
|
||||||
jobServerQueue.Setup(x => x.QueueTimelineRecordUpdate(It.IsAny<Guid>(), It.IsAny<TimelineRecord>()));
|
jobServerQueue.Setup(x => x.QueueTimelineRecordUpdate(It.IsAny<Guid>(), It.IsAny<TimelineRecord>()));
|
||||||
jobServerQueue.Setup(x => x.QueueWebConsoleLine(It.IsAny<Guid>(), It.IsAny<string>())).Callback((Guid id, string msg) => { hc.GetTrace().Info(msg); });
|
jobServerQueue.Setup(x => x.QueueWebConsoleLine(It.IsAny<Guid>(), It.IsAny<string>(), It.IsAny<long?>())).Callback((Guid id, string msg, long? lineNumber) => { hc.GetTrace().Info(msg); });
|
||||||
|
|
||||||
var actionRunner1 = new ActionRunner();
|
var actionRunner1 = new ActionRunner();
|
||||||
actionRunner1.Initialize(hc);
|
actionRunner1.Initialize(hc);
|
||||||
@@ -269,7 +269,7 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
var pagingLogger5 = new Mock<IPagingLogger>();
|
var pagingLogger5 = new Mock<IPagingLogger>();
|
||||||
var jobServerQueue = new Mock<IJobServerQueue>();
|
var jobServerQueue = new Mock<IJobServerQueue>();
|
||||||
jobServerQueue.Setup(x => x.QueueTimelineRecordUpdate(It.IsAny<Guid>(), It.IsAny<TimelineRecord>()));
|
jobServerQueue.Setup(x => x.QueueTimelineRecordUpdate(It.IsAny<Guid>(), It.IsAny<TimelineRecord>()));
|
||||||
jobServerQueue.Setup(x => x.QueueWebConsoleLine(It.IsAny<Guid>(), It.IsAny<string>())).Callback((Guid id, string msg) => { hc.GetTrace().Info(msg); });
|
jobServerQueue.Setup(x => x.QueueWebConsoleLine(It.IsAny<Guid>(), It.IsAny<string>(), It.IsAny<long?>())).Callback((Guid id, string msg, long? lineNumber) => { hc.GetTrace().Info(msg); });
|
||||||
|
|
||||||
var actionRunner1 = new ActionRunner();
|
var actionRunner1 = new ActionRunner();
|
||||||
actionRunner1.Initialize(hc);
|
actionRunner1.Initialize(hc);
|
||||||
|
|||||||
390
src/Test/L0/Worker/SetEnvFileCommandL0.cs
Normal file
390
src/Test/L0/Worker/SetEnvFileCommandL0.cs
Normal file
@@ -0,0 +1,390 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using GitHub.Runner.Common.Util;
|
||||||
|
using GitHub.Runner.Sdk;
|
||||||
|
using GitHub.Runner.Worker;
|
||||||
|
using GitHub.Runner.Worker.Container;
|
||||||
|
using GitHub.Runner.Worker.Handlers;
|
||||||
|
using Moq;
|
||||||
|
using Xunit;
|
||||||
|
using DTWebApi = GitHub.DistributedTask.WebApi;
|
||||||
|
|
||||||
|
namespace GitHub.Runner.Common.Tests.Worker
|
||||||
|
{
|
||||||
|
public sealed class SetEnvFileCommandL0
|
||||||
|
{
|
||||||
|
private Mock<IExecutionContext> _executionContext;
|
||||||
|
private List<Tuple<DTWebApi.Issue, string>> _issues;
|
||||||
|
private string _rootDirectory;
|
||||||
|
private SetEnvFileCommand _setEnvFileCommand;
|
||||||
|
private ITraceWriter _trace;
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[Trait("Level", "L0")]
|
||||||
|
[Trait("Category", "Worker")]
|
||||||
|
public void SetEnvFileCommand_DirectoryNotFound()
|
||||||
|
{
|
||||||
|
using (var hostContext = Setup())
|
||||||
|
{
|
||||||
|
var envFile = Path.Combine(_rootDirectory, "directory-not-found", "env");
|
||||||
|
_setEnvFileCommand.ProcessCommand(_executionContext.Object, envFile, null);
|
||||||
|
Assert.Equal(0, _issues.Count);
|
||||||
|
Assert.Equal(0, _executionContext.Object.Global.EnvironmentVariables.Count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[Trait("Level", "L0")]
|
||||||
|
[Trait("Category", "Worker")]
|
||||||
|
public void SetEnvFileCommand_NotFound()
|
||||||
|
{
|
||||||
|
using (var hostContext = Setup())
|
||||||
|
{
|
||||||
|
var envFile = Path.Combine(_rootDirectory, "file-not-found");
|
||||||
|
_setEnvFileCommand.ProcessCommand(_executionContext.Object, envFile, null);
|
||||||
|
Assert.Equal(0, _issues.Count);
|
||||||
|
Assert.Equal(0, _executionContext.Object.Global.EnvironmentVariables.Count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[Trait("Level", "L0")]
|
||||||
|
[Trait("Category", "Worker")]
|
||||||
|
public void SetEnvFileCommand_EmptyFile()
|
||||||
|
{
|
||||||
|
using (var hostContext = Setup())
|
||||||
|
{
|
||||||
|
var envFile = Path.Combine(_rootDirectory, "empty-file");
|
||||||
|
var content = new List<string>();
|
||||||
|
WriteContent(envFile, content);
|
||||||
|
_setEnvFileCommand.ProcessCommand(_executionContext.Object, envFile, null);
|
||||||
|
Assert.Equal(0, _issues.Count);
|
||||||
|
Assert.Equal(0, _executionContext.Object.Global.EnvironmentVariables.Count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[Trait("Level", "L0")]
|
||||||
|
[Trait("Category", "Worker")]
|
||||||
|
public void SetEnvFileCommand_Simple()
|
||||||
|
{
|
||||||
|
using (var hostContext = Setup())
|
||||||
|
{
|
||||||
|
var envFile = Path.Combine(_rootDirectory, "simple");
|
||||||
|
var content = new List<string>
|
||||||
|
{
|
||||||
|
"MY_ENV=MY VALUE",
|
||||||
|
};
|
||||||
|
WriteContent(envFile, content);
|
||||||
|
_setEnvFileCommand.ProcessCommand(_executionContext.Object, envFile, null);
|
||||||
|
Assert.Equal(0, _issues.Count);
|
||||||
|
Assert.Equal(1, _executionContext.Object.Global.EnvironmentVariables.Count);
|
||||||
|
Assert.Equal("MY VALUE", _executionContext.Object.Global.EnvironmentVariables["MY_ENV"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[Trait("Level", "L0")]
|
||||||
|
[Trait("Category", "Worker")]
|
||||||
|
public void SetEnvFileCommand_Simple_SkipEmptyLines()
|
||||||
|
{
|
||||||
|
using (var hostContext = Setup())
|
||||||
|
{
|
||||||
|
var envFile = Path.Combine(_rootDirectory, "simple");
|
||||||
|
var content = new List<string>
|
||||||
|
{
|
||||||
|
string.Empty,
|
||||||
|
"MY_ENV=my value",
|
||||||
|
string.Empty,
|
||||||
|
"MY_ENV_2=my second value",
|
||||||
|
string.Empty,
|
||||||
|
};
|
||||||
|
WriteContent(envFile, content);
|
||||||
|
_setEnvFileCommand.ProcessCommand(_executionContext.Object, envFile, null);
|
||||||
|
Assert.Equal(0, _issues.Count);
|
||||||
|
Assert.Equal(2, _executionContext.Object.Global.EnvironmentVariables.Count);
|
||||||
|
Assert.Equal("my value", _executionContext.Object.Global.EnvironmentVariables["MY_ENV"]);
|
||||||
|
Assert.Equal("my second value", _executionContext.Object.Global.EnvironmentVariables["MY_ENV_2"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[Trait("Level", "L0")]
|
||||||
|
[Trait("Category", "Worker")]
|
||||||
|
public void SetEnvFileCommand_Simple_EmptyValue()
|
||||||
|
{
|
||||||
|
using (var hostContext = Setup())
|
||||||
|
{
|
||||||
|
var envFile = Path.Combine(_rootDirectory, "simple-empty-value");
|
||||||
|
var content = new List<string>
|
||||||
|
{
|
||||||
|
"MY_ENV=",
|
||||||
|
};
|
||||||
|
WriteContent(envFile, content);
|
||||||
|
_setEnvFileCommand.ProcessCommand(_executionContext.Object, envFile, null);
|
||||||
|
Assert.Equal(0, _issues.Count);
|
||||||
|
Assert.Equal(1, _executionContext.Object.Global.EnvironmentVariables.Count);
|
||||||
|
Assert.Equal(string.Empty, _executionContext.Object.Global.EnvironmentVariables["MY_ENV"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[Trait("Level", "L0")]
|
||||||
|
[Trait("Category", "Worker")]
|
||||||
|
public void SetEnvFileCommand_Simple_MultipleValues()
|
||||||
|
{
|
||||||
|
using (var hostContext = Setup())
|
||||||
|
{
|
||||||
|
var envFile = Path.Combine(_rootDirectory, "simple");
|
||||||
|
var content = new List<string>
|
||||||
|
{
|
||||||
|
"MY_ENV=my value",
|
||||||
|
"MY_ENV_2=",
|
||||||
|
"MY_ENV_3=my third value",
|
||||||
|
};
|
||||||
|
WriteContent(envFile, content);
|
||||||
|
_setEnvFileCommand.ProcessCommand(_executionContext.Object, envFile, null);
|
||||||
|
Assert.Equal(0, _issues.Count);
|
||||||
|
Assert.Equal(3, _executionContext.Object.Global.EnvironmentVariables.Count);
|
||||||
|
Assert.Equal("my value", _executionContext.Object.Global.EnvironmentVariables["MY_ENV"]);
|
||||||
|
Assert.Equal(string.Empty, _executionContext.Object.Global.EnvironmentVariables["MY_ENV_2"]);
|
||||||
|
Assert.Equal("my third value", _executionContext.Object.Global.EnvironmentVariables["MY_ENV_3"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[Trait("Level", "L0")]
|
||||||
|
[Trait("Category", "Worker")]
|
||||||
|
public void SetEnvFileCommand_Simple_SpecialCharacters()
|
||||||
|
{
|
||||||
|
using (var hostContext = Setup())
|
||||||
|
{
|
||||||
|
var envFile = Path.Combine(_rootDirectory, "simple");
|
||||||
|
var content = new List<string>
|
||||||
|
{
|
||||||
|
"MY_ENV==abc",
|
||||||
|
"MY_ENV_2=def=ghi",
|
||||||
|
"MY_ENV_3=jkl=",
|
||||||
|
};
|
||||||
|
WriteContent(envFile, content);
|
||||||
|
_setEnvFileCommand.ProcessCommand(_executionContext.Object, envFile, null);
|
||||||
|
Assert.Equal(0, _issues.Count);
|
||||||
|
Assert.Equal(3, _executionContext.Object.Global.EnvironmentVariables.Count);
|
||||||
|
Assert.Equal("=abc", _executionContext.Object.Global.EnvironmentVariables["MY_ENV"]);
|
||||||
|
Assert.Equal("def=ghi", _executionContext.Object.Global.EnvironmentVariables["MY_ENV_2"]);
|
||||||
|
Assert.Equal("jkl=", _executionContext.Object.Global.EnvironmentVariables["MY_ENV_3"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[Trait("Level", "L0")]
|
||||||
|
[Trait("Category", "Worker")]
|
||||||
|
public void SetEnvFileCommand_Heredoc()
|
||||||
|
{
|
||||||
|
using (var hostContext = Setup())
|
||||||
|
{
|
||||||
|
var envFile = Path.Combine(_rootDirectory, "heredoc");
|
||||||
|
var content = new List<string>
|
||||||
|
{
|
||||||
|
"MY_ENV<<EOF",
|
||||||
|
"line one",
|
||||||
|
"line two",
|
||||||
|
"line three",
|
||||||
|
"EOF",
|
||||||
|
};
|
||||||
|
WriteContent(envFile, content);
|
||||||
|
_setEnvFileCommand.ProcessCommand(_executionContext.Object, envFile, null);
|
||||||
|
Assert.Equal(0, _issues.Count);
|
||||||
|
Assert.Equal(1, _executionContext.Object.Global.EnvironmentVariables.Count);
|
||||||
|
Assert.Equal($"line one{Environment.NewLine}line two{Environment.NewLine}line three", _executionContext.Object.Global.EnvironmentVariables["MY_ENV"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[Trait("Level", "L0")]
|
||||||
|
[Trait("Category", "Worker")]
|
||||||
|
public void SetEnvFileCommand_Heredoc_EmptyValue()
|
||||||
|
{
|
||||||
|
using (var hostContext = Setup())
|
||||||
|
{
|
||||||
|
var envFile = Path.Combine(_rootDirectory, "heredoc");
|
||||||
|
var content = new List<string>
|
||||||
|
{
|
||||||
|
"MY_ENV<<EOF",
|
||||||
|
"EOF",
|
||||||
|
};
|
||||||
|
WriteContent(envFile, content);
|
||||||
|
_setEnvFileCommand.ProcessCommand(_executionContext.Object, envFile, null);
|
||||||
|
Assert.Equal(0, _issues.Count);
|
||||||
|
Assert.Equal(1, _executionContext.Object.Global.EnvironmentVariables.Count);
|
||||||
|
Assert.Equal(string.Empty, _executionContext.Object.Global.EnvironmentVariables["MY_ENV"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[Trait("Level", "L0")]
|
||||||
|
[Trait("Category", "Worker")]
|
||||||
|
public void SetEnvFileCommand_Heredoc_SkipEmptyLines()
|
||||||
|
{
|
||||||
|
using (var hostContext = Setup())
|
||||||
|
{
|
||||||
|
var envFile = Path.Combine(_rootDirectory, "heredoc");
|
||||||
|
var content = new List<string>
|
||||||
|
{
|
||||||
|
string.Empty,
|
||||||
|
"MY_ENV<<EOF",
|
||||||
|
"hello",
|
||||||
|
"world",
|
||||||
|
"EOF",
|
||||||
|
string.Empty,
|
||||||
|
"MY_ENV_2<<EOF",
|
||||||
|
"HELLO",
|
||||||
|
"AGAIN",
|
||||||
|
"EOF",
|
||||||
|
string.Empty,
|
||||||
|
};
|
||||||
|
WriteContent(envFile, content);
|
||||||
|
_setEnvFileCommand.ProcessCommand(_executionContext.Object, envFile, null);
|
||||||
|
Assert.Equal(0, _issues.Count);
|
||||||
|
Assert.Equal(2, _executionContext.Object.Global.EnvironmentVariables.Count);
|
||||||
|
Assert.Equal($"hello{Environment.NewLine}world", _executionContext.Object.Global.EnvironmentVariables["MY_ENV"]);
|
||||||
|
Assert.Equal($"HELLO{Environment.NewLine}AGAIN", _executionContext.Object.Global.EnvironmentVariables["MY_ENV_2"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[Trait("Level", "L0")]
|
||||||
|
[Trait("Category", "Worker")]
|
||||||
|
public void SetEnvFileCommand_Heredoc_SpecialCharacters()
|
||||||
|
{
|
||||||
|
using (var hostContext = Setup())
|
||||||
|
{
|
||||||
|
var envFile = Path.Combine(_rootDirectory, "heredoc");
|
||||||
|
var content = new List<string>
|
||||||
|
{
|
||||||
|
"MY_ENV<<=EOF",
|
||||||
|
"hello",
|
||||||
|
"one",
|
||||||
|
"=EOF",
|
||||||
|
"MY_ENV_2<<<EOF",
|
||||||
|
"hello",
|
||||||
|
"two",
|
||||||
|
"<EOF",
|
||||||
|
"MY_ENV_3<<EOF",
|
||||||
|
"hello",
|
||||||
|
string.Empty,
|
||||||
|
"three",
|
||||||
|
string.Empty,
|
||||||
|
"EOF",
|
||||||
|
"MY_ENV_4<<EOF",
|
||||||
|
"hello=four",
|
||||||
|
"EOF",
|
||||||
|
"MY_ENV_5<<EOF",
|
||||||
|
" EOF",
|
||||||
|
"EOF",
|
||||||
|
};
|
||||||
|
WriteContent(envFile, content);
|
||||||
|
_setEnvFileCommand.ProcessCommand(_executionContext.Object, envFile, null);
|
||||||
|
Assert.Equal(0, _issues.Count);
|
||||||
|
Assert.Equal(5, _executionContext.Object.Global.EnvironmentVariables.Count);
|
||||||
|
Assert.Equal($"hello{Environment.NewLine}one", _executionContext.Object.Global.EnvironmentVariables["MY_ENV"]);
|
||||||
|
Assert.Equal($"hello{Environment.NewLine}two", _executionContext.Object.Global.EnvironmentVariables["MY_ENV_2"]);
|
||||||
|
Assert.Equal($"hello{Environment.NewLine}{Environment.NewLine}three{Environment.NewLine}", _executionContext.Object.Global.EnvironmentVariables["MY_ENV_3"]);
|
||||||
|
Assert.Equal($"hello=four", _executionContext.Object.Global.EnvironmentVariables["MY_ENV_4"]);
|
||||||
|
Assert.Equal($" EOF", _executionContext.Object.Global.EnvironmentVariables["MY_ENV_5"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if OS_WINDOWS
|
||||||
|
[Fact]
|
||||||
|
[Trait("Level", "L0")]
|
||||||
|
[Trait("Category", "Worker")]
|
||||||
|
public void SetEnvFileCommand_Heredoc_PreservesNewline()
|
||||||
|
{
|
||||||
|
using (var hostContext = Setup())
|
||||||
|
{
|
||||||
|
var newline = "\n";
|
||||||
|
var envFile = Path.Combine(_rootDirectory, "heredoc");
|
||||||
|
var content = new List<string>
|
||||||
|
{
|
||||||
|
"MY_ENV<<EOF",
|
||||||
|
"hello",
|
||||||
|
"world",
|
||||||
|
"EOF",
|
||||||
|
};
|
||||||
|
WriteContent(envFile, content, newline: newline);
|
||||||
|
_setEnvFileCommand.ProcessCommand(_executionContext.Object, envFile, null);
|
||||||
|
Assert.Equal(0, _issues.Count);
|
||||||
|
Assert.Equal(1, _executionContext.Object.Global.EnvironmentVariables.Count);
|
||||||
|
Assert.Equal($"hello{newline}world", _executionContext.Object.Global.EnvironmentVariables["MY_ENV"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private void WriteContent(
|
||||||
|
string path,
|
||||||
|
List<string> content,
|
||||||
|
string newline = null)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(newline))
|
||||||
|
{
|
||||||
|
newline = Environment.NewLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
var encoding = new UTF8Encoding(true); // Emit BOM
|
||||||
|
var contentStr = string.Join(newline, content);
|
||||||
|
File.WriteAllText(path, contentStr, encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
private TestHostContext Setup([CallerMemberName] string name = "")
|
||||||
|
{
|
||||||
|
_issues = new List<Tuple<DTWebApi.Issue, string>>();
|
||||||
|
|
||||||
|
var hostContext = new TestHostContext(this, name);
|
||||||
|
|
||||||
|
// Trace
|
||||||
|
_trace = hostContext.GetTrace();
|
||||||
|
|
||||||
|
// Directory for test data
|
||||||
|
var workDirectory = hostContext.GetDirectory(WellKnownDirectory.Work);
|
||||||
|
ArgUtil.NotNullOrEmpty(workDirectory, nameof(workDirectory));
|
||||||
|
Directory.CreateDirectory(workDirectory);
|
||||||
|
_rootDirectory = Path.Combine(workDirectory, nameof(SetEnvFileCommandL0));
|
||||||
|
Directory.CreateDirectory(_rootDirectory);
|
||||||
|
|
||||||
|
// Execution context
|
||||||
|
_executionContext = new Mock<IExecutionContext>();
|
||||||
|
_executionContext.Setup(x => x.Global)
|
||||||
|
.Returns(new GlobalContext
|
||||||
|
{
|
||||||
|
EnvironmentVariables = new Dictionary<string, string>(VarUtil.EnvironmentVariableKeyComparer),
|
||||||
|
WriteDebug = true,
|
||||||
|
});
|
||||||
|
_executionContext.Setup(x => x.AddIssue(It.IsAny<DTWebApi.Issue>(), It.IsAny<string>()))
|
||||||
|
.Callback((DTWebApi.Issue issue, string logMessage) =>
|
||||||
|
{
|
||||||
|
_issues.Add(new Tuple<DTWebApi.Issue, string>(issue, logMessage));
|
||||||
|
var message = !string.IsNullOrEmpty(logMessage) ? logMessage : issue.Message;
|
||||||
|
_trace.Info($"Issue '{issue.Type}': {message}");
|
||||||
|
});
|
||||||
|
_executionContext.Setup(x => x.Write(It.IsAny<string>(), It.IsAny<string>()))
|
||||||
|
.Callback((string tag, string message) =>
|
||||||
|
{
|
||||||
|
_trace.Info($"{tag}{message}");
|
||||||
|
});
|
||||||
|
|
||||||
|
// SetEnvFileCommand
|
||||||
|
_setEnvFileCommand = new SetEnvFileCommand();
|
||||||
|
_setEnvFileCommand.Initialize(hostContext);
|
||||||
|
|
||||||
|
return hostContext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -44,7 +44,7 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
|
|
||||||
_contexts = new DictionaryContextData();
|
_contexts = new DictionaryContextData();
|
||||||
_jobContext = new JobContext();
|
_jobContext = new JobContext();
|
||||||
_contexts["github"] = new DictionaryContextData();
|
_contexts["github"] = new GitHubContext();
|
||||||
_contexts["runner"] = new DictionaryContextData();
|
_contexts["runner"] = new DictionaryContextData();
|
||||||
_contexts["job"] = _jobContext;
|
_contexts["job"] = _jobContext;
|
||||||
_ec.Setup(x => x.ExpressionValues).Returns(_contexts);
|
_ec.Setup(x => x.ExpressionValues).Returns(_contexts);
|
||||||
@@ -602,7 +602,12 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
var stepContext = new Mock<IExecutionContext>();
|
var stepContext = new Mock<IExecutionContext>();
|
||||||
stepContext.SetupAllProperties();
|
stepContext.SetupAllProperties();
|
||||||
stepContext.Setup(x => x.Global).Returns(() => _ec.Object.Global);
|
stepContext.Setup(x => x.Global).Returns(() => _ec.Object.Global);
|
||||||
stepContext.Setup(x => x.ExpressionValues).Returns(new DictionaryContextData());
|
var expressionValues = new DictionaryContextData();
|
||||||
|
foreach (var pair in _ec.Object.ExpressionValues)
|
||||||
|
{
|
||||||
|
expressionValues[pair.Key] = pair.Value;
|
||||||
|
}
|
||||||
|
stepContext.Setup(x => x.ExpressionValues).Returns(expressionValues);
|
||||||
stepContext.Setup(x => x.ExpressionFunctions).Returns(new List<IFunctionInfo>());
|
stepContext.Setup(x => x.ExpressionFunctions).Returns(new List<IFunctionInfo>());
|
||||||
stepContext.Setup(x => x.JobContext).Returns(_jobContext);
|
stepContext.Setup(x => x.JobContext).Returns(_jobContext);
|
||||||
stepContext.Setup(x => x.ContextName).Returns(step.Object.Action.ContextName);
|
stepContext.Setup(x => x.ContextName).Returns(step.Object.Action.ContextName);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
2.273.0
|
2.273.3
|
||||||
|
|||||||
Reference in New Issue
Block a user