Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Commit 0b1cdee

Browse files
author
Filinto Duran
committed
convert simple test to mechanical markdown
Signed-off-by: Filinto Duran <filinto.duran@salt.ai>
1 parent 7deb443 commit 0b1cdee

3 files changed

Lines changed: 80 additions & 33 deletions

File tree

.github/workflows/pr-validation.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ jobs:
4949
tox -e py${{ matrix.python-version }}-e2e
5050
- name: Run examples
5151
run: |
52+
pip install mechanical-markdown
5253
cd examples
5354
durabletask-go --port 4001 &
54-
./tests.sh
55+
mm.py README.md
5556
publish:
5657
needs: build
5758
if: startswith(github.ref, 'refs/tags/v')

examples/README.md

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,92 @@ All the examples assume that you have a Durable Task-compatible sidecar running
1414
durabletask-go --port 4001
1515
```
1616

17-
## Running the examples
17+
## Automated Testing
1818

19-
With one of the sidecars running, you can simply execute any of the examples in this directory using `python3`:
19+
These examples can be tested automatically using [mechanical-markdown](https://github.com/dapr/mechanical-markdown), which validates that the examples run correctly and produce expected output.
20+
21+
To install mechanical-markdown:
22+
23+
```bash
24+
python3 -m venv .venv
25+
source .venv/bin/activate
26+
pip install -e ../.
27+
pip install mechanical-markdown
28+
```
29+
30+
To see what commands would be run without executing them:
31+
32+
```bash
33+
mm.py -d README.md
34+
```
35+
36+
To run all examples and validate their output:
37+
38+
```bash
39+
mm.py README.md
40+
```
41+
42+
## Running the Examples
43+
44+
With one of the sidecars running, you can execute any of the examples in this directory using `python3`:
2045

2146
```sh
2247
python3 ./activity_sequence.py
2348
```
2449

2550
In some cases, the sample may require command-line parameters or user inputs. In these cases, the sample will print out instructions on how to proceed.
2651

52+
### Activity Sequence Example
53+
54+
This example demonstrates the function chaining pattern, where an orchestrator schedules three activity calls in a sequence.
55+
56+
<!-- STEP
57+
name: Run activity sequence example
58+
output_match_mode: substring
59+
expected_stdout_lines:
60+
- '"Hello Tokyo!", "Hello Seattle!", "Hello London!"'
61+
-->
62+
63+
```bash
64+
python activity_sequence.py
65+
```
66+
67+
<!-- END_STEP -->
68+
69+
### Fan-out/Fan-in Example
70+
71+
This example demonstrates parallel execution, where an orchestrator schedules a dynamic number of activity calls in parallel, waits for all of them to complete, and then performs an aggregation on the results.
72+
73+
<!-- STEP
74+
name: Run fan-out/fan-in example
75+
output_match_mode: substring
76+
expected_stdout_lines:
77+
- "Orchestration completed! Result"
78+
-->
79+
80+
```bash
81+
python fanout_fanin.py
82+
```
83+
84+
<!-- END_STEP -->
85+
86+
### Human Interaction Example
87+
88+
This example demonstrates how an orchestrator can wait for external events (like human approval) with a timeout. If the approval isn't received within the specified timeout, the order is automatically cancelled.
89+
90+
<!-- STEP
91+
name: Run human interaction example with auto-approval
92+
output_match_mode: substring
93+
expected_stdout_lines:
94+
- "Approved by 'PYTHON-CI'"
95+
-->
96+
97+
```bash
98+
{ sleep 2; printf '\n'; } | python human_interaction.py --timeout 20 --approver PYTHON-CI
99+
```
100+
101+
<!-- END_STEP -->
102+
27103
## List of examples
28104
29105
- [Activity sequence](./activity_sequence.py): Orchestration that schedules three activity calls in a sequence.

examples/tests.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)