Skip to main content
hitspec is designed for CI/CD. It produces JUnit XML output, uses standard exit codes, and has an official GitHub Action. This tutorial walks through setting up API tests in a GitHub Actions workflow.

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.
1

Add test files to your repo

Create a tests/ directory with your .http files:
tests/api.http
2

Create the workflow file

Create .github/workflows/api-tests.yml:
.github/workflows/api-tests.yml
The if: always() on the upload step ensures test results are uploaded even when tests fail, so you can inspect failures in the GitHub UI.
3

Verify the results

When the workflow runs, it:
  1. Installs the latest hitspec binary
  2. Runs all .http files in the tests/ directory
  3. Produces JUnit XML output at test-results.xml
  4. Exits with code 0 on success, 1 on failure
  5. Uploads the XML as a build artifact
GitHub Actions natively understands JUnit XML and will show test results in the PR checks tab.

Workflow Recipes

Run only smoke tests

Filter by tags to run a fast subset in CI:

Run tests against staging

Use the env input to select an environment defined in the environments section of your 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

Use bail to stop at the first failure:

Stress testing in CI

Run load tests with pass/fail thresholds as a quality gate:
The workflow fails if the p95 latency exceeds 500ms or the error rate exceeds 1%.

Manual Installation (Without the Action)

If you prefer to install hitspec yourself:

Exit Codes

hitspec uses standard exit codes for CI integration: CI platforms treat any non-zero exit code as a failure, so hitspec works out of the box with GitHub Actions, GitLab CI, CircleCI, Jenkins, and others.

Environment Variables

All CLI flags can be set via environment variables with the HITSPEC_ prefix. This is useful for CI where you want to configure hitspec without modifying the workflow:

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

Next Steps

Output Formats

Learn about JUnit, JSON, TAP, and HTML output options.

Stress Testing

Configure load tests with profiles and thresholds.
Last modified on July 14, 2026