Starting framework

This commit is contained in:
Ethan Chiu
2020-07-10 14:33:12 -04:00
parent 747addfca6
commit a4cc13e36f
4 changed files with 65 additions and 48 deletions

View File

@@ -325,7 +325,7 @@ namespace GitHub.Runner.Worker
var postToken = default(StringToken);
var postEntrypointToken = default(StringToken);
var postIfToken = default(StringToken);
var stepsLoaded = default(List<Pipelines.ActionStep>);
var stepsLoaded = default(List<Pipelines.Step>);
foreach (var run in runsMapping)
{

View File

@@ -48,50 +48,68 @@ namespace GitHub.Runner.Worker.Handlers
// Add each composite action step to the front of the queue
int location = 0;
// While loop till we have reached the last layer?
Stack<Pipelines.Step> stepsToAppend = new Stack<Pipelines.Step>();
// TODO: Assume that each step is not an actionStep
// How do we handle all types of steps?????
foreach (Pipelines.ActionStep aStep in actionSteps)
// Append in reverse order since we are using a stack
for (int i = actionSteps.Count - 1; i --> 0; )
{
// Ex:
// runs:
// using: "composite"
// steps:
// - uses: example/test-composite@v2 (a)
// - run echo hello world (b)
// - run echo hello world 2 (c)
//
// ethanchewy/test-composite/action.yaml
// runs:
// using: "composite"
// steps:
// - run echo hello world 3 (d)
// - run echo hello world 4 (e)
//
// Steps processed as follow:
// | a |
// | a | => | d |
// (Run step d)
// | a |
// | a | => | e |
// (Run step e)
// | a |
// (Run step a)
// | b |
// (Run step b)
// | c |
// (Run step c)
// Done.
var actionRunner = HostContext.CreateService<IActionRunner>();
actionRunner.Action = aStep;
actionRunner.Stage = stage;
actionRunner.Condition = aStep.Condition;
actionRunner.DisplayName = aStep.DisplayName;
ExecutionContext.RegisterNestedStep(actionRunner, inputsData, location, Environment);
location++;
stepsToAppend.Append(actionSteps[i]);
}
while (stepsToAppend != null)
{
var currentStep = stepsToAppend.Pop();
}
// foreach (Pipelines.Step aStep in actionSteps)
// {
// // Ex:
// // runs:
// // using: "composite"
// // steps:
// // - uses: example/test-composite@v2 (a)
// // - run echo hello world (b)
// // - run echo hello world 2 (c)
// //
// // ethanchewy/test-composite/action.yaml
// // runs:
// // using: "composite"
// // steps:
// // - run echo hello world 3 (d)
// // - run echo hello world 4 (e)
// //
// // Steps processed as follow:
// // | a |
// // | a | => | d |
// // (Run step d)
// // | a |
// // | a | => | e |
// // (Run step e)
// // | a |
// // (Run step a)
// // | b |
// // (Run step b)
// // | c |
// // (Run step c)
// // Done.
// // TODO: how are we going to order each step?
// // How is this going to look in the UI (will we have a bunch of nesting)
// // ^ We need to focus on how we are going to get the steps to run in the right order.
// var actionRunner = HostContext.CreateService<IActionRunner>();
// actionRunner.Action = aStep;
// actionRunner.Stage = stage;
// actionRunner.Condition = aStep.Condition;
// actionRunner.DisplayName = aStep.DisplayName;
// ExecutionContext.RegisterNestedStep(actionRunner, inputsData, location, Environment);
// location++;
// }
return Task.CompletedTask;
}

View File

@@ -264,14 +264,13 @@ namespace GitHub.DistributedTask.Pipelines.ObjectTemplating
return result;
}
//Note: originally was List<Step> but we need to change to List<ActionStep> to use the "Inputs" attribute
internal static List<ActionStep> ConvertToSteps(
internal static List<Step> ConvertToSteps(
TemplateContext context,
TemplateToken steps)
{
var stepsSequence = steps.AssertSequence($"job {PipelineTemplateConstants.Steps}");
var result = new List<ActionStep>();
var result = new List<Step>();
foreach (var stepsItem in stepsSequence)
{
var step = ConvertToStep(context, stepsItem);
@@ -287,7 +286,7 @@ namespace GitHub.DistributedTask.Pipelines.ObjectTemplating
return result;
}
private static ActionStep ConvertToStep(
private static Step ConvertToStep(
TemplateContext context,
TemplateToken stepsItem)
{

View File

@@ -159,11 +159,11 @@ namespace GitHub.DistributedTask.Pipelines.ObjectTemplating
return result;
}
// Change to return a variety of steps.
public List<ActionStep> LoadCompositeSteps(
// TODO: Change to return a variety of steps.
public List<Step> LoadCompositeSteps(
TemplateToken token)
{
var result = default(List<ActionStep>);
var result = default(List<Step>);
if (token != null && token.Type != TokenType.Null)
{
var context = CreateContext(null, null, setMissingContext: false);