Honour the global-level 'run: once' setting in an included Taskfile
Author: jlucktayCreated Aug 6, 2024Updated Aug 29, 2026
Labelsarea: includes
Given two Taskfiles in a project: one at the root and the other in a subdirectory.
If the subdirectory Taskfile has run: once set at the global/top level (rather than set explicitly per-task) and the root Taskfile includes the subdirectory Taskfile, the task calls from the root directory can potentially run the subdirectory Taskfile tasks more than once.
/Taskfile.yaml:
version: '3'
includes:
subdir: ./subdir/Taskfile.yaml
tasks:
reproduce:
deps:
- task: subdir:once-only
- task: subdir:once-only/subdir/Taskfile.yaml:
version: '3'
run: once
tasks:
once-only:
cmd: echo "Once"
several:
deps:
- task: once-only
- task: once-only
- task: once-onlyFrom inside the subdirectory, run: once works fine:
$ cd subdir
$ task several
task: [once-only] echo "Once"
OnceFrom the root directory, the subdirectory Taskfile's run: once setting has no effect:
$ task reproduce
task: [subdir:once-only] echo "Once"
task: [subdir:once-only] echo "Once"
Once
OnceThese other issues/PRs seem similar/relevant, but distinct from this particular situation:
- #852
- #1563
- #1655
Source: go-task/task