Prerequisites
- A GitHub repository
- hitspec test files in your repo (see Basic CRUD)
Quick Setup with the Official Action
The fastest way to run hitspec in CI is with the official GitHub Action.Create the workflow file
Create The
.github/workflows/api-tests.yml:.github/workflows/api-tests.yml
if: always() on the upload step ensures test results are uploaded even when tests fail, so you can inspect failures in the GitHub UI.Verify the results
When the workflow runs, it:
- Installs the latest hitspec binary
- Runs all
.httpfiles in thetests/directory - Produces JUnit XML output at
test-results.xml - Exits with code 0 on success, 1 on failure
- Uploads the XML as a build artifact
Workflow Recipes
Run only smoke tests
Filter by tags to run a fast subset in CI:Run tests against staging
Use theenv input to select an environment defined in your .hitspec.env.json or hitspec.yaml:
Pass secrets via environment file
Create a.env file at runtime from GitHub secrets:
Parallel execution
Run independent tests concurrently for faster feedback:Fail fast on first error
Usebail to stop at the first failure:
Stress testing in CI
Run load tests with pass/fail thresholds as a quality gate:Manual Installation (Without the Action)
If you prefer to install hitspec yourself:Exit Codes
hitspec uses standard exit codes for CI integration:| Code | Meaning |
|---|---|
0 | All tests passed |
1 | One or more tests failed |
Environment Variables
All CLI flags can be set via environment variables with theHITSPEC_ prefix. This is useful for CI where you want to configure hitspec without modifying the workflow:
| Variable | CLI Flag | Description |
|---|---|---|
HITSPEC_ENV | --env | Environment to use |
HITSPEC_ENV_FILE | --env-file | Path to .env file |
HITSPEC_TAGS | --tags | Filter by tags |
HITSPEC_OUTPUT | --output | Output format |
HITSPEC_OUTPUT_FILE | --output-file | Output file path |
HITSPEC_BAIL | --bail | Stop on first failure |
HITSPEC_PARALLEL | --parallel | Run in parallel |
HITSPEC_TIMEOUT | --timeout | Request timeout |
Complete Production Workflow
Here is a full workflow that runs smoke tests on every push, full tests on PRs, and stress tests on merge to main:.github/workflows/api-tests-full.yml