Files
gitea-actions/test/npm/action.yml
T
2026-05-29 11:16:00 -04:00

41 lines
1.0 KiB
YAML

name: NPM Test
description: Install dependencies and run npm tests
inputs:
INSTALL_CMD:
description: "Install command"
default: "npm ci"
TEST_SCRIPT:
description: "npm script to run (must exist in package.json)"
default: "test"
WORKING_DIRECTORY:
description: "Directory to run commands in"
default: "."
runs:
using: composite
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v5
with:
node-version-file: package.json
- name: Cache node_modules
uses: actions/cache@v4
with:
path: ${{ inputs.WORKING_DIRECTORY }}/node_modules
key: node-modules-${{ hashFiles(format('{0}/package-lock.json', inputs.WORKING_DIRECTORY)) }}
restore-keys: node-modules-
- name: Install
shell: sh
working-directory: ${{ inputs.WORKING_DIRECTORY }}
run: ${{ inputs.INSTALL_CMD }}
- name: Test
shell: sh
working-directory: ${{ inputs.WORKING_DIRECTORY }}
run: npm run ${{ inputs.TEST_SCRIPT }}