Semaphore Pipeline Integration with SmartUI
Semaphore is a modern CI/CD (Continuous Integration and Continuous Delivery) platform designed for developers to automate the process of building, testing, and deploying software.
This guide explains how to integrate your project with the Semaphore CI/CD pipeline to trigger visual regression testing with LambdaTest SmartUI whenever changes are made to your repository.
Steps to Integrate Semaphore Pipeline with SmartUI
To integrate Semaphore 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: Create your Project
- Click on the Create New >> Choose Repository.
- Select your desired repository from your VCS (GitHub or Bitbucket)
Step 2: Setup your Workflow
- Select your desired build tool and edit your workflow as per your requirement. A sample workflow is given for your reference:
- Click on Run the Workflow button to trigger your tests
loading...
You can also store your LT_USERNAME, LT_ACCESS_KEY and PROJECT_TOKEN as secrets in your Semaphore project repository.
Step 3: 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 Semaphore Secrets for all sensitive data
- Rotate secrets regularly
- Use different secrets for different environments
Pipeline Optimization
- Use parallel blocks 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:
auto_cancel:
running:
when: branch != 'main'"
Build Naming
- Use meaningful build names that include branch/commit info
- Include commit SHA for traceability
- Use consistent naming conventions
Example:
env_vars:
- name: BUILD_NAME
value: ${SEMAPHORE_GIT_BRANCH}-${SEMAPHORE_GIT_SHA}"
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 Secret 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 "Secret Not Found"
Symptoms: Pipeline fails with error about missing secrets
Possible Causes:
- Secrets not created in Semaphore project
- Secret names don't match
- Secrets not accessible to pipeline
- Secret scope issues
Solutions:
-
Verify secrets exist in project settings:
- Go to Project Settings → Secrets
- Check
LT_USERNAME,LT_ACCESS_KEY, andPROJECT_TOKENexist
-
Ensure secret names match exactly (case-sensitive)
-
Check secret scope (project or organization level)
-
Verify secrets are accessible to the pipeline
Issue: PROJECT_TOKEN Not Available
Symptoms: Pipeline prompts for PROJECT_TOKEN or token not found
Possible Causes:
- PROJECT_TOKEN not set as secret
- Secret not passed to job
- Secret scope issues
Solutions:
-
Add PROJECT_TOKEN as Semaphore Secret
-
Pass secret to job:
env_vars:
- name: PROJECT_TOKEN
value: ${PROJECT_TOKEN} -
Check secret is accessible to the pipeline
-
Verify secret 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:
- name: Check Logs
commands:
- 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 in Semaphore settings
-
Run tests in parallel using parallel blocks:
blocks:
- name: Test Group 1
task:
jobs:
- name: Run Tests
commands:
- npx smartui exec -- <command">
- name: Test Group 2
task:
jobs:
- name: Run Tests
commands:
- npx smartui exec -- <command"> -
Optimize test execution
-
Split tests across multiple pipeline blocks
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:
prologue:
commands:
- nvm use 18 -
Clear npm cache:
commands:
- 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:
prologue:
commands:
- nvm use 18 -
Verify npm is available:
commands:
- npm --version -
Install SmartUI CLI explicitly:
commands:
- npm install -g @lambdatest/smartui-cli
Getting Help
If you encounter issues not covered here:
- Review Semaphore 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
