mirror of
https://github.com/actions/runner.git
synced 2025-12-14 04:53:34 +00:00
First attempt at creating baseline code for composite actions
This commit is contained in:
@@ -37,6 +37,8 @@ namespace GitHub.Runner.Listener
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
_term.WriteLine("Runner Repo TESTING VERSION OF RUNNER...");
|
||||||
|
Trace.Info("Hey I'm in the log file yay!");
|
||||||
VssUtil.InitializeVssClientSettings(HostContext.UserAgents, HostContext.WebProxy);
|
VssUtil.InitializeVssClientSettings(HostContext.UserAgents, HostContext.WebProxy);
|
||||||
|
|
||||||
_inConfigStage = true;
|
_inConfigStage = true;
|
||||||
|
|||||||
@@ -395,6 +395,9 @@ namespace GitHub.Runner.Worker
|
|||||||
Trace.Info($"Action cleanup plugin: {plugin.PluginTypeName}.");
|
Trace.Info($"Action cleanup plugin: {plugin.PluginTypeName}.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (definition.Data.Execution.ExecutionType == ActionExecutionType.Composite) {
|
||||||
|
// Don't do anything for now
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new NotSupportedException(definition.Data.Execution.ExecutionType.ToString());
|
throw new NotSupportedException(definition.Data.Execution.ExecutionType.ToString());
|
||||||
@@ -446,6 +449,15 @@ namespace GitHub.Runner.Worker
|
|||||||
definition.Data.Name = "Run";
|
definition.Data.Name = "Run";
|
||||||
definition.Data.Description = "Execute a script";
|
definition.Data.Description = "Execute a script";
|
||||||
}
|
}
|
||||||
|
// else if (definition.Data.Execution.ExecutionType == ActionExecutionType.Composite) {
|
||||||
|
// // var compositeAction = definition.Data.Execution as CompositeActionExecutionData;
|
||||||
|
// // // add Trace Info here later => maybe we don't need this?
|
||||||
|
// // Trace.Info($"Action pre composite file: {compositeAction.Pre ?? "N/A"}.");
|
||||||
|
// // // Trace.Info($"Action composite file: {compositeAction.Script}.");
|
||||||
|
// // Trace.Info($"Action post composite file: {compositeAction.Post ?? "N/A"}.");
|
||||||
|
|
||||||
|
// // We don't have to do anything since definition.Data contains everything we need.
|
||||||
|
// }
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new NotSupportedException(action.Reference.Type.ToString());
|
throw new NotSupportedException(action.Reference.Type.ToString());
|
||||||
@@ -1101,6 +1113,11 @@ namespace GitHub.Runner.Worker
|
|||||||
Trace.Info($"Action plugin: {(actionDefinitionData.Execution as PluginActionExecutionData).Plugin}, no more preparation.");
|
Trace.Info($"Action plugin: {(actionDefinitionData.Execution as PluginActionExecutionData).Plugin}, no more preparation.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
else if (actionDefinitionData.Execution.ExecutionType == ActionExecutionType.Composite)
|
||||||
|
{
|
||||||
|
// Trace.Info($"Action composite: {(actionDefinitionData.Execution as CompositeActionExecutionData).Unknown}, no more preparation.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new NotSupportedException(actionDefinitionData.Execution.ExecutionType.ToString());
|
throw new NotSupportedException(actionDefinitionData.Execution.ExecutionType.ToString());
|
||||||
@@ -1211,6 +1228,7 @@ namespace GitHub.Runner.Worker
|
|||||||
NodeJS,
|
NodeJS,
|
||||||
Plugin,
|
Plugin,
|
||||||
Script,
|
Script,
|
||||||
|
Composite
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class ContainerActionExecutionData : ActionExecutionData
|
public sealed class ContainerActionExecutionData : ActionExecutionData
|
||||||
@@ -1267,6 +1285,25 @@ namespace GitHub.Runner.Worker
|
|||||||
public override bool HasPost => false;
|
public override bool HasPost => false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public sealed class CompositeActionExecutionData : ActionExecutionData
|
||||||
|
{
|
||||||
|
// Do I actually need this??
|
||||||
|
// Pre => pre execution for checking steps before, ibid for post
|
||||||
|
// Look at Script for dummy example
|
||||||
|
|
||||||
|
public override ActionExecutionType ExecutionType => ActionExecutionType.Composite;
|
||||||
|
public override bool HasPre => false;
|
||||||
|
public override bool HasPost => false;
|
||||||
|
|
||||||
|
public MappingToken Steps {get; set;}
|
||||||
|
|
||||||
|
// public string Script { get; set; }
|
||||||
|
|
||||||
|
// public string Pre { get; set; }
|
||||||
|
|
||||||
|
// public string Post { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public abstract class ActionExecutionData
|
public abstract class ActionExecutionData
|
||||||
{
|
{
|
||||||
private string _initCondition = $"{Constants.Expressions.Always}()";
|
private string _initCondition = $"{Constants.Expressions.Always}()";
|
||||||
|
|||||||
@@ -311,6 +311,13 @@ namespace GitHub.Runner.Worker
|
|||||||
var postToken = default(StringToken);
|
var postToken = default(StringToken);
|
||||||
var postEntrypointToken = default(StringToken);
|
var postEntrypointToken = default(StringToken);
|
||||||
var postIfToken = default(StringToken);
|
var postIfToken = default(StringToken);
|
||||||
|
// TODO: How do I represent stepsToken as a list of steps?
|
||||||
|
// Well for default value, we can set it to this?
|
||||||
|
// var stepsToken = runsMapping.AssertMapping("steps");
|
||||||
|
// Actually, not sure, let's just set it to MappingToken since AssertMapping("steps")
|
||||||
|
// returns a MappingToken
|
||||||
|
var stepsToken = default(MappingToken);
|
||||||
|
|
||||||
foreach (var run in runsMapping)
|
foreach (var run in runsMapping)
|
||||||
{
|
{
|
||||||
var runsKey = run.Key.AssertString("runs key").Value;
|
var runsKey = run.Key.AssertString("runs key").Value;
|
||||||
@@ -355,6 +362,9 @@ namespace GitHub.Runner.Worker
|
|||||||
case "pre-if":
|
case "pre-if":
|
||||||
preIfToken = run.Value.AssertString("pre-if");
|
preIfToken = run.Value.AssertString("pre-if");
|
||||||
break;
|
break;
|
||||||
|
case "steps":
|
||||||
|
stepsToken = run.Value.AssertMapping("steps");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Trace.Info($"Ignore run property {runsKey}.");
|
Trace.Info($"Ignore run property {runsKey}.");
|
||||||
break;
|
break;
|
||||||
@@ -402,6 +412,21 @@ namespace GitHub.Runner.Worker
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// TODO: add composite stuff here
|
||||||
|
else if (string.Equals(usingToken.Value, "composite", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
if (stepsToken.Count <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException($"No steps provided.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new CompositeActionExecutionData()
|
||||||
|
{
|
||||||
|
Steps = stepsToken
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new ArgumentOutOfRangeException($"'using: {usingToken.Value}' is not supported, use 'docker' or 'node12' instead.");
|
throw new ArgumentOutOfRangeException($"'using: {usingToken.Value}' is not supported, use 'docker' or 'node12' instead.");
|
||||||
|
|||||||
20
src/Runner.Worker/Handlers/CompositeHandler.cs
Normal file
20
src/Runner.Worker/Handlers/CompositeHandler.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using GitHub.Runner.Common;
|
||||||
|
using GitHub.Runner.Sdk;
|
||||||
|
using GitHub.DistributedTask.WebApi;
|
||||||
|
using Pipelines = GitHub.DistributedTask.Pipelines;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace GitHub.Runner.Worker.Handlers
|
||||||
|
{
|
||||||
|
[ServiceLocator(Default = typeof(CompositeActionHandler))]
|
||||||
|
public interface ICompositeActionHandler : IHandler
|
||||||
|
{
|
||||||
|
CompositeActionExecutionData Data { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: IMPLEMENT LOGIC FOR HANDLER CODE
|
||||||
|
}
|
||||||
@@ -66,6 +66,13 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
handler = HostContext.CreateService<IRunnerPluginHandler>();
|
handler = HostContext.CreateService<IRunnerPluginHandler>();
|
||||||
(handler as IRunnerPluginHandler).Data = data as PluginActionExecutionData;
|
(handler as IRunnerPluginHandler).Data = data as PluginActionExecutionData;
|
||||||
}
|
}
|
||||||
|
else if (data.ExecutionType == ActionExecutionType.Composite)
|
||||||
|
{
|
||||||
|
// Runner plugin
|
||||||
|
handler = HostContext.CreateService<ICompositeHandler>();
|
||||||
|
// handler = CompositeHandler;
|
||||||
|
(handler as ICompositeHandler).Data = data as CompositeActionExecutionData;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// This should never happen.
|
// This should never happen.
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ namespace GitHub.Runner.Worker
|
|||||||
jobContext.InitializeJob(message, jobRequestCancellationToken);
|
jobContext.InitializeJob(message, jobRequestCancellationToken);
|
||||||
Trace.Info("Starting the job execution context.");
|
Trace.Info("Starting the job execution context.");
|
||||||
jobContext.Start();
|
jobContext.Start();
|
||||||
|
// User will see this message too
|
||||||
jobContext.Debug($"Starting: {message.JobDisplayName}");
|
jobContext.Debug($"Starting: {message.JobDisplayName}");
|
||||||
|
|
||||||
runnerShutdownRegistration = HostContext.RunnerShutdownToken.Register(() =>
|
runnerShutdownRegistration = HostContext.RunnerShutdownToken.Register(() =>
|
||||||
|
|||||||
@@ -32,7 +32,8 @@
|
|||||||
"one-of": [
|
"one-of": [
|
||||||
"container-runs",
|
"container-runs",
|
||||||
"node12-runs",
|
"node12-runs",
|
||||||
"plugin-runs"
|
"plugin-runs",
|
||||||
|
"composite-runs"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"container-runs": {
|
"container-runs": {
|
||||||
@@ -83,6 +84,21 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"composite-runs": {
|
||||||
|
"mapping" : {
|
||||||
|
"properties": {
|
||||||
|
"using": "non-empty-string",
|
||||||
|
"steps": "steps"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"steps" : {
|
||||||
|
"mapping": {
|
||||||
|
"properties": {
|
||||||
|
"run": "non-empty-string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"container-runs-context": {
|
"container-runs-context": {
|
||||||
"context": [
|
"context": [
|
||||||
"inputs"
|
"inputs"
|
||||||
|
|||||||
Reference in New Issue
Block a user