This GitHub Action sets up a Node.js environment and runs install, audit, test, and build commands for your Node.js project.
Example usage in a workflow:
name: Node.js CI
on:
pull_request:
branches:
- main
types: [opened, synchronize, reopened, ready_for_review]
jobs:
node-tests:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Run Node Tests in src directory
uses: alleyinteractive/action-test-node@develop
with:
node-version: 'lts/*'
working-directory: './src'
audit-skip: 'true'
test-command: 'npm run test:ci && npm run test:coverage'
build-command: 'npm run build:prod'
Specify using
with
keyword.
- Specify the Node.js version to use.
- Accepts a string.
- Defaults to
lts/*
.
- Specify the npm version to use if different from the bundled version.
- Accepts a string.
- Defaults to an empty string, which uses the default npm version.
- Specify the directory to run the commands in.
- Accepts a string.
- Defaults to
.
.
- Specify the path to the dependency file to use for caching; note that this path is relative to the
working-directory
. - Accepts a string.
- Defaults to
package-lock.json
.
- Determine whether to cache the
node_modules
directory relative to theworking-directory
; note that setting this to 'true' adds logic to the defaultinstall-command
to skipnpm ci
if thenode_modules
directory cache is restored. This will not override a custominstall-command
. - Accepts a boolean string (
'true'
or'false'
). - Defaults to
'false'
.
- Determine whether to skip the npm audit step.
- Accepts a boolean string (
'true'
or'false'
). - Defaults to
'false'
, which runs the audit step.
- Specify the command to run for npm audit.
- Accepts a string.
- Defaults to
npm audit --audit-level=high --production
.
- Determine whether to skip the npm install step.
- Accepts a boolean string (
'true'
or'false'
). - Defaults to
'false'
, which runs the install step.
- Specify the command to run for npm install.
- Accepts a string.
- Defaults to
npm ci
.
- Determine whether to skip the test step.
- Accepts a boolean string (
'true'
or'false'
). - Defaults to
'false'
, which runs the test step.
- Specify the command to run for tests.
- Accepts a string.
- Defaults to
npm test
.
- Determine whether to skip the build step.
- Accepts a boolean string (
'true'
or'false'
). - Defaults to
'false'
, which runs the build step.
- Specify the command to run for build.
- Accepts a string.
- Defaults to
npm run build
.
Please see CHANGELOG for more information on what has changed recently.
This project is actively maintained by Alley Interactive.
The GNU General Public License (GPL) license. Please see License File for more information.⏎