Use the pkgjs/action
workflow to automatically add new versions of Node.js to your test matrix.
- Define a miminum supported Node.js version in your
package.json
, e.g.
{
"engines": {
"node": "^16 || ^14 || ^12"
}
}
- Create a file (e.g.
ci.yaml
) in your.github/workflows/
folder:
on:
push:
branches:
- main
pull_request:
jobs:
test:
uses: pkgjs/action/.github/workflows/node-test.yaml@v0
with:
upgrade-policy: lts # optional
With the above configuration, a test matrix will be created with all the Node.js LTS versions starting from v12. In January, 2022, the above example would yield the following versions: 16, 14, 12 (LTS releases which will not be removed from the matrix), as well as 17 (current non-LTS release - will be removed from the matrix when the support ends).
By default, the test script will check out your repository, execute npm install
and then execute an npm test
using the latest Node.js version in every release line in the test matrix.
- See detailed documentation for alternative upgrade policies and other settings.
- Read more about Node.js release support process.
- Choosing the Node.js versions for your CI tests (hint: use LTS)
- This repository is managed by the Package Maintenance Working Group, see Governance.
- Code of Conduct
- Contributing