Skip to content

Commit 91fdbe8

Browse files
committed
Configure task dependencies to avoid redundant execution
The "Task" task runner tool is used to perform common development operations for the project. Tasks may call other tasks. Under certain conditions (most commonly when running a convenience "umbrella" which calls all tasks of a general type), this can result in the same task being called redundantly, which is inefficient. Worse, since task calls specified via the `deps` mapping of a task definition are executed concurrently, the multiple executions can conflict with each other and cause problems such as a spurious failure. This can be avoided by configuring tasks which may be called multiple times, and for which it never makes sense to execute multiple times with the same conditions, so that all but the first call will be ignored.
1 parent 3a310fa commit 91fdbe8

File tree

6 files changed

+9
-2
lines changed

6 files changed

+9
-2
lines changed

Taskfile.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ tasks:
143143
144144
# Check if ClangFormat is installed and the expected version
145145
clang-format:check-installed:
146+
run: when_changed
146147
vars:
147148
EXPECTED_CLANG_FORMAT_VERSION: "{{default .DEFAULT_CLANG_FORMAT_VERSION .CLANG_FORMAT_VERSION}}"
148149
cmds:
@@ -731,6 +732,7 @@ tasks:
731732
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/npm-task/Taskfile.yml
732733
npm:install-deps:
733734
desc: Install dependencies managed by npm
735+
run: when_changed
734736
dir: |
735737
"{{default "./" .PROJECT_PATH}}"
736738
cmds:
@@ -834,7 +836,7 @@ tasks:
834836
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
835837
poetry:install:
836838
desc: Install Poetry
837-
run: once
839+
run: when_changed
838840
cmds:
839841
- |
840842
if ! which yq &>/dev/null; then
@@ -887,6 +889,7 @@ tasks:
887889
Install dependencies managed by Poetry.
888890
Environment variable parameters:
889891
- POETRY_GROUPS: Poetry dependency groups to install (default: install all dependencies).
892+
run: when_changed
890893
deps:
891894
- task: poetry:install
892895
cmds:

workflow-templates/assets/check-markdown-task/Taskfile.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ version: "3"
44
tasks:
55
docs:generate:
66
desc: Create all generated documentation content
7+
run: when_changed
78
# This is an "umbrella" task used to call any documentation generation processes the project has.
89
# It can be left empty if there are none.
910

workflow-templates/assets/check-mkdocs-task/Taskfile.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ version: "3"
44
tasks:
55
docs:generate:
66
desc: Create all generated documentation content
7+
run: when_changed
78
# This is an "umbrella" task used to call any documentation generation processes the project has.
89
# It can be left empty if there are none.
910

workflow-templates/assets/deploy-cobra-mkdocs-versioned-poetry/Taskfile.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ tasks:
77
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/deploy-cobra-mkdocs-versioned-poetry/Taskfile.yml
88
docs:generate:
99
desc: Create all generated documentation content
10+
run: when_changed
1011
deps:
1112
- task: go:cli-docs
1213
cmds:

workflow-templates/assets/npm-task/Taskfile.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ tasks:
77
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/npm-task/Taskfile.yml
88
npm:install-deps:
99
desc: Install dependencies managed by npm
10+
run: when_changed
1011
dir: |
1112
"{{default "./" .PROJECT_PATH}}"
1213
cmds:

workflow-templates/assets/poetry-task/Taskfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ tasks:
55
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
66
poetry:install:
77
desc: Install Poetry
8-
run: once
8+
run: when_changed
99
cmds:
1010
- |
1111
if ! which yq &>/dev/null; then

0 commit comments

Comments
 (0)