Skip to content
Latchkey

How to Run Bruno API Collections in CI

Bruno stores collections as files in the repo and its CLI runs them, so API tests live next to the code.

Install @usebruno/cli, then bru run the collection folder with an environment and --reporter-junit so results publish like any other test.

Steps

  • Keep the .bru collection files in the repo.
  • Install with npm install -g @usebruno/cli.
  • Run bru run <dir> --env <name> with --reporter-junit.

Workflow

.github/workflows/ci.yml
jobs:
  bruno:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
      - run: npm install -g @usebruno/cli
      - run: |
          npm start &
          npx wait-on http://localhost:3000/health
      - run: bru run ./api --env ci --reporter-junit results/bruno.xml
        env:
          API_TOKEN: ${{ secrets.API_TOKEN }}

Gotchas

  • Bruno reads environment secrets from process env, so pass tokens via env: rather than committing them.
  • The CLI exits non-zero on a failed assertion, which correctly fails the job.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →