Official GitHub Action
The fastest way to add hitspec to your pipeline:.github/workflows/api-tests.yml
Action Inputs
The Action defaults
output to junit (handy for CI test reporting), whereas the
hitspec CLI defaults to console.Action Outputs
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
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