Official GitHub Action
The fastest way to add hitspec to your pipeline:.github/workflows/api-tests.yml
Action Inputs
Selecting files
files takes one or more paths separated by spaces or newlines. Directories and
glob patterns are both accepted, and a pattern that matches nothing fails the
step instead of silently testing nothing:
** matches across directories when the runner’s bash is version 4 or newer
(Linux and Windows runners); with bash 3.2 (the macOS system shell) it behaves
like a single *, so list one pattern per directory level there. Paths that
contain spaces are not supported.
Reports
With the defaultoutput: console the results are printed in the log. When you
choose a machine-readable format (json, junit, tap or html) the report is
written to output-file, or to hitspec-results.<ext> (.json, .xml, .tap,
.html) when you do not set one, so it never floods the log. Use the
report-file output to find it:
Action Outputs
Installation, platforms and verification
The action downloads the hitspec release archive from GitHub Releases (with retries), verifies its SHA-256 against thechecksums.txt published with the
same release, and adds the binary to PATH for the following steps. A checksum
mismatch fails the step. It supports Linux, macOS and Windows runners on
amd64 and arm64. With version: latest the release is resolved through the
public releases/latest redirect, so no API quota is used.
The step fails whenever hitspec exits non-zero. Combine it with
continue-on-error: true and steps.<id>.outcome if a failing test run should
not stop the job.
Pinning the action
@v2 is a floating tag that moves to the latest v2.x.y release. Pin to a
specific release tag (for example @v2.20.0) or a commit SHA for fully
reproducible workflows. The older @v1 tag is frozen and still contains the
previous, less robust implementation of the action; move to @v2.
Using the CLI Directly
If you prefer installing hitspec yourself (for example, to pin a specific version or use Homebrew caching), you can call the CLI directly:.github/workflows/api-tests.yml
Exit Codes
hitspec uses specific exit codes that GitHub Actions interprets as pass or fail:
Any non-zero exit code causes the GitHub Actions step to fail, which blocks the workflow (and any required status checks) from passing.
Environment Variables and Secrets
Use GitHub secrets to pass sensitive values like API tokens and credentials. hitspec supports all major CLI flags as environment variables with theHITSPEC_ prefix.
Using an .env File
If your tests rely on an environment file, generate it from secrets at runtime:
Supported Environment Variables
Each variable sits between its flag and hitspec.yaml: the flag wins over the
variable, and the variable wins over hitspec.yaml.
HITSPEC_BAIL=false turns
off a bail: true in hitspec.yaml.
Metrics and Notification Variables
Caching
Cache the hitspec binary to speed up subsequent runs:Matrix Testing
Run the same tests across multiple environments or configurations using a GitHub Actions matrix:.github/workflows/api-tests.yml
Matrix with Tags
You can also use a matrix to run different test suites:Stress Testing in CI
Run load tests in your pipeline to catch performance regressions:threshold input defines pass/fail criteria. If any threshold is exceeded, the step fails with exit code 1.
Reporting with JUnit
Most CI reporting tools understand JUnit XML. To publish results in GitHub pull requests, combine hitspec with a JUnit reporter action:checks: write when publishing check runs.
Full Example Workflow
A complete workflow that runs smoke tests on every PR, full tests onmain, and uploads results:
.github/workflows/api-tests.yml