mirror of
https://github.com/actions/runner.git
synced 2025-12-10 20:36:49 +00:00
Compare commits
64 Commits
v2.277.1
...
users/etha
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68b05f63c9 | ||
|
|
635baa5295 | ||
|
|
af9202bd8d | ||
|
|
b3eea21e4f | ||
|
|
9a2b3e2662 | ||
|
|
6d7efa9906 | ||
|
|
8828263795 | ||
|
|
35879fc3b1 | ||
|
|
7c57d41b3a | ||
|
|
41a8c8c3aa | ||
|
|
d2d0ecf1ed | ||
|
|
9a1dd80bcb | ||
|
|
3836574cce | ||
|
|
b6526db74e | ||
|
|
881e8e72a3 | ||
|
|
51784687f9 | ||
|
|
a58ac2ef59 | ||
|
|
b712ba2648 | ||
|
|
11b9cace75 | ||
|
|
96bff6a206 | ||
|
|
14a2cbd473 | ||
|
|
20bc6a9a5c | ||
|
|
191a096f8d | ||
|
|
4b3ec9fbe6 | ||
|
|
0041023399 | ||
|
|
4ccac8c0e2 | ||
|
|
5d6114548e | ||
|
|
da1e2b0a84 | ||
|
|
b63f98714c | ||
|
|
0bd97d6597 | ||
|
|
57d59fcd6e | ||
|
|
1f6518dfad | ||
|
|
54ed6eabce | ||
|
|
0a6453e241 | ||
|
|
368b6254ed | ||
|
|
9c60f1a264 | ||
|
|
ba4ce9c3d3 | ||
|
|
da2da85766 | ||
|
|
f9b28c7210 | ||
|
|
8aadbbdb8e | ||
|
|
9ec7047441 | ||
|
|
0d5e84b183 | ||
|
|
58d11ef80a | ||
|
|
43a3006e7b | ||
|
|
fbef557fd3 | ||
|
|
a254442dcc | ||
|
|
94e7b474e1 | ||
|
|
37849dc6e3 | ||
|
|
45ddd4233e | ||
|
|
f8054f9c2e | ||
|
|
e4dfd0e8fd | ||
|
|
00a736d9cc | ||
|
|
5988076fcf | ||
|
|
9939cf527e | ||
|
|
28be3dffc0 | ||
|
|
941a24ee37 | ||
|
|
5843362bd4 | ||
|
|
496064f72d | ||
|
|
96e003706f | ||
|
|
66cadebeb8 | ||
|
|
180a687f30 | ||
|
|
6552263369 | ||
|
|
e56b2439b9 | ||
|
|
038e5e2c2e |
@@ -33,8 +33,6 @@ namespace GitHub.Runner.Worker
|
||||
public sealed class ActionManifestManager : RunnerService, IActionManifestManager
|
||||
{
|
||||
private TemplateSchema _actionManifestSchema;
|
||||
private IReadOnlyList<String> _fileTable;
|
||||
|
||||
public override void Initialize(IHostContext hostContext)
|
||||
{
|
||||
base.Initialize(hostContext);
|
||||
@@ -55,22 +53,39 @@ namespace GitHub.Runner.Worker
|
||||
|
||||
public ActionDefinitionData Load(IExecutionContext executionContext, string manifestFile)
|
||||
{
|
||||
var context = CreateContext(executionContext);
|
||||
var templateContext = CreateContext(executionContext);
|
||||
ActionDefinitionData actionDefinition = new ActionDefinitionData();
|
||||
|
||||
// Clean up file name real quick
|
||||
// Instead of using Regex which can be computationally expensive,
|
||||
// we can just remove the # of characters from the fileName according to the length of the basePath
|
||||
string basePath = HostContext.GetDirectory(WellKnownDirectory.Actions);
|
||||
string fileRelativePath = manifestFile;
|
||||
if (manifestFile.Contains(basePath))
|
||||
{
|
||||
fileRelativePath = manifestFile.Remove(0, basePath.Length + 1);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var token = default(TemplateToken);
|
||||
|
||||
// Get the file ID
|
||||
var fileId = context.GetFileId(manifestFile);
|
||||
_fileTable = context.GetFileTable();
|
||||
var fileId = templateContext.GetFileId(fileRelativePath);
|
||||
|
||||
// Add this file to the FileTable in executionContext if it hasn't been added already
|
||||
// we use > since fileID is 1 indexed
|
||||
if (fileId > executionContext.FileTable.Count)
|
||||
{
|
||||
executionContext.FileTable.Add(fileRelativePath);
|
||||
}
|
||||
|
||||
// Read the file
|
||||
var fileContent = File.ReadAllText(manifestFile);
|
||||
using (var stringReader = new StringReader(fileContent))
|
||||
{
|
||||
var yamlObjectReader = new YamlObjectReader(null, stringReader);
|
||||
token = TemplateReader.Read(context, "action-root", yamlObjectReader, fileId, out _);
|
||||
var yamlObjectReader = new YamlObjectReader(fileId, stringReader);
|
||||
token = TemplateReader.Read(templateContext, "action-root", yamlObjectReader, fileId, out _);
|
||||
}
|
||||
|
||||
var actionMapping = token.AssertMapping("action manifest root");
|
||||
@@ -89,11 +104,11 @@ namespace GitHub.Runner.Worker
|
||||
break;
|
||||
|
||||
case "inputs":
|
||||
ConvertInputs(context, actionPair.Value, actionDefinition);
|
||||
ConvertInputs(templateContext, actionPair.Value, actionDefinition);
|
||||
break;
|
||||
|
||||
case "runs":
|
||||
actionDefinition.Execution = ConvertRuns(executionContext, context, actionPair.Value);
|
||||
actionDefinition.Execution = ConvertRuns(executionContext, templateContext, actionPair.Value);
|
||||
break;
|
||||
default:
|
||||
Trace.Info($"Ignore action property {propertyName}.");
|
||||
@@ -104,24 +119,24 @@ namespace GitHub.Runner.Worker
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.Error(ex);
|
||||
context.Errors.Add(ex);
|
||||
templateContext.Errors.Add(ex);
|
||||
}
|
||||
|
||||
if (context.Errors.Count > 0)
|
||||
if (templateContext.Errors.Count > 0)
|
||||
{
|
||||
foreach (var error in context.Errors)
|
||||
foreach (var error in templateContext.Errors)
|
||||
{
|
||||
Trace.Error($"Action.yml load error: {error.Message}");
|
||||
executionContext.Error(error.Message);
|
||||
}
|
||||
|
||||
throw new ArgumentException($"Fail to load {manifestFile}");
|
||||
throw new ArgumentException($"Fail to load {fileRelativePath}");
|
||||
}
|
||||
|
||||
if (actionDefinition.Execution == null)
|
||||
{
|
||||
executionContext.Debug($"Loaded action.yml file: {StringUtil.ConvertToJson(actionDefinition)}");
|
||||
throw new ArgumentException($"Top level 'runs:' section is required for {manifestFile}");
|
||||
throw new ArgumentException($"Top level 'runs:' section is required for {fileRelativePath}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -282,13 +297,10 @@ namespace GitHub.Runner.Worker
|
||||
result.ExpressionFunctions.Add(item);
|
||||
}
|
||||
|
||||
// Add the file table
|
||||
if (_fileTable?.Count > 0)
|
||||
// Add the file table from the Execution Context
|
||||
for (var i = 0; i < executionContext.FileTable.Count; i++)
|
||||
{
|
||||
for (var i = 0; i < _fileTable.Count; i++)
|
||||
{
|
||||
result.GetFileId(_fileTable[i]);
|
||||
}
|
||||
result.GetFileId(executionContext.FileTable[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -3584,6 +3584,7 @@ runs:
|
||||
_ec.Setup(x => x.Variables).Returns(new Variables(_hc, variables));
|
||||
_ec.Setup(x => x.ExpressionValues).Returns(new DictionaryContextData());
|
||||
_ec.Setup(x => x.ExpressionFunctions).Returns(new List<IFunctionInfo>());
|
||||
_ec.Setup(x => x.FileTable).Returns(new List<String>());
|
||||
_ec.Setup(x => x.Plan).Returns(new TaskOrchestrationPlanReference());
|
||||
_ec.Setup(x => x.Write(It.IsAny<string>(), It.IsAny<string>())).Callback((string tag, string message) => { _hc.GetTrace().Info($"[{tag}]{message}"); });
|
||||
_ec.Setup(x => x.AddIssue(It.IsAny<Issue>(), It.IsAny<string>())).Callback((Issue issue, string message) => { _hc.GetTrace().Info($"[{issue.Type}]{issue.Message ?? message}"); });
|
||||
|
||||
@@ -759,6 +759,7 @@ namespace GitHub.Runner.Common.Tests.Worker
|
||||
_ec.Setup(x => x.Variables).Returns(new Variables(_hc, new Dictionary<string, VariableValue>()));
|
||||
_ec.Setup(x => x.ExpressionValues).Returns(new DictionaryContextData());
|
||||
_ec.Setup(x => x.ExpressionFunctions).Returns(new List<IFunctionInfo>());
|
||||
_ec.Setup(x => x.FileTable).Returns(new List<String>());
|
||||
_ec.Setup(x => x.Write(It.IsAny<string>(), It.IsAny<string>())).Callback((string tag, string message) => { _hc.GetTrace().Info($"{tag}{message}"); });
|
||||
_ec.Setup(x => x.AddIssue(It.IsAny<Issue>(), It.IsAny<string>())).Callback((Issue issue, string message) => { _hc.GetTrace().Info($"[{issue.Type}]{issue.Message ?? message}"); });
|
||||
}
|
||||
|
||||
@@ -379,6 +379,7 @@ namespace GitHub.Runner.Common.Tests.Worker
|
||||
_ec.Setup(x => x.ExpressionFunctions).Returns(new List<IFunctionInfo>());
|
||||
_ec.Setup(x => x.IntraActionState).Returns(new Dictionary<string, string>());
|
||||
_ec.Setup(x => x.EnvironmentVariables).Returns(new Dictionary<string, string>());
|
||||
_ec.Setup(x => x.FileTable).Returns(new List<String>());
|
||||
_ec.Setup(x => x.SetGitHubContext(It.IsAny<string>(), It.IsAny<string>()));
|
||||
_ec.Setup(x => x.GetGitHubContext(It.IsAny<string>())).Returns("{\"foo\":\"bar\"}");
|
||||
_ec.Setup(x => x.CancellationToken).Returns(_ecTokenSource.Token);
|
||||
|
||||
Reference in New Issue
Block a user