Skip to content

CI Integration

Copy-paste examples for GitHub Actions, GitLab CI, and Jenkins.

Every example below uses af run to execute your test command, automatically create a test run, detect JUnit XML output, upload results, and finish the run — all in a single step. Your test framework just needs to produce JUnit XML (most do by default or with a flag).

GitHub Actions

name: Tests
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install AF CLI
        run: curl -fsSL https://cli.automatedfuture.co/cli/install.sh | sh

      - name: Run tests
        env:
          AF_API_KEY: ${{ secrets.AF_API_KEY }}
          AF_PROJECT_ID: ${{ secrets.AF_PROJECT_ID }}
        run: |
          af config from-env
          af run --label "GH Actions #${{ github.run_number }}" -- npm test -- --reporter=junit

Add AF_API_KEY and AF_PROJECT_ID as secrets in Settings > Secrets and variables > Actions.


GitLab CI

test:
  image: ubuntu:latest
  before_script:
    - apt-get update && apt-get install -y curl
    - curl -fsSL https://cli.automatedfuture.co/cli/install.sh | sh
    - export PATH="$HOME/.local/bin:$PATH"
    - af config from-env
  script:
    - af run --label "GitLab CI #$CI_PIPELINE_IID" -- pytest --junitxml=results.xml
  variables:
    AF_API_KEY: $AF_API_KEY
    AF_PROJECT_ID: $AF_PROJECT_ID

Add AF_API_KEY and AF_PROJECT_ID as CI/CD variables in Settings > CI/CD > Variables.


Jenkins

pipeline {
  agent any
  environment {
    AF_API_KEY     = credentials('af-api-key')
    AF_PROJECT_ID  = credentials('af-project-id')
  }
  stages {
    stage('Setup') {
      steps {
        sh 'curl -fsSL https://cli.automatedfuture.co/cli/install.sh | sh'
        sh 'export PATH="$HOME/.local/bin:$PATH" && af config from-env'
      }
    }
    stage('Test') {
      steps {
        sh '''
          export PATH="$HOME/.local/bin:$PATH"
          af run --label "Jenkins #$BUILD_NUMBER" -- ./gradlew test
        '''
      }
    }
  }
}

Add af-api-key and af-project-id as credentials in Manage Jenkins > Credentials.


Test Framework Setup

See the Test Frameworks page for detailed setup guides for Jest, pytest, Playwright, Go, Rust, RSpec, PHPUnit, and more.


Environment Variables

VariableRequiredDescription
AF_API_KEYYesYour API key (from Dashboard > Team > API Keys)
AF_PROJECT_IDRecommendedDefault project ID — avoids passing --project-id to every command

Run af config from-env after setting these to load them into the CLI config.


Troubleshooting

af: command not found — The install directory (~/.local/bin) is not in your PATH. Add export PATH="$HOME/.local/bin:$PATH" before calling af.

Invalid API key — Double-check the secret is set correctly in your CI platform and that the key has not been revoked.

No JUnit XML files found — Make sure your test framework is configured to output JUnit XML. If the output path is non-standard, pass it explicitly with --junit path/to/results.xml.

Need help? Email hello@automatedfuture.co.