Circle CI Pipeline Integration with SmartUI
CircleCI is a popular CI/CD tool known for its speed, flexibility, and seamless integration with version control systems like GitHub and Bitbucket. It is cloud-native and also offers an on-premises solution.
This guide explains how to integrate your project with the CircleCI CI/CD pipeline to trigger visual regression testing with LambdaTest SmartUI whenever changes are made to your repository.
Steps to Integrate CircleCI Pipeline with SmartUI
To integrate CircleCI Pipeline with SmartUI, follow the below steps. You can use your own project to configure and test it. For demo purposes, we are using the sample repository.
Download or Clone the code sample from the LambdaTest GitHub repository to run the tests on the SmartUI.
Step 1: Set Up Your Repository
Ensure your project is hosted in GitHub, or any supported repository.
Step 2: Create a New Pipeline:
- Navigate to Pipelines in your CircleCI project.
- Select New Pipeline and connect your repository.
Step 3: Add Environment Variables
Go to Pipeline Settings > Variables. Add the following variables:
LT_USERNAME: Your LambdaTest username.LT_ACCESS_KEY: Your LambdaTest access key.
Step 4: Setup your Workflow
version: 2.1
jobs:
smartui_test:
docker:
- image: circleci/node:16
environment:
LT_USERNAME: $LT_USERNAME
LT_ACCESS_KEY: $LT_ACCESS_KEY
steps:
- checkout
- run:
name: Install Dependencies
command: npm install @lambdatest/smartui-cli
- run:
name: Execute SmartUI Tests
command: |
npx smartui --version
npx smartui config:create smartui-web.json
npx smartui --config smartui-web.json exec -- mvn --quiet test -D suite=sdk-cloud.xml
workflows:
version: 2
smartui_pipeline:
jobs:
- smartui_test
Step 5: Check the output
- After triggering the workflow, check your results in the SmartUI Dashboard
Best Practices
- Secret Management
- Pipeline Optimization
- Build Naming
- Error Handling
- Resource Management
- Resource Management
Secret Management
- Never commit credentials to repository
- Use CircleCI Environment Variables for all sensitive data
- Mark variables as secret to hide values in logs
- Rotate secrets regularly
- Use different secrets for different environments
Pipeline Optimization
- Use parallel jobs for faster execution
- Cache dependencies to speed up pipelines
- Only run visual tests on relevant branches
- Set up pipeline conditions to avoid unnecessary runs
Example:
workflows:
version: 2
smartui_pipeline:
jobs:
- smartui_test:
filters:
branches:
only:
- main
- develop
Build Naming
- Use meaningful build names that include branch/commit info
- Include commit SHA for traceability
- Use consistent naming conventions
Example:
environment:
BUILD_NAME: ${CIRCLE_BRANCH}-${CIRCLE_SHA1:0:7}"
Error Handling
- Set up proper error handling in pipelines
- Use pipeline status checks
- Configure notifications for failures
- Add retry logic for flaky tests
Resource Management
- Limit concurrent pipeline runs
- Clean up old builds regularly
- Monitor pipeline execution time
- Optimize test execution order
Resource Management
- Limit concurrent pipeline runs
- Clean up old builds regularly
- Monitor pipeline execution time
- Optimize test execution order
Troubleshooting
- Pipeline Fails with Variable Not Found
- PROJECT_TOKEN Not Available
- Tests Run But No Results in Dashboard
- Pipeline Times Out
- Dependencies Installation Fails
- SmartUI CLI Not Found
Issue: Pipeline Fails with "Variable Not Found"
Symptoms: Pipeline fails with error about missing environment variables
Possible Causes:
- Variables not created in CircleCI project
- Variable names don't match
- Variables not accessible to job
- Variable scope issues
Solutions:
-
Verify variables exist in project settings:
- Go to Project Settings → Environment Variables
- Check
LT_USERNAME,LT_ACCESS_KEY, andPROJECT_TOKENexist
-
Ensure variable names match exactly (case-sensitive)
-
Check variable scope (project or context level)
-
Verify variables are not masked if you need to see them in logs
Issue: PROJECT_TOKEN Not Available
Symptoms: Pipeline prompts for PROJECT_TOKEN or token not found
Possible Causes:
- PROJECT_TOKEN not set as environment variable
- Variable not passed to job
- Variable masked incorrectly
Solutions:
-
Add PROJECT_TOKEN as CircleCI Environment Variable
-
Pass variable to job:
environment:
PROJECT_TOKEN: $PROJECT_TOKEN -
Check variable is accessible to the job
-
Verify variable scope includes your project
Issue: Tests Run But No Results in Dashboard
Symptoms: Pipeline completes but screenshots don't appear in SmartUI
Possible Causes:
- Incorrect PROJECT_TOKEN
- Project name mismatch
- Network issues
- Pipeline job failure
Solutions:
-
Verify PROJECT_TOKEN is correct:
- Check token in SmartUI Project Settings
- Ensure token includes project ID prefix
-
Check pipeline logs for errors:
- run:
name: Check Logs
when: on_failure
command: |
cat /tmp/*.log || true -
Verify network connectivity in pipeline
-
Check if SmartUI CLI step completed successfully
Issue: Pipeline Times Out
Symptoms: Pipeline execution exceeds time limit
Possible Causes:
- Too many tests running
- Slow test execution
- Network latency
- Resource constraints
Solutions:
-
Increase pipeline timeout:
- run:
name: Execute Tests
no_output_timeout: 60m -
Run tests in parallel using matrix:
jobs:
smartui_test:
matrix:
parameters:
test_group: [1, 2, 3] -
Optimize test execution
-
Split tests across multiple pipeline jobs
Issue: Dependencies Installation Fails
Symptoms: npm install or dependency installation fails
Possible Causes:
- Network issues
- Package registry problems
- Version conflicts
- Node version mismatch
Solutions:
-
Use specific Node version:
docker:
- image: circleci/node:18 -
Clear npm cache:
- run:
name: Install Dependencies
command: |
npm cache clean --force
npm install -
Use package-lock.json for consistent installs
-
Check for version conflicts in package.json
Issue: SmartUI CLI Not Found
Symptoms: npx smartui command fails with command not found"
Possible Causes:
- Node.js not installed
- npm not available
- PATH issues
Solutions:
-
Ensure Node.js is available in Docker image:
docker:
- image: circleci/node:18 -
Verify npm is available:
- run:
name: Check npm
command: npm --version -
Install SmartUI CLI explicitly:
- run:
name: Install SmartUI CLI
command: npm install -g @lambdatest/smartui-cli
Getting Help
If you encounter issues not covered here:
- Review CircleCI Documentation
- Check SmartUI CLI Documentation for CLI-specific issues
- Visit LambdaTest Support for additional resources
- Contact support at support@lambdatest.com or use 24/7 Chat Support
