Compare commits

...

64 Commits

Author SHA1 Message Date
Ethan Chiu
68b05f63c9 Add filetable to testing file, remove ? since we know filetable should never be non null 2020-07-08 16:25:20 -04:00
Ethan Chiu
635baa5295 Add null check 2020-07-08 14:51:07 -04:00
Ethan Chiu
af9202bd8d Fix logic for trimming manifestfile path 2020-07-08 14:43:03 -04:00
Ethan Chiu
b3eea21e4f Fix unit tests to instantiate a FileTable 2020-07-08 14:37:30 -04:00
Ethan Chiu
9a2b3e2662 Revert 2020-07-08 14:11:53 -04:00
Ethan Chiu
6d7efa9906 add line 2020-07-08 14:08:04 -04:00
Ethan Chiu
8828263795 Address situation if FileTable is null + add sanity check for adding file to fileTable 2020-07-08 14:00:12 -04:00
Ethan Chiu
35879fc3b1 Fix null errors 2020-07-08 12:33:22 -04:00
Ethan Chiu
7c57d41b3a Merge branch 'master' of https://github.com/actions/runner into users/ethanchewy/compositeFileTable 2020-07-08 11:33:32 -04:00
Ethan Chiu
41a8c8c3aa Add back line break 2020-07-08 11:20:44 -04:00
Ethan Chiu
d2d0ecf1ed revert back 2020-07-08 11:16:08 -04:00
Ethan Chiu
9a1dd80bcb Sanity check for fileTable add + remove unn. code 2020-07-08 11:14:46 -04:00
Ethan Chiu
3836574cce Fix period 2020-07-08 10:52:36 -04:00
Ethan Chiu
b6526db74e Merge branch 'users/ethanchewy/compositeenv' of https://github.com/actions/runner into users/ethanchewy/compositeFileTable 2020-07-08 10:29:19 -04:00
Ethan Chiu
881e8e72a3 Fix windows unit test syntax error 2020-07-08 10:06:03 -04:00
Ethan Chiu
51784687f9 Merge branch 'users/ethanchewy/compositeenv' of https://github.com/actions/runner into users/ethanchewy/compositeenv 2020-07-08 10:00:43 -04:00
Ethan Chiu
a58ac2ef59 fix unit tests 2020-07-08 10:00:24 -04:00
Ethan Chiu
b712ba2648 Merge branch 'master' into users/ethanchewy/compositeenv 2020-07-07 18:47:48 -04:00
Ethan Chiu
11b9cace75 formatting 2020-07-07 18:18:09 -04:00
Ethan Chiu
96bff6a206 Figure out how to handle set-env edge cases 2020-07-07 18:16:54 -04:00
Ethan Chiu
14a2cbd473 Clean up 2020-07-07 13:02:07 -04:00
Ethan Chiu
20bc6a9a5c Add file length check 2020-07-07 12:57:59 -04:00
Ethan Chiu
191a096f8d Merge branch 'users/ethanchewy/compositeenv' of https://github.com/actions/runner into users/ethanchewy/compositeFileTable 2020-07-07 12:53:19 -04:00
Ethan Chiu
4b3ec9fbe6 Remove unnecessary code 2020-07-07 12:45:59 -04:00
Ethan Chiu
0041023399 add back envToken 2020-07-07 12:44:54 -04:00
Ethan Chiu
4ccac8c0e2 revert back 2020-07-07 12:44:11 -04:00
Ethan Chiu
5d6114548e Revert back 2020-07-07 12:43:13 -04:00
Ethan Chiu
da1e2b0a84 Clean up 2020-07-07 12:40:41 -04:00
Ethan Chiu
b63f98714c Remove env in composite action scope 2020-07-07 12:38:39 -04:00
Ethan Chiu
0bd97d6597 Merge branch 'users/ethanchewy/compositeenv' of https://github.com/actions/runner into users/ethanchewy/compositeFileTable 2020-06-25 13:59:07 -04:00
Ethan Chiu
57d59fcd6e Fix Workflow Step Env overiding Parent Env 2020-06-25 13:53:41 -04:00
Ethan Chiu
1f6518dfad Merge branch 'users/ethanchewy/compositetest2' of https://github.com/actions/runner into users/ethanchewy/compositeenv 2020-06-23 14:30:04 -04:00
Ethan Chiu
54ed6eabce Remove todo 2020-06-23 14:27:06 -04:00
Ethan Chiu
0a6453e241 Clean up file path for error message 2020-06-23 14:19:51 -04:00
Ethan Chiu
368b6254ed Remove unnessary FileID attribute from CompositeActionExecutionData 2020-06-23 13:40:06 -04:00
Ethan Chiu
9c60f1a264 Merge branch 'users/ethanchewy/compositetest2' of https://github.com/actions/runner into users/ethanchewy/compositeFileTable 2020-06-23 13:26:32 -04:00
Ethan Chiu
ba4ce9c3d3 Change confusing term context => templateContext, Eliminate _fileTable and only use ExecutionContext.FileTable + update this table when need be 2020-06-23 13:22:20 -04:00
Ethan Chiu
da2da85766 Pass fileID to all children token of root action token 2020-06-23 12:56:52 -04:00
Ethan Chiu
f9b28c7210 Add helpful error message for null steps 2020-06-23 12:23:02 -04:00
Ethan Chiu
8aadbbdb8e Update context variables in composite action yaml 2020-06-23 12:21:34 -04:00
Ethan Chiu
9ec7047441 Change 0 to location 2020-06-23 12:20:39 -04:00
Ethan Chiu
0d5e84b183 Sort usings in Composite Action Handler 2020-06-23 12:20:12 -04:00
Ethan Chiu
58d11ef80a Progress towards passing FileTable or FileID or FileName 2020-06-22 18:29:48 -04:00
Ethan Chiu
43a3006e7b Initial Start for FileTable stuff 2020-06-22 14:43:50 -04:00
Ethan Chiu
fbef557fd3 Merge branch 'users/ethanchewy/compositetest2' of https://github.com/actions/runner into users/ethanchewy/compositeenv 2020-06-22 12:56:50 -04:00
Ethan Chiu
a254442dcc Add verbose trace logs which are only viewable by devs 2020-06-22 11:37:52 -04:00
Ethan Chiu
94e7b474e1 Remove TODO message for context 2020-06-22 11:31:43 -04:00
Ethan Chiu
37849dc6e3 Remove comment 2020-06-22 10:23:52 -04:00
Ethan Chiu
45ddd4233e Fix env format 2020-06-20 14:20:04 -04:00
Ethan Chiu
f8054f9c2e Add/Merge changes from Multiple Steps PR 2020-06-19 15:04:34 -04:00
Ethan Chiu
e4dfd0e8fd Fix unit tests 2020-06-19 14:51:16 -04:00
Ethan Chiu
00a736d9cc Remove unnecessary code 2020-06-19 14:43:31 -04:00
Ethan Chiu
5988076fcf Add TODO, remove unn. content 2020-06-19 14:38:37 -04:00
Ethan Chiu
9939cf527e Change JobSteps to a List, Change Register Step function name 2020-06-19 14:29:48 -04:00
Ethan Chiu
28be3dffc0 Merge branch 'users/ethanchewy/compositetest2' of https://github.com/actions/runner into users/ethanchewy/compositeenv 2020-06-19 11:30:06 -04:00
Ethan Chiu
941a24ee37 Add comma to Composite 2020-06-19 11:27:19 -04:00
Ethan Chiu
5843362bd4 Change String to string 2020-06-19 11:22:49 -04:00
Ethan Chiu
496064f72d Optimize runtime of code 2020-06-18 17:34:17 -04:00
Ethan Chiu
96e003706f Add debugging message 2020-06-18 16:16:55 -04:00
Ethan Chiu
66cadebeb8 Merge branch 'users/ethanchewy/compositetest2' of https://github.com/actions/runner into users/ethanchewy/compositeenv 2020-06-18 16:14:41 -04:00
Ethan Chiu
180a687f30 Clean up trace messages + add Trace debug in ActionManager 2020-06-18 16:13:56 -04:00
Ethan Chiu
6552263369 clean up 2020-06-18 15:57:23 -04:00
Ethan Chiu
e56b2439b9 Env Flow => Able to get env variables and overwrite current env variables => but it doesn't 'stick' 2020-06-18 15:34:48 -04:00
Ethan Chiu
038e5e2c2e Composite Action Run Steps 2020-06-18 09:48:18 -04:00
4 changed files with 35 additions and 20 deletions

View File

@@ -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;

View File

@@ -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}"); });

View File

@@ -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}"); });
}

View File

@@ -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);