Compare commits

...

5 Commits

Author SHA1 Message Date
Ferdinand Thiessen
122adcd5c2
Merge 25df5cda4f into 395ad32622 2025-12-03 21:42:03 +09:00
dependabot[bot]
395ad32622
Bump js-yaml from 3.14.1 to 3.14.2 (#1435)
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 3.14.1 to 3.14.2.
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/3.14.1...3.14.2)

---
updated-dependencies:
- dependency-name: js-yaml
  dependency-version: 3.14.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-02 21:06:19 -06:00
dependabot[bot]
a4d2e2bbca
Bump actions/checkout from 5 to 6 (#1439)
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-02 21:03:23 -06:00
Ferdinand Thiessen
25df5cda4f
test: adjust for array like devEngines
Co-authored-by: Grigory <grigory.orlov.set@gmail.com>
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
2025-06-21 15:06:11 +02:00
Ferdinand Thiessen
88483fd687
feat(node-version-file): support parsing devEngines field
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
2025-04-20 13:23:46 +02:00
10 changed files with 152 additions and 52 deletions

View File

@ -21,7 +21,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20, 22, 24] node-version: [20, 22, 24]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Clean global cache - name: Clean global cache
run: npm cache clean --force run: npm cache clean --force
- name: Setup Node - name: Setup Node
@ -44,7 +44,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20, 22, 24] node-version: [20, 22, 24]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Install pnpm - name: Install pnpm
uses: pnpm/action-setup@v4 uses: pnpm/action-setup@v4
with: with:
@ -77,7 +77,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20, 22, 24] node-version: [20, 22, 24]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Yarn version - name: Yarn version
run: yarn --version run: yarn --version
- name: Generate yarn file - name: Generate yarn file
@ -109,7 +109,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20, 22, 24] node-version: [20, 22, 24]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Update yarn - name: Update yarn
run: yarn set version 3.6.4 run: yarn set version 3.6.4
- name: Yarn version - name: Yarn version
@ -143,7 +143,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: prepare sub-projects - name: prepare sub-projects
run: __tests__/prepare-yarn-subprojects.sh yarn1 run: __tests__/prepare-yarn-subprojects.sh yarn1
@ -170,7 +170,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: prepare sub-projects - name: prepare sub-projects
run: __tests__/prepare-yarn-subprojects.sh keepcache keepcache run: __tests__/prepare-yarn-subprojects.sh keepcache keepcache
@ -197,7 +197,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: prepare sub-projects - name: prepare sub-projects
run: __tests__/prepare-yarn-subprojects.sh global run: __tests__/prepare-yarn-subprojects.sh global
@ -224,7 +224,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: prepare sub-projects - name: prepare sub-projects
run: /bin/bash __tests__/prepare-yarn-subprojects.sh keepcache run: /bin/bash __tests__/prepare-yarn-subprojects.sh keepcache
@ -253,7 +253,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20, 22, 24] node-version: [20, 22, 24]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Create package.json with packageManager field - name: Create package.json with packageManager field
run: | run: |
echo '{ "name": "test-project", "version": "1.0.0", "packageManager": "npm@8.0.0" }' > package.json echo '{ "name": "test-project", "version": "1.0.0", "packageManager": "npm@8.0.0" }' > package.json
@ -278,7 +278,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20, 22, 24] node-version: [20, 22, 24]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Create package.json with devEngines field - name: Create package.json with devEngines field
run: | run: |
echo '{ echo '{

View File

@ -25,7 +25,7 @@ jobs:
env: env:
https_proxy: http://squid-proxy:3128 https_proxy: http://squid-proxy:3128
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Clear tool cache - name: Clear tool cache
run: rm -rf $RUNNER_TOOL_CACHE/* run: rm -rf $RUNNER_TOOL_CACHE/*
- name: Setup node 24 - name: Setup node 24
@ -41,7 +41,7 @@ jobs:
https_proxy: http://no-such-proxy:3128 https_proxy: http://no-such-proxy:3128
no_proxy: api.github.com,github.com,nodejs.org,registry.npmjs.org,*.s3.amazonaws.com,s3.amazonaws.com no_proxy: api.github.com,github.com,nodejs.org,registry.npmjs.org,*.s3.amazonaws.com,s3.amazonaws.com
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Clear tool cache - name: Clear tool cache
run: rm -rf $RUNNER_TOOL_CACHE/* run: rm -rf $RUNNER_TOOL_CACHE/*
- name: Setup node 24 - name: Setup node 24

View File

@ -14,7 +14,7 @@ jobs:
steps: steps:
- name: Checking out - name: Checking out
uses: actions/checkout@v5 uses: actions/checkout@v6
- name: Publish - name: Publish
id: publish id: publish
uses: actions/publish-immutable-action@v0.0.4 uses: actions/publish-immutable-action@v0.0.4

View File

@ -20,7 +20,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20, 22, 24] node-version: [20, 22, 24]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Node - name: Setup Node
uses: ./ uses: ./
with: with:
@ -37,7 +37,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest-large]
node-version: [lts/dubnium, lts/erbium, lts/fermium, lts/*, lts/-1] node-version: [lts/dubnium, lts/erbium, lts/fermium, lts/*, lts/-1]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Node - name: Setup Node
uses: ./ uses: ./
with: with:
@ -64,7 +64,7 @@ jobs:
'20.0.0-v8-canary20221101e50e45c9f8' '20.0.0-v8-canary20221101e50e45c9f8'
] ]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Node - name: Setup Node
uses: ./ uses: ./
with: with:
@ -84,7 +84,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20-nightly, 25-nightly, 24.0.0-nightly] node-version: [20-nightly, 25-nightly, 24.0.0-nightly]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Node - name: Setup Node
uses: ./ uses: ./
with: with:
@ -104,7 +104,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20.0.0-rc.1, 22.14.0-rc.1, 24.0.0-rc.4] node-version: [20.0.0-rc.1, 22.14.0-rc.1, 24.0.0-rc.4]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Node - name: Setup Node
uses: ./ uses: ./
with: with:
@ -124,7 +124,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20.10.0, 22.0.0, 24.9.0] node-version: [20.10.0, 22.0.0, 24.9.0]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Node - name: Setup Node
uses: ./ uses: ./
with: with:
@ -141,7 +141,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [20, 22, 24] node-version: [20, 22, 24]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Node and check latest - name: Setup Node and check latest
uses: ./ uses: ./
with: with:
@ -160,7 +160,7 @@ jobs:
node-version-file: node-version-file:
[.nvmrc, .tool-versions, .tool-versions-node, package.json] [.nvmrc, .tool-versions, .tool-versions-node, package.json]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup node from node version file - name: Setup node from node version file
uses: ./ uses: ./
with: with:
@ -168,6 +168,36 @@ jobs:
- name: Verify node - name: Verify node
run: __tests__/verify-node.sh 24 run: __tests__/verify-node.sh 24
version-file-dev-engines:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
steps:
- uses: actions/checkout@v4
- name: Setup node from node version file
uses: ./
with:
node-version-file: '__tests__/data/package-dev-engines.json'
- name: Verify node
run: __tests__/verify-node.sh 20
version-file-dev-engines-array:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
steps:
- uses: actions/checkout@v4
- name: Setup node from node version file
uses: ./
with:
node-version-file: '__tests__/data/package-dev-engines-array.json'
- name: Verify node
run: __tests__/verify-node.sh 20
version-file-volta: version-file-volta:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
@ -175,7 +205,7 @@ jobs:
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup node from node version file - name: Setup node from node version file
uses: ./ uses: ./
with: with:
@ -190,7 +220,7 @@ jobs:
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup node from node version file - name: Setup node from node version file
uses: ./ uses: ./
with: with:
@ -206,7 +236,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
node-version: [17, 19] node-version: [17, 19]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Node from dist - name: Setup Node from dist
uses: ./ uses: ./
with: with:
@ -222,7 +252,7 @@ jobs:
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest-large]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
# test old versions which didn't have npm and layout different # test old versions which didn't have npm and layout different
- name: Setup node 0.12.18 from dist - name: Setup node 0.12.18 from dist
uses: ./ uses: ./
@ -235,7 +265,7 @@ jobs:
arch: arch:
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup node 20 x86 from dist - name: Setup node 20 x86 from dist
uses: ./ uses: ./
with: with:
@ -259,7 +289,7 @@ jobs:
echo "LATEST_NODE_VERSION=$latestNodeVersion" >> $GITHUB_OUTPUT echo "LATEST_NODE_VERSION=$latestNodeVersion" >> $GITHUB_OUTPUT
id: version id: version
shell: bash shell: bash
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Node - name: Setup Node
uses: ./ uses: ./
with: with:

View File

@ -0,0 +1,17 @@
{
"engines": {
"node": "^19"
},
"devEngines": {
"runtime": [
{
"name": "bun",
"version": "^1"
},
{
"name": "node",
"version": "^20"
}
]
}
}

View File

@ -0,0 +1,11 @@
{
"engines": {
"node": "^19"
},
"devEngines": {
"runtime": {
"name": "node",
"version": "^20"
}
}
}

View File

@ -94,22 +94,24 @@ describe('main tests', () => {
describe('getNodeVersionFromFile', () => { describe('getNodeVersionFromFile', () => {
each` each`
contents | expected contents | expected
${'12'} | ${'12'} ${'12'} | ${'12'}
${'12.3'} | ${'12.3'} ${'12.3'} | ${'12.3'}
${'12.3.4'} | ${'12.3.4'} ${'12.3.4'} | ${'12.3.4'}
${'v12.3.4'} | ${'12.3.4'} ${'v12.3.4'} | ${'12.3.4'}
${'lts/erbium'} | ${'lts/erbium'} ${'lts/erbium'} | ${'lts/erbium'}
${'lts/*'} | ${'lts/*'} ${'lts/*'} | ${'lts/*'}
${'nodejs 12.3.4'} | ${'12.3.4'} ${'nodejs 12.3.4'} | ${'12.3.4'}
${'ruby 2.3.4\nnodejs 12.3.4\npython 3.4.5'} | ${'12.3.4'} ${'ruby 2.3.4\nnodejs 12.3.4\npython 3.4.5'} | ${'12.3.4'}
${''} | ${''} ${''} | ${''}
${'unknown format'} | ${'unknown format'} ${'unknown format'} | ${'unknown format'}
${' 14.1.0 '} | ${'14.1.0'} ${' 14.1.0 '} | ${'14.1.0'}
${'{"volta": {"node": ">=14.0.0 <=17.0.0"}}'}| ${'>=14.0.0 <=17.0.0'} ${'{}'} | ${null}
${'{"volta": {"extends": "./package.json"}}'}| ${'18.0.0'} ${'{"volta": {"node": ">=14.0.0 <=17.0.0"}}'} | ${'>=14.0.0 <=17.0.0'}
${'{"engines": {"node": "17.0.0"}}'} | ${'17.0.0'} ${'{"volta": {"extends": "./package.json"}}'} | ${'18.0.0'}
${'{}'} | ${null} ${'{"engines": {"node": "17.0.0"}}'} | ${'17.0.0'}
${'{"devEngines": {"runtime": {"name": "node", "version": "22.0.0"}}}'} | ${'22.0.0'}
${'{"devEngines": {"runtime": [{"name": "bun"}, {"name": "node", "version": "22.0.0"}]}}'} | ${'22.0.0'}
`.it('parses "$contents"', ({contents, expected}) => { `.it('parses "$contents"', ({contents, expected}) => {
const existsSpy = jest.spyOn(fs, 'existsSync'); const existsSpy = jest.spyOn(fs, 'existsSync');
existsSpy.mockImplementation(() => true); existsSpy.mockImplementation(() => true);

View File

@ -71,7 +71,35 @@ steps:
- run: npm test - run: npm test
``` ```
When using the `package.json` input, the action will look for `volta.node` first. If `volta.node` isn't defined, then it will look for `engines.node`. When using the `package.json` input, the action will look in following field for a specified Node version:
1. It checks `volta.node` first.
2. Then it checks `devEngines.runtime`.
3. Then it will look for `engines.node`.
4. Otherwise it tries to resolve the file defined by [`volta.extends`](https://docs.volta.sh/advanced/workspaces)
and look for `volta.node` or `engines.node` recursively.
### Example with `devEngines`
When a runtime engine (`engines.node`) is defined but also a development engine (`devEngines.runtime`) then the `devEngine` runtime version is used.
This example will install a Node version based on the `^20.10` pattern.
```json
{
"engines": {
"node": "^19"
},
"devEngines": {
"runtime": {
"name": "node",
"version": "^20.10"
}
}
}
```
### Example with volta pinned Node version
When both `engines.node` and `volta.node` is defined the value in `volta.node` is used.
```json ```json
{ {
@ -84,8 +112,6 @@ When using the `package.json` input, the action will look for `volta.node` first
} }
``` ```
Otherwise, when [`volta.extends`](https://docs.volta.sh/advanced/workspaces) is defined, then it will resolve the corresponding file and look for `volta.node` or `engines.node` recursively.
## Architecture ## Architecture
You can use any of the [supported operating systems](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners), and the compatible `architecture` can be selected using `architecture`. Values are `x86`, `x64`, `arm64`, `armv6l`, `armv7l`, `ppc64le`, `s390x` (not all of the architectures are available on all platforms). You can use any of the [supported operating systems](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners), and the compatible `architecture` can be selected using `architecture`. Values are `x86`, `x64`, `arm64`, `armv6l`, `armv7l`, `ppc64le`, `s390x` (not all of the architectures are available on all platforms).

14
package-lock.json generated
View File

@ -994,10 +994,11 @@
} }
}, },
"node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": { "node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": {
"version": "3.14.1", "version": "3.14.2",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.2.tgz",
"integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", "integrity": "sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"argparse": "^1.0.7", "argparse": "^1.0.7",
"esprima": "^4.0.0" "esprima": "^4.0.0"
@ -4315,10 +4316,11 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/js-yaml": { "node_modules/js-yaml": {
"version": "4.1.0", "version": "4.1.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"argparse": "^2.0.1" "argparse": "^2.0.1"
}, },

View File

@ -26,6 +26,18 @@ export function getNodeVersionFromFile(versionFilePath: string): string | null {
return manifest.volta.node; return manifest.volta.node;
} }
// support devEngines from npm 11
if (manifest.devEngines?.runtime) {
// find an entry with name set to node and having set a version.
// the devEngines.runtime can either be an object or an array of objects
const nodeEntry = [manifest.devEngines.runtime]
.flat()
.find(({name, version}) => name.toLowerCase() === 'node' && version);
if (nodeEntry) {
return nodeEntry.version;
}
}
if (manifest.engines?.node) { if (manifest.engines?.node) {
return manifest.engines.node; return manifest.engines.node;
} }