Skip to content

CI/CD Integration

Unfault integrates with GitHub Actions, GitLab CI, and other CI/CD systems to catch issues before they reach production.

The unfault review command supports multiple output formats:

FormatFlagUse Case
text--output=textHuman-readable terminal output (default)
json--output=jsonMachine-readable JSON for custom integrations
sarif--output=sarifSARIF format for GitHub Code Scanning

Add this workflow to .github/workflows/unfault.yml:

name: Unfault
on:
pull_request:
push:
branches: [main]
jobs:
unfault:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Unfault
run: curl -sSL https://unfault.dev/get | bash
- name: Run Unfault review
env:
UNFAULT_API_KEY: ${{ secrets.UNFAULT_API_KEY }}
run: unfault review --output sarif > results.sarif
- name: Upload SARIF to GitHub
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif

This configuration:

  1. Runs on every pull request and push to main
  2. Uploads SARIF results to GitHub’s Security tab
  3. Shows findings inline in pull request diffs with full context
  1. Go to your Unfault dashboard
  2. Navigate to Settings > API Keys
  3. Create a new key with appropriate permissions
  4. Add it to your repository secrets as UNFAULT_API_KEY

Add to .gitlab-ci.yml:

unfault:
image: debian:bookworm-slim
stage: test
before_script:
- apt-get update && apt-get install -y curl
- curl -sSL https://unfault.dev/get | bash
script:
- unfault review --output sarif > gl-code-quality-report.json
artifacts:
reports:
sast: gl-code-quality-report.json
variables:
UNFAULT_API_KEY: $UNFAULT_API_KEY

The CLI uses standard exit codes for CI/CD integration:

CodeMeaningAction
0Success, no issues✅ Proceed
1General error🔍 Check logs
2Configuration errorRun unfault login
3Authentication failedRe-authenticate
4Network errorCheck connectivity
5Findings detected🚨 Review issues
6Invalid inputCheck arguments
7Service unavailableRetry later
8Session errorRetry analysis
10Subscription requiredUpgrade plan

For custom PR comments with JSON output:

- name: Run Unfault review
id: unfault
run: |
unfault review --output json > results.json
echo "findings=$(cat results.json | jq '.findings | length')" >> $GITHUB_OUTPUT
- name: Comment on PR
if: ${{ steps.unfault.outputs.findings > 0 }}
uses: actions/github-script@v7
with:
script: |
const results = require('./results.json');
const body = `## Unfault found ${results.findings.length} findings\n\n` +
results.findings.map(f => `- **${f.rule}**: ${f.message}`).join('\n');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body
});

Speed up CI runs by caching the Unfault binary:

- name: Cache Unfault
uses: actions/cache@v4
with:
path: ~/.local/bin/unfault
key: unfault-${{ runner.os }}
- name: Install Unfault
if: steps.cache.outputs.cache-hit != 'true'
run: curl -sSL https://unfault.dev/get | bash
VariablePurpose
UNFAULT_API_KEYAuthentication for CI
UNFAULT_NO_COLORDisable colored output
UNFAULT_DEBUGEnable debug logging