Skip to content

Commit 79ed85e

Browse files
committed
docs: update documentation for failure hooks, task conditionals, argument validation and ignore error features
1 parent 3a7b2c9 commit 79ed85e

2 files changed

Lines changed: 105 additions & 10 deletions

File tree

docs/features.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,30 @@ You can run:
5757
makim clean --cache
5858
```
5959

60+
### Arguments Validation
61+
62+
Makim also allows extra validation following the
63+
[JSON schema validation](https://json-schema.org/draft/2020-12/json-schema-validation#name-validation-keywords-for-num),
64+
you can provide validation options similar to JSON schema validation options:
65+
66+
```yaml
67+
{% raw %}
68+
tasks:
69+
create-cluster:
70+
help: Create a Kubernetes cluster with a specific number of nodes
71+
args:
72+
node-count:
73+
help: number of nodes
74+
type: integer
75+
validations:
76+
minimum: 1
77+
maximum: 100
78+
required: true
79+
run: |
80+
echo "Creating Kubernetes cluster with ${{ args.node-count }} nodes..."
81+
{% endraw %}
82+
```
83+
6084
### Benefit
6185

6286
- Prevents hardcoded parameters in scripts.
@@ -174,8 +198,8 @@ Makim automatically expands this into multiple runs for each combination.
174198

175199
### What It Does
176200

177-
Makim provides `pre-run` and `post-run` hooks to execute tasks before or after
178-
another task runs.
201+
Makim provides `pre-run`, `post-run` and `failure` hooks to execute tasks before
202+
or after another task runs or after task execution fails.
179203

180204
### Use Case
181205

@@ -191,6 +215,8 @@ groups:
191215
- task: build.clean
192216
post-run:
193217
- task: build.notify
218+
failure:
219+
- task: build.failure-notify
194220
run: echo "Compiling source code..."
195221

196222
clean:
@@ -200,6 +226,10 @@ groups:
200226
notify:
201227
help: Notify team about successful compilation
202228
run: echo "Build completed successfully!"
229+
230+
failure-notify:
231+
help: Notify team about build failure
232+
run: echo "Build failed! Alerting the team..."
203233
```
204234
205235
### Skipping Hooks

docs/spec.md

Lines changed: 73 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,11 @@ tasks:
7575
help: <description>
7676
args: <arguments>
7777
env: <environment_variables>
78-
hooks: <pre/post-run_hooks>
78+
hooks: <pre-run/post-run/failure_hooks>
7979
matrix: <parameter_combinations>
8080
log: <file_logging_configuration>
81+
if: <validation_conditionals>
82+
options: <additional_options>
8183
run: <command>
8284
{% endraw %}
8385
```
@@ -103,8 +105,8 @@ tasks:
103105

104106
### Description
105107

106-
Defines arguments that tasks can accept with types, defaults, and help
107-
descriptions.
108+
Defines arguments that tasks can accept with types, defaults,help descriptions
109+
and validation options.
108110

109111
### Structure
110112

@@ -115,16 +117,27 @@ args:
115117
default: <default_value>
116118
interactive: <true/false>
117119
help: <description>
120+
validations:
121+
<validation-type>: <validation_value>
118122
```
119123
124+
> You can provide `validation-type` options similar to
125+
> [JSON schema validation options](https://json-schema.org/draft/2020-12/json-schema-validation#name-validation-keywords-for-num)
126+
120127
### Example
121128

122129
```yaml
123130
args:
124131
env:
125-
type: str
132+
type: string
126133
default: "dev"
127134
help: Environment setting
135+
username:
136+
type: string
137+
help: Username for system access
138+
validations:
139+
min-length: 3
140+
max-length: 32
128141
```
129142

130143
---
@@ -134,8 +147,8 @@ args:
134147
### Description
135148

136149
Hooks define tasks that run before (`pre-run`) or after (`post-run`) a task
137-
executes. They can also include an `if` condition to control when the hook
138-
should be triggered.
150+
executes or after (`failure`) a task execution fails. They can also include an
151+
`if` condition to control when the hook should be triggered.
139152

140153
### Structure
141154

@@ -147,6 +160,9 @@ hooks:
147160
post-run:
148161
- task: <task_name>
149162
if: <condition>
163+
failure:
164+
- task: <task_name>
165+
if: <condition>
150166
```
151167

152168
### Example
@@ -161,6 +177,8 @@ tasks:
161177
if: ${{ vars.REBUILD == "true" }}
162178
post-run:
163179
- task: notify
180+
failure:
181+
- task: failure-notify
164182
run: echo "Building project..."
165183
{% endraw %}
166184
```
@@ -397,7 +415,54 @@ tasks:
397415

398416
---
399417

400-
## 12. Variables
418+
## 12. Ignore Error Option
419+
420+
### Description
421+
422+
The `ignore-errors` option allows a task to continue executing subsequent tasks
423+
even if it fails. When `ignore-errors: true` is set under `options`, the failure
424+
of that task does not interrupt the execution flow.
425+
426+
### Structure
427+
428+
```yaml
429+
options:
430+
ignore-errors: <true/false>
431+
```
432+
433+
> The default value for `ignore-errors` is set to `false`
434+
435+
### Example
436+
437+
```yaml
438+
groups:
439+
deploy:
440+
tasks:
441+
clear-cache:
442+
help: Attempt to clear CDN cache (optional)
443+
options:
444+
ignore-errors: true
445+
run: |
446+
echo "Clearing CDN cache..."
447+
# Simulate possible failure
448+
assert 1 == 2
449+
450+
deploy-app:
451+
help: Deploy the application
452+
run: echo "Deploying application to production..."
453+
454+
main-deploy:
455+
help: Deployment pipeline
456+
hooks:
457+
pre-run:
458+
- task: deploy.clear-cache
459+
- task: deploy.deploy-app
460+
run: echo "Deployment complete."
461+
```
462+
463+
---
464+
465+
## 13. Variables
401466

402467
### Description
403468

@@ -434,7 +499,7 @@ tasks:
434499
{% endraw %}
435500
```
436501

437-
## 13. Environment Variables
502+
## 14. Environment Variables
438503

439504
### Description
440505

0 commit comments

Comments
 (0)