mirror of
https://github.com/actions/runner.git
synced 2025-12-10 12:36:23 +00:00
Compare commits
27 Commits
v2.280.1
...
compositeA
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abfc04c58a | ||
|
|
46245a1a71 | ||
|
|
45345dc981 | ||
|
|
7ab3d5ad42 | ||
|
|
4c02d0a685 | ||
|
|
3d36af47f1 | ||
|
|
992ce4b924 | ||
|
|
e927bacf3c | ||
|
|
1ce75f188b | ||
|
|
e0d4270cc1 | ||
|
|
49893b6ede | ||
|
|
6a46ef1c47 | ||
|
|
80540edd4e | ||
|
|
cc8e2738ef | ||
|
|
e9dcc05d75 | ||
|
|
a24e33bbcc | ||
|
|
5dfb2cc552 | ||
|
|
143266bc96 | ||
|
|
522fbd0546 | ||
|
|
2bfa135739 | ||
|
|
3381b951a0 | ||
|
|
a22fcbc036 | ||
|
|
aeae15de7b | ||
|
|
6602117989 | ||
|
|
89412f35bf | ||
|
|
220793d4e9 | ||
|
|
645ba099b9 |
@@ -30,6 +30,8 @@ namespace GitHub.Runner.Worker
|
|||||||
Dictionary<string, string> EvaluateContainerEnvironment(IExecutionContext executionContext, MappingToken token, IDictionary<string, PipelineContextData> extraExpressionValues);
|
Dictionary<string, string> EvaluateContainerEnvironment(IExecutionContext executionContext, MappingToken token, IDictionary<string, PipelineContextData> extraExpressionValues);
|
||||||
|
|
||||||
string EvaluateDefaultInput(IExecutionContext executionContext, string inputName, TemplateToken token);
|
string EvaluateDefaultInput(IExecutionContext executionContext, string inputName, TemplateToken token);
|
||||||
|
|
||||||
|
// string EvaluateDefaultInputInsideComposite(IExecutionContext executionContext, string inputName, TemplateToken token);
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class ActionManifestManager : RunnerService, IActionManifestManager
|
public sealed class ActionManifestManager : RunnerService, IActionManifestManager
|
||||||
@@ -282,6 +284,9 @@ namespace GitHub.Runner.Worker
|
|||||||
if (token != null)
|
if (token != null)
|
||||||
{
|
{
|
||||||
var templateContext = CreateTemplateContext(executionContext);
|
var templateContext = CreateTemplateContext(executionContext);
|
||||||
|
Trace.Info($"Template context GitHub: {StringUtil.ConvertToJson(templateContext.ExpressionValues["github"])}");
|
||||||
|
|
||||||
|
Trace.Info($"Template context keys: {StringUtil.ConvertToJson(templateContext.ExpressionValues.Keys)}");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var evaluateResult = TemplateEvaluator.Evaluate(templateContext, "input-default-context", token, 0, null, omitHeader: true);
|
var evaluateResult = TemplateEvaluator.Evaluate(templateContext, "input-default-context", token, 0, null, omitHeader: true);
|
||||||
@@ -304,6 +309,83 @@ namespace GitHub.Runner.Worker
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public string EvaluateDefaultInputInsideComposite(
|
||||||
|
// IExecutionContext executionContext,
|
||||||
|
// string inputName,
|
||||||
|
// TemplateToken token)
|
||||||
|
// {
|
||||||
|
// string result = "";
|
||||||
|
// if (token != null)
|
||||||
|
// {
|
||||||
|
// // Add GitHub Expression Values
|
||||||
|
// var githubContext = executionContext.ExpressionValues["github"];
|
||||||
|
// Trace.Info($"GitHub Context EvaluateDefaultInputInsideComposite: {StringUtil.ConvertToJson(githubContext)}");
|
||||||
|
|
||||||
|
// var temp = new Dictionary<string, PipelineContextData>();
|
||||||
|
// temp["github"] = githubContext;
|
||||||
|
|
||||||
|
// // Trace.Info($"Token: {StringUtil.ConvertToJson(token)}");
|
||||||
|
|
||||||
|
// var templateContext = CreateTemplateContext(executionContext, temp);
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
|
||||||
|
// var evaluateResult = TemplateEvaluator.Evaluate(templateContext, "uses-input", token, 0, null, omitHeader: true);
|
||||||
|
|
||||||
|
// Trace.Info($"Input '{inputName}': default value evaluate result: {StringUtil.ConvertToJson(evaluateResult)}");
|
||||||
|
// templateContext.Errors.Check();
|
||||||
|
|
||||||
|
// // Can't evaluate the default github.respository, etc.
|
||||||
|
|
||||||
|
|
||||||
|
// // TODO: restrict to only be used for composite "uses" steps
|
||||||
|
// // Find better way to isolate only
|
||||||
|
// // We could create a whitelist for just checkout?
|
||||||
|
// // (ex: "repo", "token", etc.)
|
||||||
|
// // if (evaluateResult is BasicExpressionToken)
|
||||||
|
// // {
|
||||||
|
|
||||||
|
|
||||||
|
// // // var evaluateResult2 = TemplateEvaluator.Evaluate(templateContext, "step-with", token, 0, null, omitHeader: true);
|
||||||
|
// // // templateContext.Errors.Check();
|
||||||
|
|
||||||
|
// // // Trace.Info($"Test2 Input '{inputName}': default value evaluate result: {StringUtil.ConvertToJson(evaluateResult2)}");
|
||||||
|
// // // var result2 = evaluateResult2.AssertString($"default value for input '{inputName}'").Value;
|
||||||
|
|
||||||
|
// // // TODO 6/28 => Try just getting it from the getgithubcontext lmao.
|
||||||
|
|
||||||
|
// // // Trace.Info($"Basic expr token: {evaluateResult}");
|
||||||
|
|
||||||
|
// // var stringVersion = evaluateResult.AssertString($"default value for input '{inputName}'").Value;
|
||||||
|
|
||||||
|
// // // no we have to use the template evaluator since it's a
|
||||||
|
|
||||||
|
// // // var githubTokenSplit =
|
||||||
|
|
||||||
|
// // // // Evaluate it
|
||||||
|
// // // var evaluateResult = executionContext.GetGitHubContext("");
|
||||||
|
|
||||||
|
// // return result2;
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// // Trace.Info($"Input '{inputName}': default value evaluate result: {StringUtil.ConvertToJson(evaluateResult)}");
|
||||||
|
|
||||||
|
// // String
|
||||||
|
// result = evaluateResult.AssertString($"default value for input '{inputName}'").Value;
|
||||||
|
// }
|
||||||
|
// catch (Exception ex) when (!(ex is TemplateValidationException))
|
||||||
|
// {
|
||||||
|
// Trace.Error(ex);
|
||||||
|
// templateContext.Errors.Add(ex);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// templateContext.Errors.Check();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return result;
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
private TemplateContext CreateTemplateContext(
|
private TemplateContext CreateTemplateContext(
|
||||||
IExecutionContext executionContext,
|
IExecutionContext executionContext,
|
||||||
IDictionary<string, PipelineContextData> extraExpressionValues = null)
|
IDictionary<string, PipelineContextData> extraExpressionValues = null)
|
||||||
|
|||||||
@@ -169,6 +169,25 @@ namespace GitHub.Runner.Worker
|
|||||||
validInputs.Add("entryPoint");
|
validInputs.Add("entryPoint");
|
||||||
validInputs.Add("args");
|
validInputs.Add("args");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Trace.Info($"Repo: {ExecutionContext.GetGitHubContext("repository")}");
|
||||||
|
|
||||||
|
// Since we don't pass the GitHub Context attributes to the composite action,
|
||||||
|
// We need to explitly set the default values of certain things we need like the
|
||||||
|
// default repository
|
||||||
|
|
||||||
|
// if (ExecutionContext.GetGitHubContext("repository") == null)
|
||||||
|
// {
|
||||||
|
// ExecutionContext.SetGitHubContext("repository", definition.Directory);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// var githubContext = ExecutionContext.ExpressionValues["github"] as GitHubContext;
|
||||||
|
|
||||||
|
// foreach (var pair in githubContext)
|
||||||
|
// {
|
||||||
|
// ExecutionContext.SetGitHubContext(pair.Key, pair.Value as StringContextData);
|
||||||
|
// }
|
||||||
|
|
||||||
// Merge the default inputs from the definition
|
// Merge the default inputs from the definition
|
||||||
if (definition.Data?.Inputs != null)
|
if (definition.Data?.Inputs != null)
|
||||||
{
|
{
|
||||||
@@ -179,7 +198,17 @@ namespace GitHub.Runner.Worker
|
|||||||
validInputs.Add(key);
|
validInputs.Add(key);
|
||||||
if (!inputs.ContainsKey(key))
|
if (!inputs.ContainsKey(key))
|
||||||
{
|
{
|
||||||
|
Trace.Info($"Definition Input Key: {key}");
|
||||||
|
// if (ExecutionContext.InsideComposite)
|
||||||
|
// {
|
||||||
|
// inputs[key] = manifestManager.EvaluateDefaultInputInsideComposite(ExecutionContext, key, input.Value);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// inputs[key] = manifestManager.EvaluateDefaultInput(ExecutionContext, key, input.Value);
|
||||||
|
// }
|
||||||
inputs[key] = manifestManager.EvaluateDefaultInput(ExecutionContext, key, input.Value);
|
inputs[key] = manifestManager.EvaluateDefaultInput(ExecutionContext, key, input.Value);
|
||||||
|
Trace.Info($"Definition Input Value: {inputs[key]}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,14 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using GitHub.DistributedTask.Expressions2;
|
||||||
using GitHub.DistributedTask.ObjectTemplating.Tokens;
|
using GitHub.DistributedTask.ObjectTemplating.Tokens;
|
||||||
using GitHub.DistributedTask.Pipelines.ContextData;
|
using GitHub.DistributedTask.Pipelines.ContextData;
|
||||||
|
using GitHub.DistributedTask.Pipelines.ObjectTemplating;
|
||||||
using GitHub.DistributedTask.WebApi;
|
using GitHub.DistributedTask.WebApi;
|
||||||
using GitHub.Runner.Common;
|
using GitHub.Runner.Common;
|
||||||
using GitHub.Runner.Sdk;
|
using GitHub.Runner.Sdk;
|
||||||
|
using GitHub.Runner.Worker.Expressions;
|
||||||
using Pipelines = GitHub.DistributedTask.Pipelines;
|
using Pipelines = GitHub.DistributedTask.Pipelines;
|
||||||
|
|
||||||
|
|
||||||
@@ -35,6 +38,8 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
var githubContext = ExecutionContext.ExpressionValues["github"] as GitHubContext;
|
var githubContext = ExecutionContext.ExpressionValues["github"] as GitHubContext;
|
||||||
ArgUtil.NotNull(githubContext, nameof(githubContext));
|
ArgUtil.NotNull(githubContext, nameof(githubContext));
|
||||||
|
|
||||||
|
// Trace.Info($"Github Context: {StringUtil.ConvertToJson(githubContext)}");
|
||||||
|
|
||||||
// Resolve action steps
|
// Resolve action steps
|
||||||
var actionSteps = Data.Steps;
|
var actionSteps = Data.Steps;
|
||||||
|
|
||||||
@@ -45,6 +50,8 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
inputsData[i.Key] = new StringContextData(i.Value);
|
inputsData[i.Key] = new StringContextData(i.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Trace.Info($"Composite Actions Inputs {StringUtil.ConvertToJson(inputsData)}");
|
||||||
|
|
||||||
// Initialize Composite Steps List of Steps
|
// Initialize Composite Steps List of Steps
|
||||||
var compositeSteps = new List<IStep>();
|
var compositeSteps = new List<IStep>();
|
||||||
|
|
||||||
@@ -64,6 +71,10 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
compositeGitHubContext[pair.Key] = pair.Value;
|
compositeGitHubContext[pair.Key] = pair.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Download all data
|
||||||
|
var actionManager = HostContext.GetService<IActionManager>();
|
||||||
|
await actionManager.PrepareActionsAsync(ExecutionContext, actionSteps);
|
||||||
|
|
||||||
foreach (Pipelines.ActionStep actionStep in actionSteps)
|
foreach (Pipelines.ActionStep actionStep in actionSteps)
|
||||||
{
|
{
|
||||||
var actionRunner = HostContext.CreateService<IActionRunner>();
|
var actionRunner = HostContext.CreateService<IActionRunner>();
|
||||||
@@ -76,6 +87,7 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
// Set GITHUB_ACTION_PATH
|
// Set GITHUB_ACTION_PATH
|
||||||
step.ExecutionContext.ExpressionValues["github"] = compositeGitHubContext;
|
step.ExecutionContext.ExpressionValues["github"] = compositeGitHubContext;
|
||||||
step.ExecutionContext.SetGitHubContext("action_path", ActionDirectory);
|
step.ExecutionContext.SetGitHubContext("action_path", ActionDirectory);
|
||||||
|
step.ExecutionContext.ExpressionFunctions.Add(new FunctionInfo<HashFilesFunction>(PipelineTemplateConstants.HashFiles, 1, byte.MaxValue));
|
||||||
|
|
||||||
compositeSteps.Add(step);
|
compositeSteps.Add(step);
|
||||||
}
|
}
|
||||||
@@ -150,6 +162,7 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
{
|
{
|
||||||
ArgUtil.NotNull(compositeSteps, nameof(compositeSteps));
|
ArgUtil.NotNull(compositeSteps, nameof(compositeSteps));
|
||||||
|
|
||||||
|
|
||||||
// The parent StepsRunner of the whole Composite Action Step handles the cancellation stuff already.
|
// The parent StepsRunner of the whole Composite Action Step handles the cancellation stuff already.
|
||||||
foreach (IStep step in compositeSteps)
|
foreach (IStep step in compositeSteps)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -109,9 +109,15 @@
|
|||||||
},
|
},
|
||||||
"composite-steps": {
|
"composite-steps": {
|
||||||
"sequence": {
|
"sequence": {
|
||||||
"item-type": "composite-step"
|
"item-type": "composite-step-types"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"composite-step-types": {
|
||||||
|
"one-of": [
|
||||||
|
"composite-step",
|
||||||
|
"uses-step"
|
||||||
|
]
|
||||||
|
},
|
||||||
"composite-step": {
|
"composite-step": {
|
||||||
"mapping": {
|
"mapping": {
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -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": {
|
"container-runs-context": {
|
||||||
"context": [
|
"context": [
|
||||||
"inputs"
|
"inputs"
|
||||||
@@ -195,6 +215,37 @@
|
|||||||
"loose-key-type": "non-empty-string",
|
"loose-key-type": "non-empty-string",
|
||||||
"loose-value-type": "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"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"uses-input": {
|
||||||
|
"context": [
|
||||||
|
"github",
|
||||||
|
"inputs",
|
||||||
|
"strategy",
|
||||||
|
"matrix",
|
||||||
|
"steps",
|
||||||
|
"job",
|
||||||
|
"runner",
|
||||||
|
"env",
|
||||||
|
"hashFiles(1,255)"
|
||||||
|
],
|
||||||
|
"string": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
2.272.0
|
2.274.0
|
||||||
|
|||||||
Reference in New Issue
Block a user