Test-Lab.aiDocs

CI Integration

Run Test-Lab tests from GitHub Actions, GitLab CI, and other pipelines

CI Integration

Integrate Test-Lab into your CI/CD pipeline to automatically run tests on every commit, PR, or deployment.

Prerequisites

  1. A Test-Lab account with test plans created
  2. An API key
  3. Your test plan ID(s)

GitHub Actions

Basic Workflow

Create .github/workflows/testlab.yml:

name: Test-Lab Tests

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Trigger Test-Lab Tests
        run: |
          RESPONSE=$(curl -s -X POST https://test-lab.ai/api/v1/run \
            -H "Authorization: Bearer ${{ secrets.TESTLAB_API_KEY }}" \
            -H "Content-Type: application/json" \
            -d '{
              "testPlanId": YOUR_TEST_PLAN_ID,
              "testType": "quickTest",
              "buildId": "${{ github.sha }}"
            }')
          
          echo "Response: $RESPONSE"
          JOB_ID=$(echo $RESPONSE | jq -r '.jobId')
          echo "job_id=$JOB_ID" >> $GITHUB_OUTPUT
        id: trigger

Multiple Test Plans

Run all tests for a project:

- name: Trigger All Tests
  run: |
    curl -X POST https://test-lab.ai/api/v1/run \
      -H "Authorization: Bearer ${{ secrets.TESTLAB_API_KEY }}" \
      -H "Content-Type: application/json" \
      -d '{"projectId": YOUR_PROJECT_ID, "buildId": "${{ github.sha }}"}'

Or specific test plans:

- name: Trigger Multiple Tests
  run: |
    curl -X POST https://test-lab.ai/api/v1/run \
      -H "Authorization: Bearer ${{ secrets.TESTLAB_API_KEY }}" \
      -H "Content-Type: application/json" \
      -d '{"testPlanIds": [ID_1, ID_2, ID_3], "buildId": "${{ github.sha }}"}'

GitLab CI

Basic Pipeline

Create .gitlab-ci.yml:

stages:
  - test

testlab:
  stage: test
  image: curlimages/curl:latest
  script:
    - |
      RESPONSE=$(curl -s -X POST https://test-lab.ai/api/v1/run \
        -H "Authorization: Bearer $TESTLAB_API_KEY" \
        -H "Content-Type: application/json" \
        -d "{\"testPlanId\": YOUR_TEST_PLAN_ID, \"buildId\": \"$CI_COMMIT_SHA\"}")
      
      echo "Response: $RESPONSE"
  variables:
    TESTLAB_API_KEY: $TESTLAB_API_KEY

Using Build IDs

The buildId field links test runs to specific commits or deployments:

  • Track test results per commit
  • View test history in the Builds page
  • Correlate failures with code changes
{
  "testPlanId": YOUR_TEST_PLAN_ID,
  "buildId": "YOUR_BUILD_ID"  // git SHA, PR number, version, etc.
}

Valid characters: letters, numbers, dashes, underscores, dots.

Getting Results

Use webhooks to receive test results. Configure a webhook URL in your project settings to get notified when tests complete.

Fire-and-Forget Pattern

Trigger tests and let webhooks handle the results:

- name: Trigger Tests (non-blocking)
  run: |
    curl -X POST https://test-lab.ai/api/v1/run \
      -H "Authorization: Bearer ${{ secrets.TESTLAB_API_KEY }}" \
      -H "Content-Type: application/json" \
      -d '{"testPlanId": YOUR_TEST_PLAN_ID, "buildId": "${{ github.sha }}"}'
    
    echo "Tests triggered - results will be sent to webhook"

Configure webhooks to notify Slack, update PR status, etc.

Secrets Management

Store your API key as a CI secret:

PlatformSetting
GitHub ActionsSettings → Secrets → TESTLAB_API_KEY
GitLab CISettings → CI/CD → Variables → TESTLAB_API_KEY
JenkinsCredentials → Add → TESTLAB_API_KEY

Never commit API keys to your repository.

Best Practices

  1. Use Quick mode for PRs - Faster feedback during development
  2. Use Deep mode for main branch - Thorough testing before release
  3. Set meaningful buildIds - Makes debugging easier
  4. Configure webhooks - For Slack notifications, PR status updates
  5. Run critical tests only - Don't slow down CI with every test

Troubleshooting

Tests not triggering

  • Verify API key is set correctly
  • Check the response for error messages
  • Ensure test plan IDs are correct

Not receiving webhook notifications

Insufficient credits error

  • Top up credits in Dashboard → Billing
  • Switch to Quick mode for lower cost

Next Steps

On this page