community icon indicating copy to clipboard operation
community copied to clipboard

TEP-0156 : when-in-steps

Open ericzzzzzzz opened this issue 1 year ago β€’ 8 comments

Description

This pull request proposes the ability to define When Expressions directly within Steps. This allows for fine-grained control over step execution based on conditions like the status of previous steps, enabling more dynamic and adaptable workflows.

Overview

  • Steps accept an optional when field with a list of When Expressions.
  • When Expressions are evaluated at the entrypoint level, allowing access to previous step results.
  • Skipped steps due to When Expressions have an exit code of 0 and a TerminationReason of Skipped.
  • Both Operator-based and CEL expressions are supported.
  • Variable substitution within When Expressions includes access to Task Results, Params, Workspaces, and Step Results.

ericzzzzzzz avatar Apr 15 '24 17:04 ericzzzzzzz

/kind tep

chitrangpatel avatar Apr 22 '24 15:04 chitrangpatel

/assign

chitrangpatel avatar Apr 22 '24 16:04 chitrangpatel

@ericzzzzzzz can you please leave a short description of the TEP in the opening comment?

chitrangpatel avatar Apr 23 '24 19:04 chitrangpatel

@tektoncd/core-maintainers PTAL πŸ™

chitrangpatel avatar Apr 23 '24 19:04 chitrangpatel

@ericzzzzzzz can you please leave a short description of the TEP in the opening comment?

done! Thanks

ericzzzzzzz avatar Apr 23 '24 20:04 ericzzzzzzz

/assign

afrittoli avatar Apr 30 '24 16:04 afrittoli

/assign @vdemeester PTAL since you had suggested opening this. πŸ™

chitrangpatel avatar May 15 '24 17:05 chitrangpatel

@vdemeester PTAL when you have a chance πŸ™

chitrangpatel avatar May 27 '24 13:05 chitrangpatel

The lines between Task and Pipeline are bluring more and more with this. An additionnal question, what happens if a step that write a TaskResult is skipped ?

I think the core difference between the fact that Pipeline can fan-out (Matrix, DAG) vs Task is sequential will always remain. So it might appear that lines are being blurred but what you can do with Pipelines vs Tasks will always be different. If Tasks was a DAG of Steps then I agree that the lines would be truly blurred.

I think the outcome will be the same as if the Step producing a TaskResult errored out. The Task author is controlling the flow of the StepAction/Step that is producing the result so they can choose. In this case, I think that the Task will error with the message that it could not produce a result (whatever the current behavior is if the Task does not generate a result)?

chitrangpatel avatar May 27 '24 15:05 chitrangpatel

I think the outcome will be the same as if the Step producing a TaskResult errored out. The Task author is controlling the flow of the StepAction/Step that is producing the result so they can choose. In this case, I think that the Task will error with the message that it could not produce a result (whatever the current behavior is if the Task does not generate a result)?

Can we discuss this in the TEP ?

vdemeester avatar May 27 '24 15:05 vdemeester

I think the outcome will be the same as if the Step producing a TaskResult errored out. The Task author is controlling the flow of the StepAction/Step that is producing the result so they can choose. In this case, I think that the Task will error with the message that it could not produce a result (whatever the current behavior is if the Task does not generate a result)?

Can we discuss this in the TEP ?

I added a section to capture this.

ericzzzzzzz avatar May 27 '24 19:05 ericzzzzzzz

Sorry, one more thing,Β can we dig a bit more into examples of use case it would fullfill ?

For example

  • having "optional" set of caching steps (using StepAction) if a parameter is the Task
  • having a "report" and fail step if the previous step fails
  • … other use case we envision with this feature.

Hi, I added some examples.

ericzzzzzzz avatar May 30 '24 16:05 ericzzzzzzz

Hi @vdemeester , I think I've addressed all the comments you provided on tep. Could you please take another look and let me know if there's anything else you'd like to discuss? Once you're happy with the tep, could you please provide your approval? Thanks!

ericzzzzzzz avatar Jun 10 '24 14:06 ericzzzzzzz

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chitrangpatel, vdemeester

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

tekton-robot avatar Jun 11 '24 18:06 tekton-robot

Thanks for your work @ericzzzzzzz and thanks for the detailed review Vincent!!

/lgtm

chitrangpatel avatar Jun 11 '24 19:06 chitrangpatel