Run tests in CI
HeyBug can test every pull request and report the result as a check named **HeyBug / tests**.
HeyBug can test every pull request and report the result as a check named HeyBug / tests. The check needs one thing from your pipeline: the URL of the preview of that pull request.
Set up
- Create an access token with the
run:testsandread:testsscopes (see CI security). - Store it as a repository secret named
HEYBUG_TOKEN. Store your server address asHEYBUG_SERVER. - Add a workflow that calls
heybug ci runwith a preview URL.
Two ways to get a preview URL
Pattern A: the platform deploys every pull request
Your host (Vercel, Netlify, Render and others) builds a preview for each pull request and reports a deployment_status event to GitHub. The workflow listens for that event and tests the URL it carries.
name: HeyBug
on: deployment_status
permissions:
contents: read
jobs:
tests:
# Only test previews that are ready. Ignore pending, failure and error.
if: github.event.deployment_status.state == 'success'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Run HeyBug
env:
HEYBUG_SERVER: ${{ secrets.HEYBUG_SERVER }}
HEYBUG_TOKEN: ${{ secrets.HEYBUG_TOKEN }}
run: >
heybug ci run
--target-url "${{ github.event.deployment_status.environment_url }}"Every state other than success is skipped on purpose. A preview that is still building, or that failed to build, has nothing to test. Because the job is skipped, no check appears for that event; the successful event that follows creates it.
Use this pattern when the platform already deploys previews. You write no deploy step.
Pattern B: the workflow deploys the app itself
If there is no platform preview, build and deploy inside the workflow, then hand the URL to HeyBug with --target-url.
name: HeyBug
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: deploy
run: ./scripts/deploy-preview.sh # prints url=<preview url> to $GITHUB_OUTPUT
- run: heybug ci run --target-url "${{ steps.deploy.outputs.url }}"
env:
HEYBUG_SERVER: ${{ secrets.HEYBUG_SERVER }}
HEYBUG_TOKEN: ${{ secrets.HEYBUG_TOKEN }}Copy-paste deploy steps for common hosts are in Preview recipes.
The check name
Both patterns publish the result as HeyBug / tests. It is green when every test passes, red when a test fails or errors, and red when the preview could not be tested at all. Keep the job id tests and the workflow name HeyBug so the name stays the same (the check keeps its original name after the HeyBug rename, so existing branch rules keep working).
Block merges on failures
- Open the repository's settings, then Branches, then the rule for your main branch.
- Turn on "Require status checks to pass before merging".
- Search for HeyBug / tests and add it.
Until the check has run once, GitHub may not offer it in the search. Open a test pull request first.
With pattern A, a pull request that never gets a successful preview has no check at all. Branch protection waits for it, so the pull request stays blocked. This is the safe default.
What --allow-skip does
If no preview URL shows up before the wait runs out, HeyBug treats the run as skipped. By default a skipped run fails the check, because "nothing was tested" is not the same as "everything passed".
Add --allow-skip when a missing preview is normal for your project, for example docs-only changes that never deploy:
heybug ci run --wait-for-status --allow-skipWith the flag, a skipped run exits 0 and the check turns green with the note "skipped". A test that ran and failed still fails the check. The flag never hides real failures.
The command exits 0 when the check is green and non-zero when it is red, so any CI system can use it as a gate.