From 3a310fa8cbd6cd63257b2d5ce2894fcee94dba0f Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 19 Jun 2025 17:53:36 -0700 Subject: [PATCH 1/2] Only install Python package dependencies from relevant group The "Poetry" tool is used to manage the project's Python package dependencies. Dependencies might be classified into distinct categories. The most basic classification would be: - Application dependencies: used by the project's applications - Development dependencies: tools used in the development and maintenance of the project, but not by the application By default, Poetry installs all non-optional dependencies. This can be inefficient in a case where a specific operation is being performed, since a given operation might only require the dependencies from one category and so the installation of dependencies from the other is pointless for that operation. For this reason, Poetry allows the user to organize dependencies into arbitrary "groups", and to specify which groups should be installed. The Python package installation task is hereby updated to allow dependency groups to be specified, and the calls to that task updated to specify the groups they require. --- Taskfile.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index b8fb74c3..c45a2cd9 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -883,11 +883,16 @@ tasks: # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml poetry:install-deps: - desc: Install dependencies managed by Poetry + desc: | + Install dependencies managed by Poetry. + Environment variable parameters: + - POETRY_GROUPS: Poetry dependency groups to install (default: install all dependencies). deps: - task: poetry:install cmds: - - poetry install --no-root + - | + poetry install \ + {{if .POETRY_GROUPS}} --only {{.POETRY_GROUPS}} {{end}} # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml poetry:update-deps: From 91fdbe87c8d5a6e8d3363d5ca195b6ff76e79f6d Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 19 Jun 2025 22:17:09 -0700 Subject: [PATCH 2/2] 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. --- Taskfile.yml | 5 ++++- workflow-templates/assets/check-markdown-task/Taskfile.yml | 1 + workflow-templates/assets/check-mkdocs-task/Taskfile.yml | 1 + .../assets/deploy-cobra-mkdocs-versioned-poetry/Taskfile.yml | 1 + workflow-templates/assets/npm-task/Taskfile.yml | 1 + workflow-templates/assets/poetry-task/Taskfile.yml | 2 +- 6 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index c45a2cd9..ded1df3a 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -143,6 +143,7 @@ tasks: # Check if ClangFormat is installed and the expected version clang-format:check-installed: + run: when_changed vars: EXPECTED_CLANG_FORMAT_VERSION: "{{default .DEFAULT_CLANG_FORMAT_VERSION .CLANG_FORMAT_VERSION}}" cmds: @@ -731,6 +732,7 @@ tasks: # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/npm-task/Taskfile.yml npm:install-deps: desc: Install dependencies managed by npm + run: when_changed dir: | "{{default "./" .PROJECT_PATH}}" cmds: @@ -834,7 +836,7 @@ tasks: # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml poetry:install: desc: Install Poetry - run: once + run: when_changed cmds: - | if ! which yq &>/dev/null; then @@ -887,6 +889,7 @@ tasks: Install dependencies managed by Poetry. Environment variable parameters: - POETRY_GROUPS: Poetry dependency groups to install (default: install all dependencies). + run: when_changed deps: - task: poetry:install cmds: diff --git a/workflow-templates/assets/check-markdown-task/Taskfile.yml b/workflow-templates/assets/check-markdown-task/Taskfile.yml index a968b975..5216f0dc 100644 --- a/workflow-templates/assets/check-markdown-task/Taskfile.yml +++ b/workflow-templates/assets/check-markdown-task/Taskfile.yml @@ -4,6 +4,7 @@ version: "3" tasks: docs:generate: desc: Create all generated documentation content + run: when_changed # This is an "umbrella" task used to call any documentation generation processes the project has. # It can be left empty if there are none. diff --git a/workflow-templates/assets/check-mkdocs-task/Taskfile.yml b/workflow-templates/assets/check-mkdocs-task/Taskfile.yml index e9b678bb..42fd5050 100644 --- a/workflow-templates/assets/check-mkdocs-task/Taskfile.yml +++ b/workflow-templates/assets/check-mkdocs-task/Taskfile.yml @@ -4,6 +4,7 @@ version: "3" tasks: docs:generate: desc: Create all generated documentation content + run: when_changed # This is an "umbrella" task used to call any documentation generation processes the project has. # It can be left empty if there are none. diff --git a/workflow-templates/assets/deploy-cobra-mkdocs-versioned-poetry/Taskfile.yml b/workflow-templates/assets/deploy-cobra-mkdocs-versioned-poetry/Taskfile.yml index bbd6a350..5d22935f 100644 --- a/workflow-templates/assets/deploy-cobra-mkdocs-versioned-poetry/Taskfile.yml +++ b/workflow-templates/assets/deploy-cobra-mkdocs-versioned-poetry/Taskfile.yml @@ -7,6 +7,7 @@ tasks: # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/deploy-cobra-mkdocs-versioned-poetry/Taskfile.yml docs:generate: desc: Create all generated documentation content + run: when_changed deps: - task: go:cli-docs cmds: diff --git a/workflow-templates/assets/npm-task/Taskfile.yml b/workflow-templates/assets/npm-task/Taskfile.yml index 0d28ec97..810ec9a6 100644 --- a/workflow-templates/assets/npm-task/Taskfile.yml +++ b/workflow-templates/assets/npm-task/Taskfile.yml @@ -7,6 +7,7 @@ tasks: # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/npm-task/Taskfile.yml npm:install-deps: desc: Install dependencies managed by npm + run: when_changed dir: | "{{default "./" .PROJECT_PATH}}" cmds: diff --git a/workflow-templates/assets/poetry-task/Taskfile.yml b/workflow-templates/assets/poetry-task/Taskfile.yml index 4b9e1e87..c3914122 100644 --- a/workflow-templates/assets/poetry-task/Taskfile.yml +++ b/workflow-templates/assets/poetry-task/Taskfile.yml @@ -5,7 +5,7 @@ tasks: # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml poetry:install: desc: Install Poetry - run: once + run: when_changed cmds: - | if ! which yq &>/dev/null; then