Task: Dependencies and Parallel Execution
Task runs the tasks listed under deps in parallel before the task body, while cmds task: calls run sequentially.
Task distinguishes prerequisites that can run concurrently (deps) from ordered subtask calls (task: inside cmds). Knowing the difference avoids race conditions in CI.
What it does
The deps key lists tasks that must complete before the current task runs; Task executes them in parallel. To run subtasks in a guaranteed order, call them sequentially with "- task: name" entries inside cmds. Dependencies and called tasks can receive variables via a vars map on the reference.
Common usage
# Taskfile.yml
version: '3'
tasks:
generate:
cmds: [go generate ./...]
fmt:
cmds: [gofmt -w .]
# deps run in parallel before build
build:
deps: [generate, fmt]
cmds:
- go build ./...
# ordered subtask calls
release:
cmds:
- task: test
- task: build
- task: publish
vars: { CHANNEL: stable }Syntax
| Form | What it does |
|---|---|
| deps: [a, b] | Run tasks a and b in parallel before this task |
| - task: name | Call another task in order inside cmds |
| vars: { K: v } | Pass variables to a dep or called task |
| --parallel, -p | Run multiple named tasks in parallel |
| --concurrency N, -C N | Limit how many tasks run at once |
In CI
Put independent prerequisites in deps so the runner does them concurrently, but use ordered "task:" calls for steps with a real sequence (test before publish). Cap fan-out with --concurrency on small runners to avoid exhausting CPU or memory.
Common errors in CI
Two deps writing the same file can race because deps run in parallel, producing intermittent failures; make them sequential cmds instead. "task: Task X does not exist" in a dep is a typo or a missing include. A dependency cycle reports "task: Maximum task call exceeded ... probably a cyclic dependency".