workflow: Steps
REAL
workflow is a list. Each item is one step: a named unit that runs
one tool and then says where to go next.
workflow:
- step: start
desc: Build a greeting
tool:
kind: rhai
code: |
"{{ workload.greeting }}, {{ workload.who }}"
next:
- step: shout
- step: shout
tool:
kind: rhai
code: |
"{{ workload.greeting }}, {{ workload.who }}!".to_upper()
Step keys
These are all the keys a step has in the grammar at server v3.161.2
(Step in orchestrate-core/src/playbook.rs, and the Step type in
Appendix A).
| Key | Required | What it is | Covered in |
|---|---|---|---|
step | yes | The step's name. It must be unique within the playbook; next targets refer to it. | here |
tool | yes (server) | What the step runs: one tool, or an ordered list of tools | Chapter 5 |
desc | A description | here | |
next | Where control goes after the step: one name, a list, or a router of arcs with when guards | 6.1 | |
when | An enable guard: an expression checked before the step runs | 6.2 | |
loop | Run the step once per item of a collection | 6.3 | |
spec | Step behaviour: next_mode, timeout, on_error | 6.5 | |
args | Input arguments for the step | 5.3 | |
vars | Values to extract from the step's result into variables | 5.3 | |
set | Variable mutations applied when the step completes | 5.3 |
Two rules from the server's validator apply to the list as a whole
(validate_playbook, src/playbook/parser.rs, server v3.161.2):
- One step must be named
start. The server begins every execution there, wherever it sits in the list. - Step names are unique, and every name used in a
nextmust exist.
There is no special end step to declare. A step with no next
simply ends its branch. Chapter 6 explains
when the whole execution counts as finished.
Checked in CLI v6.4.1 (src/playbook_runner.rs):
- It starts at the first step in the list, not at
start. You can change that with--target <step>. toolis optional. A step without one runs nothing and just routes.- It still runs the old
case:blocks, which the server refuses.
Write playbooks for the server's rules (a start step, a tool on
every step, no case:) and both runtimes accept their structure. A
tool's own fields can still differ between the two;
Chapter 5 shows where.
Step order is not run order
The position of a step in workflow decides nothing except, locally,
which step runs first. Run order comes from next. This playbook
lists done before start. It is still valid, and on a server it runs
start and then done:
# Chapter 4.3: list position is not run order. The server starts at `start`;
# the local runtime (CLI 6.4.1) starts at the first step in the list.
apiVersion: noetl.io/v2
kind: Playbook
metadata:
name: step_order
workflow:
- step: done
tool:
kind: rhai
code: |
"done"
- step: start
tool:
kind: rhai
code: |
"start"
next:
- step: done
The local runtime runs it differently. It starts at the first step in
the list, done, which has no next, so the run ends there and
start never runs. The book's CI checks exactly that
(examples/ch04/step-order):
{
"executed_steps": [
"done"
],
"final_result": "done",
"playbook_name": "step_order",
"status": "ok",
"step_results": {
"done": "done"
}
}