Skip to content

Commit 77bb572

Browse files
committed
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` field 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.
1 parent f6a7bd0 commit 77bb572

11 files changed

+20
-48
lines changed

.github/workflows/check-action-metadata-task.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
name: Check Action Metadata
22

3-
env:
4-
# See: https://github.com/actions/setup-node/#readme
5-
NODE_VERSION: 20.x
6-
73
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
84
on:
95
push:
@@ -37,7 +33,7 @@ jobs:
3733
- name: Setup Node.js
3834
uses: actions/setup-node@v4
3935
with:
40-
node-version: ${{ env.NODE_VERSION }}
36+
node-version-file: package.json
4137

4238
- name: Install Task
4339
uses: arduino/setup-task@v2

.github/workflows/check-markdown-task.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-markdown-task.md
22
name: Check Markdown
33

4-
env:
5-
# See: https://github.com/actions/setup-node/#readme
6-
NODE_VERSION: 16.x
7-
84
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
95
on:
106
push:
@@ -48,7 +44,7 @@ jobs:
4844
- name: Setup Node.js
4945
uses: actions/setup-node@v4
5046
with:
51-
node-version: ${{ env.NODE_VERSION }}
47+
node-version-file: package.json
5248

5349
- name: Initialize markdownlint-cli problem matcher
5450
uses: xt0rted/markdownlint-problem-matcher@v3
@@ -72,7 +68,7 @@ jobs:
7268
- name: Setup Node.js
7369
uses: actions/setup-node@v4
7470
with:
75-
node-version: ${{ env.NODE_VERSION }}
71+
node-version-file: package.json
7672

7773
- name: Install Task
7874
uses: arduino/setup-task@v2

.github/workflows/check-npm-dependencies-task.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-npm-dependencies-task.md
22
name: Check npm Dependencies
33

4-
env:
5-
# See: https://github.com/actions/setup-node/#readme
6-
NODE_VERSION: 20.x
7-
84
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
95
on:
106
create:
@@ -78,7 +74,7 @@ jobs:
7874
- name: Setup Node.js
7975
uses: actions/setup-node@v4
8076
with:
81-
node-version: ${{ env.NODE_VERSION }}
77+
node-version-file: package.json
8278

8379
- name: Install Task
8480
uses: arduino/setup-task@v2
@@ -128,7 +124,7 @@ jobs:
128124
- name: Setup Node.js
129125
uses: actions/setup-node@v4
130126
with:
131-
node-version: ${{ env.NODE_VERSION }}
127+
node-version-file: package.json
132128

133129
- name: Install Task
134130
uses: arduino/setup-task@v2

.github/workflows/check-npm-task.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-npm-task.md
22
name: Check npm
33

4-
env:
5-
# See: https://github.com/actions/setup-node/#readme
6-
NODE_VERSION: 16.x
7-
84
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
95
on:
106
push:
@@ -39,7 +35,7 @@ jobs:
3935
- name: Setup Node.js
4036
uses: actions/setup-node@v4
4137
with:
42-
node-version: ${{ env.NODE_VERSION }}
38+
node-version-file: package.json
4339

4440
- name: Install Task
4541
uses: arduino/setup-task@v2
@@ -60,7 +56,7 @@ jobs:
6056
- name: Setup Node.js
6157
uses: actions/setup-node@v4
6258
with:
63-
node-version: ${{ env.NODE_VERSION }}
59+
node-version-file: package.json
6460

6561
- name: Install Task
6662
uses: arduino/setup-task@v2

.github/workflows/check-prettier-formatting-task.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-prettier-formatting-task.md
22
name: Check Prettier Formatting
33

4-
env:
5-
# See: https://github.com/actions/setup-node/#readme
6-
NODE_VERSION: 20.x
7-
84
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
95
on:
106
push:
@@ -213,7 +209,7 @@ jobs:
213209
- name: Setup Node.js
214210
uses: actions/setup-node@v4
215211
with:
216-
node-version: ${{ env.NODE_VERSION }}
212+
node-version-file: package.json
217213

218214
- name: Install Task
219215
uses: arduino/setup-task@v2

.github/workflows/check-tsconfig-task.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
name: Check TypeScript Configuration
22

3-
env:
4-
# See: https://github.com/actions/setup-node/#readme
5-
NODE_VERSION: 16.x
6-
73
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
84
on:
95
push:
@@ -45,7 +41,7 @@ jobs:
4541
- name: Setup Node.js
4642
uses: actions/setup-node@v4
4743
with:
48-
node-version: ${{ env.NODE_VERSION }}
44+
node-version-file: package.json
4945

5046
- name: Install Task
5147
uses: arduino/setup-task@v2

.github/workflows/check-typescript-task.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
name: Check TypeScript
22

3-
env:
4-
# See: https://github.com/actions/setup-node/#readme
5-
NODE_VERSION: 20.x
6-
73
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
84
on:
95
push:
@@ -51,7 +47,7 @@ jobs:
5147
- name: Setup Node.js
5248
uses: actions/setup-node@v4
5349
with:
54-
node-version: ${{ env.NODE_VERSION }}
50+
node-version-file: package.json
5551

5652
- name: Install Task
5753
uses: arduino/setup-task@v2

.github/workflows/sync-labels-npm.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
name: Sync Labels
33

44
env:
5-
# See: https://github.com/actions/setup-node/#readme
6-
NODE_VERSION: 16.x
75
CONFIGURATIONS_FOLDER: .github/label-configuration-files
86
CONFIGURATIONS_ARTIFACT: label-configuration-files
97

@@ -38,7 +36,7 @@ jobs:
3836
- name: Setup Node.js
3937
uses: actions/setup-node@v4
4038
with:
41-
node-version: ${{ env.NODE_VERSION }}
39+
node-version-file: package.json
4240

4341
- name: Download JSON schema for labels configuration file
4442
id: download-schema
@@ -132,7 +130,7 @@ jobs:
132130
- name: Setup Node.js
133131
uses: actions/setup-node@v4
134132
with:
135-
node-version: ${{ env.NODE_VERSION }}
133+
node-version-file: package.json
136134

137135
- name: Merge label configuration files
138136
run: |

.github/workflows/test-typescript-task.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
name: Test TypeScript
22

3-
env:
4-
# See: https://github.com/actions/setup-node/#readme
5-
NODE_VERSION: 20.x
6-
73
on:
84
push:
95
paths:
@@ -54,7 +50,7 @@ jobs:
5450
- name: Setup Node.js
5551
uses: actions/setup-node@v4
5652
with:
57-
node-version: ${{ env.NODE_VERSION }}
53+
node-version-file: package.json
5854

5955
- name: Install Task
6056
uses: arduino/setup-task@v2
@@ -75,7 +71,7 @@ jobs:
7571
- name: Setup Node.js
7672
uses: actions/setup-node@v4
7773
with:
78-
node-version: ${{ env.NODE_VERSION }}
74+
node-version-file: package.json
7975

8076
- name: Install Task
8177
uses: arduino/setup-task@v2

package-lock.json

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,8 @@
4646
"strip-json-comments-cli": "^3.0.0",
4747
"ts-jest": "^28.0.8",
4848
"typescript": "^5.5.4"
49+
},
50+
"engines": {
51+
"node": "20.x"
4952
}
5053
}

0 commit comments

Comments
 (0)