From 172b79ea66e247f15b6ef292b2394701c628496e Mon Sep 17 00:00:00 2001 From: per1234 Date: Tue, 23 Sep 2025 01:43:32 -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-markdown-task.yml | 8 ++------ .../workflows/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 ++++++-------- package-lock.json | 3 +++ package.json | 3 +++ 7 files changed, 17 insertions(+), 29 deletions(-) diff --git a/.github/workflows/check-markdown-task.yml b/.github/workflows/check-markdown-task.yml index 4adb7fd..bef3b76 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/using-workflows/events-that-trigger-workflows on: create: @@ -77,7 +73,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v5 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@v5 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-prettier-formatting-task.yml b/.github/workflows/check-prettier-formatting-task.yml index ea0cfd2..9f5285c 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/using-workflows/events-that-trigger-workflows on: create: @@ -242,7 +238,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v5 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 0820ac6..94fcfe6 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/using-workflows/events-that-trigger-workflows on: create: @@ -77,7 +73,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v5 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 cf67434..04f2fdc 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/using-workflows/events-that-trigger-workflows on: push: @@ -38,7 +34,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v5 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 bf77088..c631cdf 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/using-workflows/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@v5 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Download JSON schema for labels configuration file id: download-schema @@ -138,7 +136,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v5 with: - node-version: ${{ env.NODE_VERSION }} + node-version-file: package.json - name: Merge label configuration files run: | diff --git a/package-lock.json b/package-lock.json index e598b76..cd0605a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,9 @@ "markdown-link-check": "^3.13.7", "markdownlint-cli": "^0.37.0", "prettier": "^3.6.2" + }, + "engines": { + "node": "16.x" } }, "node_modules/@financial-times/origami-service-makefile": { diff --git a/package.json b/package.json index e1eb5a2..73d41ee 100644 --- a/package.json +++ b/package.json @@ -6,5 +6,8 @@ "markdown-link-check": "^3.13.7", "markdownlint-cli": "^0.37.0", "prettier": "^3.6.2" + }, + "engines": { + "node": "16.x" } }