From 4949c822a72bf6bbeb08ab9a74b1054b66e3dd3d Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 7 Sep 2025 19:53:21 -0700 Subject: [PATCH 1/2] Remove unnecessary recursive `.npmrc` coverage from workflow path filters For the sake of efficiency, GitHub Workflows should be configured to only be triggered when relevant files are modified. This filtering is done via the `paths` mapping. "Globstar" patterns are supported in paths filters. This will cause the filter to match the matching files in any path under the repository. Previously, this was done for the `.npmrc` npm configuration file in various workflows. Although this is appropriate in the "Check npm" workflow, which supports checking npm-based projects in subfolders of the repository, it is not appropriate for the other workflows which do not have such support (and likely don't need it). In order to improve the efficiency of the workflows, the globstars are removed from the `.npmrc` path filters in the workflows where it is not appropriate. --- .github/workflows/check-markdown-task.yml | 4 ++-- .github/workflows/check-prettier-formatting-task.yml | 4 ++-- .github/workflows/check-workflows-task.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check-markdown-task.yml b/.github/workflows/check-markdown-task.yml index 6f933806..92de9278 100644 --- a/.github/workflows/check-markdown-task.yml +++ b/.github/workflows/check-markdown-task.yml @@ -8,7 +8,7 @@ on: paths: - ".github/workflows/check-markdown-task.ya?ml" - ".markdown-link-check.json" - - "**/.npmrc" + - ".npmrc" - "package.json" - "package-lock.json" - "Taskfile.ya?ml" @@ -23,7 +23,7 @@ on: paths: - ".github/workflows/check-markdown-task.ya?ml" - ".markdown-link-check.json" - - "**/.npmrc" + - ".npmrc" - "package.json" - "package-lock.json" - "Taskfile.ya?ml" diff --git a/.github/workflows/check-prettier-formatting-task.yml b/.github/workflows/check-prettier-formatting-task.yml index 312eefb0..8e799df5 100644 --- a/.github/workflows/check-prettier-formatting-task.yml +++ b/.github/workflows/check-prettier-formatting-task.yml @@ -7,8 +7,8 @@ on: push: paths: - ".github/workflows/check-prettier-formatting-task.ya?ml" + - ".npmrc" - "Taskfile.ya?ml" - - "**/.npmrc" - "**/.prettierignore" - "**/.prettierrc*" # CSS @@ -111,8 +111,8 @@ on: pull_request: paths: - ".github/workflows/check-prettier-formatting-task.ya?ml" + - ".npmrc" - "Taskfile.ya?ml" - - "**/.npmrc" - "**/.prettierignore" - "**/.prettierrc*" # CSS diff --git a/.github/workflows/check-workflows-task.yml b/.github/workflows/check-workflows-task.yml index 6a9f8e75..0160deea 100644 --- a/.github/workflows/check-workflows-task.yml +++ b/.github/workflows/check-workflows-task.yml @@ -6,14 +6,14 @@ on: push: paths: - ".github/workflows/*.ya?ml" - - "**/.npmrc" + - ".npmrc" - "package.json" - "package-lock.json" - "Taskfile.ya?ml" pull_request: paths: - ".github/workflows/*.ya?ml" - - "**/.npmrc" + - ".npmrc" - "package.json" - "package-lock.json" - "Taskfile.ya?ml" From 2affc9291928513ee80b89373c9a34c4e2d5cdaa Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 7 Sep 2025 20:02:21 -0700 Subject: [PATCH 2/2] Make default npm project path configurable via taskfile variable A repository might contain multiple npm-managed projects. For this reason, the appropriate npm-managed tasks have a parameter environment variable that allows it to be configured for an arbitrary path, with the "Check npm" workflow having a job matrix of paths to pass. Generally, even if there are multiple npm-managed projects, there will be one primary project that is most often the target of contributor operation. Since it would be inconvenient for the contributor to pass the environment variable path every time they want to run a task for that primary project, the tasks are configured to have a default path which is used if the variable is not defined by the user. Since the primary npm-managed project would typically be in the root of the repository, the default value is set to the root. In the case where the primary npm-managed project is not in the root of the repository, the template installer will need to adjust this. Previously the default was hard coded in each individual task. The template will be made easier to install by defining the default in a single place via a friendly taskfile variable, following the convention already established by the templates for Go-based projects. --- Taskfile.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index 5e48e364..c883e084 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -5,6 +5,9 @@ includes: dist: ./DistTasks.yml vars: + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/npm-task/Taskfile.yml + # Path of the project's primary npm-managed project: + DEFAULT_NPM_PROJECT_PATH: . # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/release-go-task/Taskfile.yml PROJECT_NAME: "arduino-lint" DIST_DIR: "dist" @@ -155,6 +158,8 @@ tasks: WORKFLOWS_DATA_PATH: "./.github/workflows/*.{yml,yaml}" deps: - task: npm:install-deps + vars: + PROJECT_PATH: . cmds: - | wget \ @@ -248,6 +253,8 @@ tasks: desc: Format all supported files with Prettier deps: - task: npm:install-deps + vars: + PROJECT_PATH: . cmds: - | npx \ @@ -412,6 +419,8 @@ tasks: deps: - task: docs:generate - task: npm:install-deps + vars: + PROJECT_PATH: . cmds: - | npx \ @@ -423,6 +432,8 @@ tasks: desc: Automatically correct linting violations in Markdown files where possible deps: - task: npm:install-deps + vars: + PROJECT_PATH: . cmds: - | npx \ @@ -435,6 +446,8 @@ tasks: desc: Check for problems in Markdown files deps: - task: npm:install-deps + vars: + PROJECT_PATH: . cmds: - | npx \ @@ -447,7 +460,7 @@ tasks: npm:install-deps: desc: Install dependencies managed by npm dir: | - "{{default "./" .PROJECT_PATH}}" + "{{default .DEFAULT_NPM_PROJECT_PATH .PROJECT_PATH}}" cmds: - npm install @@ -498,7 +511,7 @@ tasks: STYLELINTRC_SCHEMA_PATH: sh: task utility:mktemp-file TEMPLATE="stylelintrc-schema-XXXXXXXXXX.json" INSTANCE_PATH: >- - {{default "." .PROJECT_PATH}}/package.json + {{default .DEFAULT_NPM_PROJECT_PATH .PROJECT_PATH}}/package.json PROJECT_FOLDER: sh: pwd WORKING_FOLDER: