actions/run-tests/action.yml
2026-05-15 11:48:04 +02:00

56 lines
1.6 KiB
YAML

name: Run Tests
description: Runs a project's test suite with optional setup and failure-artifact upload. Language-agnostic.
inputs:
command:
description: Test command to execute (multiline allowed)
required: true
setup:
description: Setup commands to run before tests (install deps, build, etc.)
required: false
default: ""
working-directory:
description: Directory to run setup and command in
required: false
default: "."
shell:
description: Shell to use for setup and command
required: false
default: bash
artifacts-path:
description: Glob of paths to upload on failure (test reports, logs). Empty disables upload.
required: false
default: ""
artifacts-name:
description: Name of the uploaded artifact bundle
required: false
default: test-artifacts
runs:
using: composite
steps:
- name: Setup
if: inputs.setup != ''
shell: ${{ inputs.shell }}
working-directory: ${{ inputs.working-directory }}
run: ${{ inputs.setup }}
- name: Run tests
id: tests
shell: ${{ inputs.shell }}
working-directory: ${{ inputs.working-directory }}
run: ${{ inputs.command }}
continue-on-error: true
- name: Upload failure artifacts
if: inputs.artifacts-path != '' && steps.tests.outcome == 'failure'
uses: https://code.forgejo.org/forgejo/upload-artifact@v4
with:
name: ${{ inputs.artifacts-name }}
path: ${{ inputs.artifacts-path }}
if-no-files-found: ignore
- name: Propagate failure
if: steps.tests.outcome == 'failure'
shell: bash
run: exit 1