Add comments + fix action_yaml schema

This commit is contained in:
Ethan Chiu
2020-06-11 10:37:29 -04:00
parent 3fed00814d
commit 65287fb0f0
4 changed files with 224 additions and 14 deletions

View File

@@ -449,15 +449,6 @@ namespace GitHub.Runner.Worker
definition.Data.Name = "Run";
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
{
throw new NotSupportedException(action.Reference.Type.ToString());

View File

@@ -364,6 +364,7 @@ namespace GitHub.Runner.Worker
break;
case "steps":
stepsToken = run.Value.AssertMapping("steps");
// Maybe insert a for loop here instead since MappingToken is not supposed to be used in HandlerFactory.cs
break;
default:
Trace.Info($"Ignore run property {runsKey}.");

View File

@@ -17,5 +17,58 @@ namespace GitHub.Runner.Worker.Handlers
}
// TODO: IMPLEMENT LOGIC FOR HANDLER CODE
public sealed class CompositeActionHandler : Handler, ICompositeActionHandler
{
public CompositeActionExecutionData Data { get; set; }
public async Task RunAsync(ActionRunStage stage)
{
// Copied from NodEscriptActionHandler.cs
// Validate args.
Trace.Entering();
ArgUtil.NotNull(Data, nameof(Data));
ArgUtil.NotNull(ExecutionContext, nameof(ExecutionContext));
ArgUtil.NotNull(Inputs, nameof(Inputs));
ArgUtil.Directory(ActionDirectory, nameof(ActionDirectory));
// Update the env dictionary.
AddInputsToEnvironment();
AddPrependPathToEnvironment();
// expose context to environment
// for example, this is how we know what OS the runner is running on
foreach (var context in ExecutionContext.ExpressionValues)
{
if (context.Value is IEnvironmentContextData runtimeContext && runtimeContext != null)
{
foreach (var env in runtimeContext.GetRuntimeEnvironmentVariables())
{
Environment[env.Key] = env.Value;
}
}
}
// Add Actions Runtime server info
var systemConnection = ExecutionContext.Endpoints.Single(x => string.Equals(x.Name, WellKnownServiceEndpointNames.SystemVssConnection, StringComparison.OrdinalIgnoreCase));
Environment["ACTIONS_RUNTIME_URL"] = systemConnection.Url.AbsoluteUri;
Environment["ACTIONS_RUNTIME_TOKEN"] = systemConnection.Authorization.Parameters[EndpointAuthorizationParameters.AccessToken];
if (systemConnection.Data.TryGetValue("CacheServerUrl", out var cacheUrl) && !string.IsNullOrEmpty(cacheUrl))
{
Environment["ACTIONS_CACHE_URL"] = cacheUrl;
}
// Resolve steps
// How do I handle the MappingToken?
MappingToken target = null;
if (stage == ActionRunStage.Main)
{
target = Data.Steps;
}
}
}
}

View File

@@ -92,11 +92,176 @@
}
}
},
"steps" : {
"steps": {
"sequence": {
"item-type": "steps-item"
}
},
"steps-item": {
"one-of": [
"run-step",
"regular-step",
"steps-template-reference"
]
},
"run-step": {
"mapping": {
"properties": {
"run": "non-empty-string"
}
"properties": {
"name": "string-steps-context",
"id": "non-empty-string",
"if": "step-if",
"timeout-minutes": "number-steps-context",
"run": {
"type": "string-steps-context",
"required": true
},
"continue-on-error": "boolean-steps-context",
"env": "step-env",
"working-directory": "string-steps-context",
"shell": "non-empty-string"
}
}
},
"regular-step": {
"mapping": {
"properties": {
"name": "string-steps-context",
"id": "non-empty-string",
"if": "step-if",
"continue-on-error": "boolean-steps-context",
"timeout-minutes": "number-steps-context",
"uses": {
"type": "non-empty-string",
"required": true
},
"with": "step-with",
"env": "step-env"
}
}
},
"steps-template-reference": {
"mapping": {
"properties": {
"template": "non-empty-string",
"id": "non-empty-string",
"inputs": "steps-template-reference-inputs"
}
}
},
"string-steps-context": {
"context": [
"github",
"needs",
"strategy",
"matrix",
"secrets",
"steps",
"job",
"runner",
"env",
"hashFiles(1,255)"
],
"string": {}
},
"step-if": {
"context": [
"github",
"needs",
"strategy",
"matrix",
"steps",
"job",
"runner",
"env",
"always(0,0)",
"failure(0,0)",
"cancelled(0,0)",
"success(0,0)",
"hashFiles(1,255)"
],
"string": {}
},
"number-steps-context": {
"context": [
"github",
"needs",
"strategy",
"matrix",
"secrets",
"steps",
"job",
"runner",
"env",
"hashFiles(1,255)"
],
"number": {}
},
"boolean-steps-context": {
"context": [
"github",
"needs",
"strategy",
"matrix",
"secrets",
"steps",
"job",
"runner",
"env",
"hashFiles(1,255)"
],
"boolean": {}
},
"step-env": {
"context": [
"github",
"needs",
"strategy",
"matrix",
"secrets",
"steps",
"job",
"runner",
"env",
"hashFiles(1,255)"
],
"mapping": {
"loose-key-type": "non-empty-string",
"loose-value-type": "string"
}
},
"step-with": {
"context": [
"github",
"needs",
"strategy",
"matrix",
"secrets",
"steps",
"job",
"runner",
"env",
"hashFiles(1,255)"
],
"mapping": {
"loose-key-type": "non-empty-string",
"loose-value-type": "string"
}
},
"steps-template-reference-inputs": {
"context": [
"github",
"needs",
"strategy",
"matrix",
"secrets",
"steps",
"job",
"runner",
"env"
],
"mapping": {
"loose-key-type": "non-empty-string",
"loose-value-type": "string"
}
},
"container-runs-context": {