Skip to main content

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​

ParameterTypeDefaultRequiredDescription
TEST_COMMANDstringmake testNoCommand to run tests
WORKING_DIRECTORYstring.NoDirectory to run tests from (relative to workspace root)
TEST_IMAGEstringalpine@sha256:6baf43584bcb78f2e5847d1de515f23499913ac9f12bdf834811a3145eb11ca1NoContainer image with test dependencies
COVERAGEstringfalseNoEnable coverage reporting
TIMEOUTstring600NoTest timeout in seconds
FAIL_ON_ERRORstringtrueNoFail the task if tests fail

Workspaces​

  • source (required): bound from pipeline workspace source
  • test-results (optional): bound from pipeline workspace test-results

Results​

ResultDescription
TEST_RESULTTest result (PASS or FAIL)
TEST_OUTPUTPath 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.