Skip to content
/ action Public

Github Actions tooling for testing Node.js packages

License

Notifications You must be signed in to change notification settings

pkgjs/action

Repository files navigation

pkgjs/action

Use the pkgjs/action workflow to automatically add new versions of Node.js to your test matrix.

Basic usage

  1. Define a miminum supported Node.js version in your package.json, e.g.
{
  "engines": {
    "node": "^16 || ^14 || ^12"
  }
}
  1. 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.

Further reading