Skip to content
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

Support Conditional Steps in Composite Actions #1438

Merged
merged 22 commits into from
Oct 29, 2021

Conversation

fhammerl
Copy link
Contributor

No description provided.

@@ -1034,7 +1034,6 @@ private ActionSetupInfo PrepareRepositoryActionAsync(IExecutionContext execution
}
}

// TODO: remove once we remove the DistributedTask.EnableCompositeActions FF
foreach (var step in compositeAction.Steps)
{
if (string.IsNullOrEmpty(executionContext.Global.Variables.Get("DistributedTask.EnableCompositeActions")) && step.Reference.Type != Pipelines.ActionSourceType.Script)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need the FF in the runner? I guess the answer might be yes for older version GHES.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose when we do remove the FF we would search the runner for its references, not sure if leaving the TODO made sense.

@@ -123,6 +123,7 @@
"properties": {
"name": "string-steps-context",
"id": "non-empty-string",
"if": "step-if",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add some L0 tests for this new keyword

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added L0 to test parsing ${{ inputs.* }} and functions like always(). Let me know if you think we should test something else.

return jobStatus == ActionResult.Failure;

// Decide based on 'action_status' for composite MAIN steps and 'job.status' for pre, post and job-level steps
var isCompositeMainStep = executionContext.IsEmbedded && executionContext.Stage == ActionRunStage.Main;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add some L0 for these new functions.
Do we need to change other ExpressionFunctions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than Success and Failure, we've got

AlwaysFunction: It's a constant return true
CancelledFunction : dependent on jobStatus == ActionResult.Cancelled, so no change required
HashFunction: irrelevant

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added L0s for Success and Failure

@@ -241,6 +241,10 @@ private async Task RunStepsAsync(List<IStep> embeddedSteps, ActionRunStage stage
step.ExecutionContext.ExpressionFunctions.Add(new FunctionInfo<FailureFunction>(PipelineTemplateConstants.Failure, 0, 0));
step.ExecutionContext.ExpressionFunctions.Add(new FunctionInfo<SuccessFunction>(PipelineTemplateConstants.Success, 0, 0));

// Set action_status to the success of the current composite action
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we adding a new github context? action_status

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i linked you the ADR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have following action related context:

  • github.action_repository
  • github.action_ref
  • github.action_status
  • github.action_path

Looks like in composite actions, they might point to different actions (parent vs. child)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, it's the behaviour we want. - we decided to add github.action_status in that pattern.

action_status only matters to composite actions. If a composite action calls another composite action, we want their github.action_status values to be independent from each other.

@@ -295,108 +299,100 @@ private async Task RunStepsAsync(List<IStep> embeddedSteps, ActionRunStage stage
CancellationTokenRegistration? jobCancelRegister = null;
try
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these change seems risky, do we have any L0 to cover existing behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No L0s for *Handler files afaik, but I wrote up a good number of composite action E2Es we could merge into /canary.

@fhammerl fhammerl marked this pull request as ready for review October 28, 2021 20:37
@fhammerl fhammerl requested a review from a team as a code owner October 28, 2021 20:37
@fhammerl fhammerl merged commit 67ba8a7 into actions:main Oct 29, 2021
@potatoqualitee
Copy link

Woohoo! Thanks everyone 🥳

solarmosaic-kflorence added a commit to solarmosaic-kflorence/schemastore that referenced this pull request Nov 5, 2021
Support has been added in actions/runner#1438
The issue was being tracked in actions/runner#834

The "metadata syntax" documentation has not been updated yet, so the link and copy may need to change.
madskristensen pushed a commit to SchemaStore/schemastore that referenced this pull request Nov 8, 2021
Support has been added in actions/runner#1438
The issue was being tracked in actions/runner#834

The "metadata syntax" documentation has not been updated yet, so the link and copy may need to change.
@fhammerl fhammerl deleted the composite-conditionals branch April 3, 2022 18:03
AdamOlech pushed a commit to antmicro/runner that referenced this pull request Nov 16, 2022
* conditional support for composite actions

* Fix Conditional function evaluation

* Push launch.json temporarily

* Revert "Push launch.json temporarily"

* rename context

* Cleanup comments

* fix success/failure functions to run based on pre/main steps

* idea of step_status

* change to use steps context, WIP

* add inputs to possible if condition expressions

* use action_status

* pr cleanup

* Added right stages

* Test on stage in conditional functions

* Fix naming and formatting

* Fix tests

* Add success and failure L0s

* Remove comment

* Remove whitespace

* Undo formatting

* Add L0 for step-if parsing

* Add ADR

Co-authored-by: Thomas Boop <thboop@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants