71 lines
2.3 KiB
YAML
71 lines
2.3 KiB
YAML
name: npm-test
|
|
description: "Install dependencies and run tests for an NPM package."
|
|
inputs:
|
|
workingDirectory:
|
|
description: "Working directory containing package.json."
|
|
required: false
|
|
default: "."
|
|
nodeVersion:
|
|
description: "Node.js version to use."
|
|
required: false
|
|
default: "20"
|
|
testCommand:
|
|
description: "Command to run tests. Default: npm test"
|
|
required: false
|
|
default: "npm test"
|
|
coverageCommand:
|
|
description: "Command to run tests with coverage. Default: npm run test:coverage"
|
|
required: false
|
|
default: "npm run test:coverage"
|
|
runCoverage:
|
|
description: "Whether to run coverage. Values: true, false."
|
|
required: false
|
|
default: "false"
|
|
coverageDirectory:
|
|
description: "Directory for the coverage output. Default: coverage"
|
|
required: false
|
|
default: "coverage"
|
|
uploadArtifacts:
|
|
description: "Whether to upload test artifacts. Values: true, false."
|
|
required: false
|
|
default: "false"
|
|
artifactName:
|
|
description: "Name of the artifact to upload. Default: test-results"
|
|
required: false
|
|
default: "test-results"
|
|
retention-days:
|
|
description: "Number of retention days for artifacts. Default: 7"
|
|
required: false
|
|
default: "7"
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: "Setup Node.js"
|
|
uses: https://github.com/actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ inputs.nodeVersion }}
|
|
- name: "Install dependencies"
|
|
run: |
|
|
ls -al
|
|
echo --------------------------------------------
|
|
npm ci
|
|
working-directory: ${{ inputs.workingDirectory }}
|
|
shell: bash
|
|
# - name: "Run tests"
|
|
# run: ${{ inputs.testCommand }}
|
|
# working-directory: ${{ inputs.workingDirectory }}
|
|
# shell: bash
|
|
# - name: "Run tests with coverage"
|
|
# if: ${{ inputs.runCoverage == 'true' }}
|
|
# run: ${{ inputs.coverageCommand }}
|
|
# working-directory: ${{ inputs.workingDirectory }}
|
|
# shell: bash
|
|
# - name: "Upload test artifacts"
|
|
# if: ${{ inputs.uploadArtifacts == 'true' && always() }}
|
|
# uses: https://github.com/ChristopherHX/gitea-upload-artifact@v4
|
|
# with:
|
|
# name: ${{ inputs.artifactName }}
|
|
# path: ${{ inputs.workingDirectory }}/${{ inputs.coverageDirectory }}
|
|
# if-no-files-found: warn
|
|
# retention-days: ${{ inputs.retention-days }}
|