Skip to content

A reusable action that can be leveraged to run a standard battery of node tests (within the context of a Pull Request)

License

Notifications You must be signed in to change notification settings

alleyinteractive/action-test-node

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Run Node Tests Action

This GitHub Action sets up a Node.js environment and runs install, audit, test, and build commands for your Node.js project.

Usage

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'

Inputs

Specify using with keyword.

node-version

  • Specify the Node.js version to use.
  • Accepts a string.
  • Defaults to lts/*.

npm-version

  • 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.

working-directory

  • Specify the directory to run the commands in.
  • Accepts a string.
  • Defaults to ..

cache-dependency-path

  • 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.

cache-node-modules

  • Determine whether to cache the node_modules directory relative to the working-directory; note that setting this to 'true' adds logic to the default install-command to skip npm ci if the node_modules directory cache is restored. This will not override a custom install-command.
  • Accepts a boolean string ('true' or 'false').
  • Defaults to 'false'.

audit-skip or skip-audit

  • Determine whether to skip the npm audit step.
  • Accepts a boolean string ('true' or 'false').
  • Defaults to 'false', which runs the audit step.

audit-command

  • Specify the command to run for npm audit.
  • Accepts a string.
  • Defaults to npm audit --audit-level=high --production.

install-skip or skip-install

  • Determine whether to skip the npm install step.
  • Accepts a boolean string ('true' or 'false').
  • Defaults to 'false', which runs the install step.

install-command

  • Specify the command to run for npm install.
  • Accepts a string.
  • Defaults to npm ci.

test-skip or skip-test

  • Determine whether to skip the test step.
  • Accepts a boolean string ('true' or 'false').
  • Defaults to 'false', which runs the test step.

test-command

  • Specify the command to run for tests.
  • Accepts a string.
  • Defaults to npm test.

build-skip or skip-build

  • Determine whether to skip the build step.
  • Accepts a boolean string ('true' or 'false').
  • Defaults to 'false', which runs the build step.

build-command

  • Specify the command to run for build.
  • Accepts a string.
  • Defaults to npm run build.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

This project is actively maintained by Alley Interactive.

License

The GNU General Public License (GPL) license. Please see License File for more information.⏎

About

A reusable action that can be leveraged to run a standard battery of node tests (within the context of a Pull Request)

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published