I am receiving errors after running workflows in Github Actions using Node.js CI. I believe the problem is with the yml file based on the following errors:
build (18.x) Process completed with exit code 32. build (16.x) The operation was canceled.
build (18.x) The following actions uses node12 which is deprecated and will be forced to run on node16: actions/checkout@v2, actions/setup-node@v1. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/
build (16.x) The following actions uses node12 which is deprecated and will be forced to run on node16: actions/checkout@v2, actions/setup-node@v1. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/
The error is occuring on the "run npm test" step. I'm not sure if this is an issue with the yml file but it is mentioned in the links on the error codes:
Here is the yml file:
name: Node.js CI
on:
workflow_dispatch:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x,18.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm start &
- run: npm test
Your GitHub Actions are outdated and do not support Node.js v16
or v18
(which are the versions you are using, as evident from your matrix strategy). Hence why you get the error.
You can fix the error by using actions/checkout@v4
and actions/setup-node@v3
:
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
Both actions/checkout@v2
and actions/setup-node@v1
support only up to Node.js v12.
actions/setup-node@v3
supports Node.js 18
since v3.7.0
: https://github.com/actions/setup-node/releases/tag/v3.7.0