Skip to content

Commit 40b6641

Browse files
authored
feat: source Node version from package.json#engines (#66)
1 parent 231f304 commit 40b6641

5 files changed

Lines changed: 12 additions & 11 deletions

File tree

.github/actions/install-dependencies/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: |
77
88
inputs:
99
node-version:
10-
description: "Explicit node version. Otherwise fallback reading `.nvmrc`"
10+
description: "Explicit node version. Otherwise fallback reading `engines.node` in `package.json`"
1111

1212
runs:
1313
using: composite
@@ -24,11 +24,11 @@ runs:
2424
cache: "pnpm"
2525
registry-url: "https://registry.npmjs.org"
2626

27-
- name: Setup Node.js (via .nvmrc)
27+
- name: Setup Node.js (via package.json engines)
2828
if: ${{ !inputs.node-version }}
2929
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
3030
with:
31-
node-version-file: ".nvmrc"
31+
node-version-file: "package.json"
3232
cache: "pnpm"
3333
registry-url: "https://registry.npmjs.org"
3434

.github/workflows/ci.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ permissions: {}
1717

1818
jobs:
1919
test:
20-
name: Test ${{ matrix.node }} on ${{ matrix.os }}
20+
name: Test on ${{ matrix.os }}
2121

2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
node: [24]
2625
os: [ubuntu-latest, macos-latest]
2726
runs-on: ${{ matrix.os }}
2827

@@ -35,8 +34,6 @@ jobs:
3534

3635
- name: Install Dependencies
3736
uses: ./.github/actions/install-dependencies
38-
with:
39-
node-version: ${{ matrix.node }}
4037

4138
- name: Run E2E tests
4239
run: pnpm run test

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
# Source of truth: package.json engines.node — keep this file aligned
12
24

action.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,21 @@ outputs:
2828
runs:
2929
using: composite
3030
steps:
31-
- name: Resolve relative path to package.json
31+
# pnpm/action-setup's `package_json_file` and setup-node's `node-version-file` are both
32+
# resolved relative to $GITHUB_WORKSPACE, but our package.json lives under
33+
# ${{ github.action_path }} — convert to a workspace-relative path.
34+
- name: Compute workspace-relative package.json path
3235
id: resolve_path
3336
run: echo "package_json=$(realpath --relative-to="$GITHUB_WORKSPACE" "${{ github.action_path }}/package.json")" >> "$GITHUB_OUTPUT"
3437
shell: bash
3538
- name: Install pnpm
36-
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
39+
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
3740
with:
3841
package_json_file: ${{ steps.resolve_path.outputs.package_json }}
3942
- name: Setup Node.js
4043
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
4144
with:
42-
node-version: "24"
45+
node-version-file: ${{ steps.resolve_path.outputs.package_json }}
4346
- name: Install dependencies
4447
# --prod skips devDependencies (husky, vitest, etc.); --ignore-scripts skips the
4548
# husky prepare hook, which would otherwise fail since husky isn't installed.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@
2929
"*.{js,jsx,ts,tsx,css,json,jsonc,yaml,yml}": "prettier --write"
3030
},
3131
"engines": {
32-
"node": ">=24"
32+
"node": "24.x"
3333
}
3434
}

0 commit comments

Comments
 (0)