Run Tests
Generic test runner for any framework: npm, pytest, go test, make, etc.
Reference: loha/run-tests@v1
Category: test
Runtime: alpine:3.19 (non-root, digest-pinned)
License: Apache-2.0
When to use
Use this step to run your test suite. It is intentionally generic: configure TEST_COMMAND for whatever testing tool you use. For language-specific defaults (lint, type-check) use the dedicated run-lint and type-check tasks instead.
Parameters
| Parameter | Type | Default | Required | Description |
|---|---|---|---|---|
TEST_COMMAND | string | make test | No | Command to run tests |
WORKING_DIRECTORY | string | . | No | Directory to run tests from (relative to workspace root) |
TEST_IMAGE | string | alpine@sha256:6baf43584bcb78f2e5847d1de515f23499913ac9f12bdf834811a3145eb11ca1 | No | Container image with test dependencies |
COVERAGE | string | false | No | Enable coverage reporting |
TIMEOUT | string | 600 | No | Test timeout in seconds |
FAIL_ON_ERROR | string | true | No | Fail the task if tests fail |
Workspaces
source(required): bound from pipeline workspacesourcetest-results(optional): bound from pipeline workspacetest-results
Results
| Result | Description |
|---|---|
TEST_RESULT | Test result (PASS or FAIL) |
TEST_OUTPUT | Path to test output file |
How it works
Spins up TEST_IMAGE (defaults to alpine:3.19), cds into WORKING_DIRECTORY, and runs TEST_COMMAND with a wall-clock timeout of TIMEOUT seconds. Captures the exit code and writes a results file to the optional test-results workspace if mounted.
Examples
Node.js test suite
steps:
- name: test
uses: loha/run-tests@v1
with:
TEST_COMMAND: 'pnpm test:unit'
TEST_IMAGE: 'node:20-alpine'
Python with coverage
steps:
- name: test
uses: loha/run-tests@v1
with:
TEST_COMMAND: 'pytest --cov=src --cov-report=xml'
TEST_IMAGE: 'python:3.12-slim'
COVERAGE: 'true'
TIMEOUT: '900'
Troubleshooting
Problem: Tests pass locally but the step reports FAIL with no obvious error.
Solution: Check TIMEOUT: slow integration tests may be hitting the 600-second default. Bump it explicitly when needed.