mirror of
https://github.com/actions/runner.git
synced 2025-12-11 04:46:58 +00:00
Experimentation with evaluating inputs in the context
This commit is contained in:
@@ -292,6 +292,30 @@ namespace GitHub.Runner.Worker
|
||||
var evaluateResult = TemplateEvaluator.Evaluate(templateContext, "input-default-context", token, 0, null, omitHeader: true);
|
||||
templateContext.Errors.Check();
|
||||
|
||||
// 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)
|
||||
{
|
||||
// Trace.Info($"Basic expr token: {evaluateResult}");
|
||||
|
||||
// var stringVersion = evaluateResult.Value as String;
|
||||
|
||||
// var githubTokenSplit =
|
||||
|
||||
// // Evaluate it
|
||||
// var evaluateResult = executionContext.GetGitHubContext("");
|
||||
|
||||
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;
|
||||
|
||||
return result2;
|
||||
}
|
||||
|
||||
Trace.Info($"Input '{inputName}': default value evaluate result: {StringUtil.ConvertToJson(evaluateResult)}");
|
||||
|
||||
// String
|
||||
|
||||
@@ -169,6 +169,18 @@ namespace GitHub.Runner.Worker
|
||||
validInputs.Add("entryPoint");
|
||||
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);
|
||||
}
|
||||
|
||||
// Merge the default inputs from the definition
|
||||
if (definition.Data?.Inputs != null)
|
||||
{
|
||||
@@ -179,7 +191,9 @@ namespace GitHub.Runner.Worker
|
||||
validInputs.Add(key);
|
||||
if (!inputs.ContainsKey(key))
|
||||
{
|
||||
Trace.Info($"Definition Input Key: {key}");
|
||||
inputs[key] = manifestManager.EvaluateDefaultInput(ExecutionContext, key, input.Value);
|
||||
Trace.Info($"Definition Input Value: {inputs[key]}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace GitHub.Runner.Worker.Handlers
|
||||
var githubContext = ExecutionContext.ExpressionValues["github"] as GitHubContext;
|
||||
ArgUtil.NotNull(githubContext, nameof(githubContext));
|
||||
|
||||
Trace.Info($"Github Context: {StringUtil.ConvertToJson(githubContext)}");
|
||||
|
||||
// Resolve action steps
|
||||
var actionSteps = Data.Steps;
|
||||
|
||||
@@ -64,6 +66,11 @@ namespace GitHub.Runner.Worker.Handlers
|
||||
actionRunner.Condition = actionStep.Condition;
|
||||
|
||||
var step = ExecutionContext.CreateCompositeStep(childScopeName, actionRunner, inputsData, Environment);
|
||||
|
||||
// TESTING: Blatantly pass github object so that we have access to it for checking out
|
||||
// (Later, we can just do this for the checkout step!)
|
||||
step.ExecutionContext.ExpressionValues["github"] = githubContext;
|
||||
|
||||
compositeSteps.Add(step);
|
||||
}
|
||||
|
||||
|
||||
@@ -109,9 +109,15 @@
|
||||
},
|
||||
"composite-steps": {
|
||||
"sequence": {
|
||||
"item-type": "composite-step"
|
||||
"item-type": "composite-step-types"
|
||||
}
|
||||
},
|
||||
"composite-step-types": {
|
||||
"one-of": [
|
||||
"composite-step",
|
||||
"uses-step"
|
||||
]
|
||||
},
|
||||
"composite-step": {
|
||||
"mapping": {
|
||||
"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": {
|
||||
"context": [
|
||||
"inputs"
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user