From e2c148b488c92588761069295b9da1ac5271e9e4 Mon Sep 17 00:00:00 2001 From: per1234 Date: Fri, 13 Jun 2025 22:40:21 -0700 Subject: [PATCH] Use `engines.node` as source of version data for "actions/setup-node" action The "actions/setup-node" GitHub Actions action is used to set up Node.js in the GitHub Actions runner machine. The action supports obtaining the Node.js version to set up from the `engines.node` key of the package.json file. This allows us to define the standardized version of Node.js for use by project contributors in a single place rather than having to maintain multiple instances of that data. --- .github/workflows/check-clang-format.yml | 8 ++----- .github/workflows/check-eslint.yml | 6 +---- .github/workflows/check-javascript-task.yml | 6 +---- .github/workflows/check-markdown-task.yml | 8 ++----- .github/workflows/check-npm-task.yml | 8 ++----- .../check-prettier-formatting-task.yml | 6 +---- .github/workflows/check-taskfiles.yml | 6 +---- .github/workflows/check-workflows-task.yml | 6 +---- .github/workflows/sync-labels-npm.yml | 14 +++++------- docs/development.md | 3 +-- package-lock.json | 3 +++ package.json | 3 +++ .../check-action-metadata-task.md | 12 ++++++---- .../check-action-metadata-task.yml | 6 +---- workflow-templates/check-javascript-task.md | 12 ++++++---- workflow-templates/check-javascript-task.yml | 6 +---- workflow-templates/check-markdown-task.md | 8 +++++-- workflow-templates/check-markdown-task.yml | 8 ++----- .../check-npm-dependencies-task.md | 20 ++++++++++++----- .../check-npm-dependencies-task.yml | 8 ++----- workflow-templates/check-npm-task.md | 12 +++++++++- workflow-templates/check-npm-task.yml | 8 ++----- .../check-prettier-formatting-task.md | 8 +++++-- .../check-prettier-formatting-task.yml | 6 +---- workflow-templates/check-taskfiles.md | 10 +++++++-- workflow-templates/check-taskfiles.yml | 6 +---- workflow-templates/check-toc-task.md | 10 +++++++-- workflow-templates/check-toc-task.yml | 6 +---- workflow-templates/check-workflows-task.md | 12 ++++++---- workflow-templates/check-workflows-task.yml | 6 +---- workflow-templates/sync-labels-npm.md | 22 ++++++++++++++----- workflow-templates/sync-labels-npm.yml | 14 +++++------- 32 files changed, 136 insertions(+), 141 deletions(-) diff --git a/.github/workflows/check-clang-format.yml b/.github/workflows/check-clang-format.yml index c7217f4d..eb0ee7e7 100644 --- a/.github/workflows/check-clang-format.yml +++ b/.github/workflows/check-clang-format.yml @@ -1,9 +1,5 @@ name: Check ClangFormat Configuration -env: - # See: https://github.com/actions/setup-node/#readme - NODE_VERSION: 16.x - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: push: @@ -48,7 +44,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Install Task uses: arduino/setup-task@v2 @@ -229,7 +225,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Install Task uses: arduino/setup-task@v2 diff --git a/.github/workflows/check-eslint.yml b/.github/workflows/check-eslint.yml index 2a5cd32c..1f81f371 100644 --- a/.github/workflows/check-eslint.yml +++ b/.github/workflows/check-eslint.yml @@ -1,9 +1,5 @@ name: Check ESLint Configuration -env: - # See: https://github.com/actions/setup-node/#readme - NODE_VERSION: 16.x - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: push: @@ -38,7 +34,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Install Task uses: arduino/setup-task@v2 diff --git a/.github/workflows/check-javascript-task.yml b/.github/workflows/check-javascript-task.yml index 33e62181..707ff99a 100644 --- a/.github/workflows/check-javascript-task.yml +++ b/.github/workflows/check-javascript-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-javascript-task.md name: Check JavaScript -env: - # See: https://github.com/actions/setup-node/#readme - NODE_VERSION: 16.x - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -68,7 +64,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Install Task uses: arduino/setup-task@v2 diff --git a/.github/workflows/check-markdown-task.yml b/.github/workflows/check-markdown-task.yml index 5e7c5a0c..16c52721 100644 --- a/.github/workflows/check-markdown-task.yml +++ b/.github/workflows/check-markdown-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-markdown-task.md name: Check Markdown -env: - # See: https://github.com/actions/setup-node/#readme - NODE_VERSION: 16.x - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -77,7 +73,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Initialize markdownlint-cli problem matcher uses: xt0rted/markdownlint-problem-matcher@v3 @@ -105,7 +101,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Install Task uses: arduino/setup-task@v2 diff --git a/.github/workflows/check-npm-task.yml b/.github/workflows/check-npm-task.yml index f968557a..746144d5 100644 --- a/.github/workflows/check-npm-task.yml +++ b/.github/workflows/check-npm-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-npm-task.md name: Check npm -env: - # See: https://github.com/actions/setup-node/#readme - NODE_VERSION: 16.x - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -73,7 +69,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Install Task uses: arduino/setup-task@v2 @@ -106,7 +102,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: "${{ matrix.project.path }}/package.json" - name: Install Task uses: arduino/setup-task@v2 diff --git a/.github/workflows/check-prettier-formatting-task.yml b/.github/workflows/check-prettier-formatting-task.yml index 53a28efa..f3ef0ec8 100644 --- a/.github/workflows/check-prettier-formatting-task.yml +++ b/.github/workflows/check-prettier-formatting-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-prettier-formatting-task.md name: Check Prettier Formatting -env: - # See: https://github.com/actions/setup-node/#readme - NODE_VERSION: 16.x - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -245,7 +241,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Install Task uses: arduino/setup-task@v2 diff --git a/.github/workflows/check-taskfiles.yml b/.github/workflows/check-taskfiles.yml index d9cdec35..262cbbbc 100644 --- a/.github/workflows/check-taskfiles.yml +++ b/.github/workflows/check-taskfiles.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-taskfiles.md name: Check Taskfiles -env: - # See: https://github.com/actions/setup-node/#readme - NODE_VERSION: 16.x - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -74,7 +70,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Download JSON schema for Taskfiles id: download-schema diff --git a/.github/workflows/check-workflows-task.yml b/.github/workflows/check-workflows-task.yml index f36bd658..1fbeb4d6 100644 --- a/.github/workflows/check-workflows-task.yml +++ b/.github/workflows/check-workflows-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-workflows-task.md name: Check Workflows -env: - # See: https://github.com/actions/setup-node/#readme - NODE_VERSION: 16.x - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: push: @@ -36,7 +32,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Install Task uses: arduino/setup-task@v2 diff --git a/.github/workflows/sync-labels-npm.yml b/.github/workflows/sync-labels-npm.yml index 857371dd..096d1f09 100644 --- a/.github/workflows/sync-labels-npm.yml +++ b/.github/workflows/sync-labels-npm.yml @@ -1,12 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels-npm.md name: Sync Labels -env: - # See: https://github.com/actions/setup-node/#readme - NODE_VERSION: 16.x - CONFIGURATIONS_FOLDER: .github/label-configuration-files - CONFIGURATIONS_ARTIFACT_PREFIX: label-configuration-file- - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: push: @@ -27,6 +21,10 @@ on: workflow_dispatch: repository_dispatch: +env: + CONFIGURATIONS_FOLDER: .github/label-configuration-files + CONFIGURATIONS_ARTIFACT_PREFIX: label-configuration-file- + jobs: check: runs-on: ubuntu-latest @@ -40,7 +38,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Download JSON schema for labels configuration file id: download-schema @@ -136,7 +134,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Merge label configuration files run: | diff --git a/docs/development.md b/docs/development.md index b0a5ccc7..78580b2f 100644 --- a/docs/development.md +++ b/docs/development.md @@ -7,8 +7,7 @@ The following development tools must be available in your local environment: - [**Node.js** / **npm**](https://nodejs.org/en/download/) - Node.js dependencies management tool - - - This project uses Node.js 16.x + - The **Node.js** version in use is defined by the `engines.node` key of [`package.json`](../package.json). - [**Python**](https://wiki.python.org/moin/BeginnersGuide/Download) - This project uses Python 3.9.x diff --git a/package-lock.json b/package-lock.json index a8c5ad73..5e42b2c5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,9 @@ "markdown-link-check": "^3.13.7", "markdownlint-cli": "^0.37.0", "prettier": "^3.5.3" + }, + "engines": { + "node": "16.x" } }, "node_modules/@aashutoshrathi/word-wrap": { diff --git a/package.json b/package.json index f56266b1..0a197724 100644 --- a/package.json +++ b/package.json @@ -13,5 +13,8 @@ }, "dependencies": { "js-yaml": "^4.1.0" + }, + "engines": { + "node": "16.x" } } diff --git a/workflow-templates/check-action-metadata-task.md b/workflow-templates/check-action-metadata-task.md index 40450f9d..fce85ad8 100644 --- a/workflow-templates/check-action-metadata-task.md +++ b/workflow-templates/check-action-metadata-task.md @@ -33,10 +33,6 @@ Commit the resulting changes to the `package.json` and `package-lock.json` files ### Configuration -#### Workflow - -Configure the version of **Node.js** used for development of the project in the `env.NODE_VERSION` field of `check-action-metadata-task.yml`. - #### `.gitignore` Add the following to [`/.gitignore`](https://git-scm.com/docs/gitignore): @@ -45,6 +41,14 @@ Add the following to [`/.gitignore`](https://git-scm.com/docs/gitignore): /node_modules/ ``` +#### Node.js + +Configure the version of [**Node.js**](https://nodejs.org) used for development of the project by running the following command from a terminal in the project repository folder: + +```text +npm pkg set engines.node=16.x +``` + ### Readme badge Markdown badge: diff --git a/workflow-templates/check-action-metadata-task.yml b/workflow-templates/check-action-metadata-task.yml index 07ab3131..b02460b4 100644 --- a/workflow-templates/check-action-metadata-task.yml +++ b/workflow-templates/check-action-metadata-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-action-metadata-task.md name: Check Action Metadata -env: - # See: https://github.com/actions/setup-node/#readme - NODE_VERSION: 16.x - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -67,7 +63,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Install Task uses: arduino/setup-task@v2 diff --git a/workflow-templates/check-javascript-task.md b/workflow-templates/check-javascript-task.md index 5404071e..6deeb141 100644 --- a/workflow-templates/check-javascript-task.md +++ b/workflow-templates/check-javascript-task.md @@ -39,10 +39,6 @@ Commit the resulting changes to the `package.json` and `package-lock.json` files ### Configuration -#### Workflow - -Configure the version of [**Node.js**](https://nodejs.org) used for development of the project in the `env.NODE_VERSION` field of `check-javascript-task.yml`. - #### `.gitignore` Add the following to [`/.gitignore`](https://git-scm.com/docs/gitignore): @@ -51,6 +47,14 @@ Add the following to [`/.gitignore`](https://git-scm.com/docs/gitignore): /node_modules/ ``` +#### Node.js + +Configure the version of [**Node.js**](https://nodejs.org) used for development of the project by running the following command from a terminal in the project repository folder: + +```text +npm pkg set engines.node=16.x +``` + ### Readme badge Markdown badge: diff --git a/workflow-templates/check-javascript-task.yml b/workflow-templates/check-javascript-task.yml index 33e62181..707ff99a 100644 --- a/workflow-templates/check-javascript-task.yml +++ b/workflow-templates/check-javascript-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-javascript-task.md name: Check JavaScript -env: - # See: https://github.com/actions/setup-node/#readme - NODE_VERSION: 16.x - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -68,7 +64,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Install Task uses: arduino/setup-task@v2 diff --git a/workflow-templates/check-markdown-task.md b/workflow-templates/check-markdown-task.md index bbb5ecb4..5393b353 100644 --- a/workflow-templates/check-markdown-task.md +++ b/workflow-templates/check-markdown-task.md @@ -44,9 +44,13 @@ Commit the resulting changes to the `package.json` and `package-lock.json` files ### Configuration -#### Workflow +#### Node.js -Configure the version of Node.js used for development of the project in the `env.NODE_VERSION` field of `check-markdown-task.yml`. +Configure the version of [**Node.js**](https://nodejs.org) used for development of the project by running the following command from a terminal in the project repository folder: + +```text +npm pkg set engines.node=16.x +``` #### Taskfile diff --git a/workflow-templates/check-markdown-task.yml b/workflow-templates/check-markdown-task.yml index 5e7c5a0c..16c52721 100644 --- a/workflow-templates/check-markdown-task.yml +++ b/workflow-templates/check-markdown-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-markdown-task.md name: Check Markdown -env: - # See: https://github.com/actions/setup-node/#readme - NODE_VERSION: 16.x - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -77,7 +73,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Initialize markdownlint-cli problem matcher uses: xt0rted/markdownlint-problem-matcher@v3 @@ -105,7 +101,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Install Task uses: arduino/setup-task@v2 diff --git a/workflow-templates/check-npm-dependencies-task.md b/workflow-templates/check-npm-dependencies-task.md index a7d5d1b7..bc1aa5ce 100644 --- a/workflow-templates/check-npm-dependencies-task.md +++ b/workflow-templates/check-npm-dependencies-task.md @@ -28,15 +28,17 @@ Install the [`check-npm-dependencies-task.yml`](check-npm-dependencies-task.yml) ### Configuration +#### Licensed + The **Licensed** tool is configured via `.licensed.yml` configuration file, located in the repository root folder: https://github.com/github/licensed/blob/main/docs/configuration.md -#### Project paths +##### Project paths By default, the project in the root of the repository will be checked. If the project is in a subfolder of the repository or if the repository contains multiple projects with dependencies that should be checked then the path to each project should be defined via [`apps[*].source_path` keys](https://github.com/github/licensed/blob/main/docs/configuration/application_source.md#application-source-path) in `.licensed.yml`. -#### Allowed licenses +##### Allowed licenses A list of [allowed license types](https://github.com/github/licensed/blob/main/docs/configuration/allowed_licenses.md) can be defined in the `.licensed.yml` configuration file under: @@ -47,7 +49,7 @@ All dependencies that are determined to use one of these licenses will be automa [SPDX license identifiers](https://spdx.org/licenses/) are used, except converted to all lowercase letters (e.g., use `gpl-3.0-or-later` for the "**GPL 3.0 (or later)**" license). -#### Metadata cache +##### Metadata cache Dependency license metadata is stored in the `.licenses` folder. This should be committed to the repository. Generate or update the cache by running this command: @@ -57,13 +59,13 @@ task general:cache-dep-licenses Alternatively, you can download the `dep-licenses-cache` [workflow artifact](https://docs.github.com/actions/managing-workflow-runs/downloading-workflow-artifacts) that is generated by the "Check Go Dependencies" workflow run when the cache is found to be outdated by the workflow's "check-cache" job. -#### Unrecognized licenses +##### Unrecognized licenses **Licensed** uses the [**licensee**](https://github.com/licensee/licensee) tool to automatically detect the license type of the dependency. This will not be possible if a dependency author has not documented the license in a standardized fashion. In this case, the dependency licensing must be manually reviewed. [**licensee**](https://github.com/licensee/licensee) is a useful tool for this manual review process (use `licensee --diff`). Once the license type has been determined, find the dependency's metadata file under the `.licenses` folder and update its `license` key with the [SPDX license identifier](https://spdx.org/licenses/) of the dependency's license, converted to all lowercase letters. If the file containing the license was not found by **Licensed**, define its path in the `licenses[*].sources` key and add the text of the license in `licenses[*].text`. This will allow **Licensed** to check if the license has changed when the dependency version is updated. -#### Reviewed dependencies +##### Reviewed dependencies A dependency might use a license type that can not be allowed globally via the `allowed` key of the `.licensed.yml` configuration file, but that is determined to be acceptable for that specific dependency. @@ -90,6 +92,14 @@ ignore: | /.licenses/ ``` +#### Node.js + +Configure the version of [**Node.js**](https://nodejs.org) used for development of the project by running the following command from a terminal in the project repository folder: + +```text +npm pkg set engines.node=16.x +``` + ### Documentation #### Readme badge diff --git a/workflow-templates/check-npm-dependencies-task.yml b/workflow-templates/check-npm-dependencies-task.yml index 58a49f87..d3849740 100644 --- a/workflow-templates/check-npm-dependencies-task.yml +++ b/workflow-templates/check-npm-dependencies-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-npm-dependencies-task.md name: Check npm Dependencies -env: - # See: https://github.com/actions/setup-node/#readme - NODE_VERSION: 16.x - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -87,7 +83,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Install Task uses: arduino/setup-task@v2 @@ -146,7 +142,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Install Task uses: arduino/setup-task@v2 diff --git a/workflow-templates/check-npm-task.md b/workflow-templates/check-npm-task.md index 3095e690..40860040 100644 --- a/workflow-templates/check-npm-task.md +++ b/workflow-templates/check-npm-task.md @@ -21,7 +21,17 @@ Install the [check-npm-task.yml](check-npm-task.yml) GitHub Actions workflow to ### Configuration -Configure the version of Node.js used for development of the project in the `env.NODE_VERSION` field of `check-npm-task.yml`. +#### Node.js + +Configure the version of [**Node.js**](https://nodejs.org) used for development of the project by running the following command from a terminal in the project repository folder: + +```text +npm pkg set engines.node=16.x +``` + +If the project contains **npm**-managed projects (i.e., a folder containing a `package.json` file) in paths other than the root of the repository, run the command again from each of those paths. + +#### Workflow If the project contains **npm**-managed projects (i.e., a folder containing a `package.json` file) in paths other than the root of the repository, add their paths to the [job matrices](https://docs.github.com/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix) of `check-npm-task.yml` at: diff --git a/workflow-templates/check-npm-task.yml b/workflow-templates/check-npm-task.yml index f968557a..746144d5 100644 --- a/workflow-templates/check-npm-task.yml +++ b/workflow-templates/check-npm-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-npm-task.md name: Check npm -env: - # See: https://github.com/actions/setup-node/#readme - NODE_VERSION: 16.x - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -73,7 +69,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Install Task uses: arduino/setup-task@v2 @@ -106,7 +102,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: "${{ matrix.project.path }}/package.json" - name: Install Task uses: arduino/setup-task@v2 diff --git a/workflow-templates/check-prettier-formatting-task.md b/workflow-templates/check-prettier-formatting-task.md index 62d6ab81..8ed0a9ad 100644 --- a/workflow-templates/check-prettier-formatting-task.md +++ b/workflow-templates/check-prettier-formatting-task.md @@ -41,9 +41,13 @@ Commit the resulting changes to the `package.json` and `package-lock.json` files ### Configuration -#### Workflow +#### Node.js -Configure the version of Node.js used for development of the project in the `env.NODE_VERSION` field of `check-prettier-formatting-task.yml`. +Configure the version of [**Node.js**](https://nodejs.org) used for development of the project by running the following command from a terminal in the project repository folder: + +```text +npm pkg set engines.node=16.x +``` #### Prettier diff --git a/workflow-templates/check-prettier-formatting-task.yml b/workflow-templates/check-prettier-formatting-task.yml index 53a28efa..f3ef0ec8 100644 --- a/workflow-templates/check-prettier-formatting-task.yml +++ b/workflow-templates/check-prettier-formatting-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-prettier-formatting-task.md name: Check Prettier Formatting -env: - # See: https://github.com/actions/setup-node/#readme - NODE_VERSION: 16.x - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -245,7 +241,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Install Task uses: arduino/setup-task@v2 diff --git a/workflow-templates/check-taskfiles.md b/workflow-templates/check-taskfiles.md index 58785376..deb20ac4 100644 --- a/workflow-templates/check-taskfiles.md +++ b/workflow-templates/check-taskfiles.md @@ -22,6 +22,14 @@ Commit the resulting changes to the `package.json` and `package-lock.json` files ### Configuration +#### Node.js + +Configure the version of [**Node.js**](https://nodejs.org) used for development of the project by running the following command from a terminal in the project repository folder: + +```text +npm pkg set engines.node=16.x +``` + #### Workflow The workflow is configured to check all files named `Taskfile.yml` in the repository. If there are additional taskfiles, add them to the following fields in `check-taskfiles.yml`: @@ -30,8 +38,6 @@ The workflow is configured to check all files named `Taskfile.yml` in the reposi - `on.pull_request.paths` - `jobs.validate.strategy.matrix.file[]` -Configure the version of Node.js used for development of the project in the `env.NODE_VERSION` field of `check-taskfiles.yml`. - #### `.gitignore` Add the following to [`/.gitignore`](https://git-scm.com/docs/gitignore): diff --git a/workflow-templates/check-taskfiles.yml b/workflow-templates/check-taskfiles.yml index d9cdec35..262cbbbc 100644 --- a/workflow-templates/check-taskfiles.yml +++ b/workflow-templates/check-taskfiles.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-taskfiles.md name: Check Taskfiles -env: - # See: https://github.com/actions/setup-node/#readme - NODE_VERSION: 16.x - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -74,7 +70,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Download JSON schema for Taskfiles id: download-schema diff --git a/workflow-templates/check-toc-task.md b/workflow-templates/check-toc-task.md index c49102f6..413762f9 100644 --- a/workflow-templates/check-toc-task.md +++ b/workflow-templates/check-toc-task.md @@ -33,6 +33,14 @@ Commit the resulting changes to the `package.json` and `package-lock.json` files ### Configuration +#### Node.js + +Configure the version of [**Node.js**](https://nodejs.org) used for development of the project by running the following command from a terminal in the project repository folder: + +```text +npm pkg set engines.node=16.x +``` + #### Workflow The workflow is configured to check a table of contents in `README.md`. If other files have a table of contents, adjust the following fields in `check-toc-task.yml`: @@ -41,8 +49,6 @@ The workflow is configured to check a table of contents in `README.md`. If other - `on.pull_request.paths` - `jobs.check.strategy.matrix.file[]` -Configure the version of Node.js used for development of the project in the `env.NODE_VERSION` field of `check-toc-task.yml`. - #### `.gitignore` Add the following to [`/.gitignore`](https://git-scm.com/docs/gitignore): diff --git a/workflow-templates/check-toc-task.yml b/workflow-templates/check-toc-task.yml index c137a4b1..4698a697 100644 --- a/workflow-templates/check-toc-task.yml +++ b/workflow-templates/check-toc-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-toc-task.md name: Check ToC -env: - # See: https://github.com/actions/setup-node/#readme - NODE_VERSION: 16.x - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -78,7 +74,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Install Task uses: arduino/setup-task@v2 diff --git a/workflow-templates/check-workflows-task.md b/workflow-templates/check-workflows-task.md index 2e01120c..e7a8ef9f 100644 --- a/workflow-templates/check-workflows-task.md +++ b/workflow-templates/check-workflows-task.md @@ -33,10 +33,6 @@ Commit the resulting changes to the `package.json` and `package-lock.json` files ### Configuration -#### Workflow - -Configure the version of Node.js used for development of the project in the `env.NODE_VERSION` field of `check-workflows-task.yml`. - #### `.gitignore` Add the following to [`/.gitignore`](https://git-scm.com/docs/gitignore): @@ -45,6 +41,14 @@ Add the following to [`/.gitignore`](https://git-scm.com/docs/gitignore): /node_modules/ ``` +#### Node.js + +Configure the version of [**Node.js**](https://nodejs.org) used for development of the project by running the following command from a terminal in the project repository folder: + +```text +npm pkg set engines.node=16.x +``` + ### Readme badge Markdown badge: diff --git a/workflow-templates/check-workflows-task.yml b/workflow-templates/check-workflows-task.yml index 8b9fa433..3fff4c8c 100644 --- a/workflow-templates/check-workflows-task.yml +++ b/workflow-templates/check-workflows-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-workflows-task.md name: Check Workflows -env: - # See: https://github.com/actions/setup-node/#readme - NODE_VERSION: 16.x - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: push: @@ -38,7 +34,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Install Task uses: arduino/setup-task@v2 diff --git a/workflow-templates/sync-labels-npm.md b/workflow-templates/sync-labels-npm.md index 6960229c..c76ff054 100644 --- a/workflow-templates/sync-labels-npm.md +++ b/workflow-templates/sync-labels-npm.md @@ -29,11 +29,13 @@ Commit the resulting changes to the `package.json` and `package-lock.json` files ### Configuration +#### Labels + Multiple labels data files can be merged to form the list of labels for the repository. The [universal labels](assets/sync-labels/universal.yml) must be used in all repositories, but some projects will benefit from the addition of other domain-specific labels. The configuration file structure is documented here: https://github.com/Financial-Times/github-label-sync#label-config-file -#### Maximum string lengths +##### Maximum string lengths Label sync will fail with a `422: Validation Failed` error if a label configuration string exceeds the maximum length. @@ -41,7 +43,7 @@ Label sync will fail with a `422: Validation Failed` error if a label configurat - `description`: 100 - Note: `description` is truncated at ~45 (depending on width) characters in the labeling menu, so make sure the meaning of the label is clear to the maintainer from the visible subset of the description. -#### Standardized label colors +##### Standardized label colors These colors have good contrast. When possible, follow the conventions established in the universal labels for the general meaning associated the colors. @@ -60,22 +62,22 @@ These colors have good contrast. When possible, follow the conventions establish - `#ff00ff` - `#c0c0c0` -##### Notes +###### Notes - Remove the `#` from the hex color code before adding it to the `color` field of the labels definition file. - Black and white should not be used due to lacking contrast with the GitHub page background colors (light and dark themes). -#### Shared labels +##### Shared labels Configuration files for labels that are applicable to multiple projects are hosted [here](assets/sync-labels). Add the file name to the `jobs.download.strategy.matrix.filename[]` array in the workflow. -#### Project-specific labels +##### Project-specific labels The configuration file for labels that only apply to the specific project should be located in `.github/label-configuration-files/` -#### Configure `.gitignore` +#### `.gitignore` Add the following to `.gitignore`: @@ -83,6 +85,14 @@ Add the following to `.gitignore`: /node_modules/ ``` +#### Node.js + +Configure the version of [**Node.js**](https://nodejs.org) used for development of the project by running the following command from a terminal in the project repository folder: + +```text +npm pkg set engines.node=16.x +``` + ### Readme badge Markdown badge: diff --git a/workflow-templates/sync-labels-npm.yml b/workflow-templates/sync-labels-npm.yml index 857371dd..096d1f09 100644 --- a/workflow-templates/sync-labels-npm.yml +++ b/workflow-templates/sync-labels-npm.yml @@ -1,12 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels-npm.md name: Sync Labels -env: - # See: https://github.com/actions/setup-node/#readme - NODE_VERSION: 16.x - CONFIGURATIONS_FOLDER: .github/label-configuration-files - CONFIGURATIONS_ARTIFACT_PREFIX: label-configuration-file- - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: push: @@ -27,6 +21,10 @@ on: workflow_dispatch: repository_dispatch: +env: + CONFIGURATIONS_FOLDER: .github/label-configuration-files + CONFIGURATIONS_ARTIFACT_PREFIX: label-configuration-file- + jobs: check: runs-on: ubuntu-latest @@ -40,7 +38,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Download JSON schema for labels configuration file id: download-schema @@ -136,7 +134,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Merge label configuration files run: |