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
- A Test-Lab account with test plans created
- An API key
- 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: triggerMultiple 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_KEYUsing 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:
| Platform | Setting |
|---|---|
| GitHub Actions | Settings → Secrets → TESTLAB_API_KEY |
| GitLab CI | Settings → CI/CD → Variables → TESTLAB_API_KEY |
| Jenkins | Credentials → Add → TESTLAB_API_KEY |
Never commit API keys to your repository.
Best Practices
- Use Quick mode for PRs - Faster feedback during development
- Use Deep mode for main branch - Thorough testing before release
- Set meaningful buildIds - Makes debugging easier
- Configure webhooks - For Slack notifications, PR status updates
- 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
- Verify webhook URL is publicly accessible
- Check webhook secret is configured
- See Webhooks troubleshooting
Insufficient credits error
- Top up credits in Dashboard → Billing
- Switch to Quick mode for lower cost