Skip to content

Commit

Permalink
Composite Actions (actions#1170)
Browse files Browse the repository at this point in the history
Composite Actions Refactoring
  • Loading branch information
thboop authored Jul 1, 2021
1 parent ee34f48 commit 7c90b2a
Show file tree
Hide file tree
Showing 6 changed files with 328 additions and 1,913 deletions.
2 changes: 2 additions & 0 deletions src/Runner.Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public static class Constants
public static string PluginTracePrefix = "##[plugin.trace]";
public static readonly int RunnerDownloadRetryMaxAttempts = 3;

public static readonly int CompositeActionsMaxDepth = 9;

// This enum is embedded within the Constants class to make it easier to reference and avoid
// ambiguous type reference with System.Runtime.InteropServices.OSPlatform and System.Runtime.InteropServices.Architecture
public enum OSPlatform
Expand Down
371 changes: 123 additions & 248 deletions src/Runner.Worker/ActionManager.cs

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/Runner.Worker/ExecutionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ public void ForceTaskComplete()

public void RegisterPostJobStep(IStep step)
{
// TODO: Remove when we support composite post job steps
if (this.IsEmbedded)
{
throw new Exception("Composite actions do not currently support post steps");

}
if (step is IActionRunner actionRunner && !Root.StepsWithPostRegistered.Add(actionRunner.Action.Id))
{
Trace.Info($"'post' of '{actionRunner.DisplayName}' already push to post step stack.");
Expand Down
7 changes: 7 additions & 0 deletions src/Runner.Worker/Handlers/CompositeActionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using GitHub.DistributedTask.Expressions2;
using GitHub.DistributedTask.ObjectTemplating.Tokens;
using GitHub.DistributedTask.Pipelines.ContextData;
using GitHub.DistributedTask.Pipelines.ObjectTemplating;
using GitHub.DistributedTask.WebApi;
using GitHub.Runner.Common;
using GitHub.Runner.Sdk;
using GitHub.Runner.Worker;
using GitHub.Runner.Worker.Expressions;
using Pipelines = GitHub.DistributedTask.Pipelines;


Expand Down Expand Up @@ -142,6 +146,9 @@ private async Task RunStepsAsync(List<IStep> embeddedSteps)
{
Trace.Info($"Processing embedded step: DisplayName='{step.DisplayName}'");

// Add Expression Functions
step.ExecutionContext.ExpressionFunctions.Add(new FunctionInfo<HashFilesFunction>(PipelineTemplateConstants.HashFiles, 1, byte.MaxValue));

// Initialize env context
Trace.Info("Initialize Env context for embedded step");
#if OS_WINDOWS
Expand Down
39 changes: 38 additions & 1 deletion src/Runner.Worker/action_yaml.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,13 @@
"item-type": "composite-step"
}
},
"composite-step": {
"composite-step":{
"one-of": [
"run-step",
"uses-step"
]
},
"run-step": {
"mapping": {
"properties": {
"name": "string-steps-context",
Expand All @@ -130,6 +136,20 @@
}
}
},
"uses-step": {
"mapping": {
"properties": {
"name": "string-steps-context",
"id": "non-empty-string",
"uses": {
"type": "non-empty-string",
"required": true
},
"with": "step-with",
"env": "step-env"
}
}
},
"container-runs-context": {
"context": [
"inputs"
Expand Down Expand Up @@ -195,6 +215,23 @@
"loose-key-type": "non-empty-string",
"loose-value-type": "string"
}
},
"step-with": {
"context": [
"github",
"inputs",
"strategy",
"matrix",
"steps",
"job",
"runner",
"env",
"hashFiles(1,255)"
],
"mapping": {
"loose-key-type": "non-empty-string",
"loose-value-type": "string"
}
}
}
}
Loading

0 comments on commit 7c90b2a

Please sign in to comment.