-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Composite Actions: Support Env Flow #557
Conversation
…bles => but it doesn't 'stick'
src/Runner.Worker/action_yaml.json
Outdated
@@ -88,6 +88,7 @@ | |||
"mapping": { | |||
"properties": { | |||
"using": "non-empty-string", | |||
"env": "runs-env", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since, container-runs-env
's structure is used by both composite actions and container actions, I decided to change the name so that both types of runs can use it.
Moreover, to support this change, I made sure to look at all files that contained container-runs-env
and replace it with `run-env'
…actions/runner into users/ethanchewy/compositeenv
Nevermind, in both the composite action and workflow steps, the environment contexts are evaluated correctly: https://github.com/ethanchewy/testing-actions/runs/795652488?check_suite_focus=true |
Ready for review! |
…actions/runner into users/ethanchewy/compositeenv
TODO: Remove only top level env token support. I need to remove most of my changes from the PR |
src/Runner.Worker/ActionManager.cs
Outdated
@@ -1285,6 +1287,7 @@ public sealed class CompositeActionExecutionData : ActionExecutionData | |||
public override bool HasPre => false; | |||
public override bool HasPost => false; | |||
public List<Pipelines.ActionStep> Steps { get; set; } | |||
public MappingToken Environment { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
src/Runner.Worker/ActionManager.cs
Outdated
@@ -400,6 +400,8 @@ public Definition LoadAction(IExecutionContext executionContext, Pipelines.Actio | |||
var compositeAction = definition.Data.Execution as CompositeActionExecutionData; | |||
Trace.Info($"Load {compositeAction.Steps.Count} action steps."); | |||
Trace.Verbose($"Details: {StringUtil.ConvertToJson(compositeAction.Steps)}"); | |||
Trace.Info($"Load: {compositeAction.Environment} environment steps"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove these 2 lines
@@ -27,6 +27,7 @@ public interface IActionManifestManager : IRunnerService | |||
|
|||
Dictionary<string, string> EvaluateContainerEnvironment(IExecutionContext executionContext, MappingToken token, IDictionary<string, PipelineContextData> extraExpressionValues); | |||
|
|||
public Dictionary<string, string> EvaluateCompositeActionEnvironment(IExecutionContext executionContext, MappingToken token, IDictionary<string, PipelineContextData> extraExpressionValues); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
@@ -74,6 +75,8 @@ public ActionDefinitionData Load(IExecutionContext executionContext, string mani | |||
} | |||
|
|||
var actionMapping = token.AssertMapping("action manifest root"); | |||
var envComposite = default(MappingToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
envData[env.Key] = env.Value; | ||
} | ||
// Overwrite with current env | ||
foreach (var env in compositeEnvData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove for now since we don't need to supprot outputs in action
// Add the composite action environment variables to each step. | ||
// If the key already exists, we override it since the composite action env variables will have higher precedence | ||
// Note that for each composite action step, it's environment variables will be set in the StepRunner automatically | ||
var compositeEnvData = manifestManager.EvaluateCompositeActionEnvironment(ExecutionContext, Data.Environment, extraExpressionValues); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove Data.Environment
Removed all of my code that supported the Updated Description above to reflect this. |
lets make sure to test this: steps:
- uses: myorg/mycompositeaction@v1
env:
foo: this is foo
- run: printenv|sort # prints baz
# my composite action
steps:
- env:
bar: this is bar
run: |
echo '::set-env name=baz::this is baz'
printenv|sort # prints foo and bar
|
let's go with this behavior
|
First test works as intended: Second test works as intended as well: As discussed with Ting and Eric, we will most likely have to refactor this in the future. See above comments by Eric for reference. Pushing changes soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
we'll figure out how to simplify w/ nested composite steps runner (when we solve timeout)
* Composite Action Run Steps * Env Flow => Able to get env variables and overwrite current env variables => but it doesn't 'stick' * clean up * Clean up trace messages + add Trace debug in ActionManager * Add debugging message * Optimize runtime of code * Change String to string * Add comma to Composite * Change JobSteps to a List, Change Register Step function name * Add TODO, remove unn. content * Remove unnecessary code * Fix unit tests * Fix env format * Remove comment * Remove TODO message for context * Add verbose trace logs which are only viewable by devs * Sort usings in Composite Action Handler * Change 0 to location * Update context variables in composite action yaml * Add helpful error message for null steps * Fix Workflow Step Env overiding Parent Env * Remove env in composite action scope * Clean up * Revert back * revert back * add back envToken * Remove unnecessary code * Figure out how to handle set-env edge cases * formatting * fix unit tests * Fix windows unit test syntax error
This is branched off of my previous PR #549
In this PR, I build in support for environment variables for a Composite Action and its steps as described in the ADR: https://github.com/actions/runner/blob/users/ethanchewy/compositeADR/docs/adrs/0549-composite-run-steps.md#environment
action.yml
workflow.yml
Demo: https://github.com/ethanchewy/testing-actions/runs/846467581?check_suite_focus=true
This is an experimental feature that can only be turned on via turning the feature flag on:
export TESTING_COMPOSITE_ACTIONS_ALPHA=1
./run.sh