These examples can apply to virtually any GitHub deployment, provided that you already have some existing automated tests, and are either the maintainer or an admin of the target repository.
- GitHub Account
- Sauce Labs Account
- The following permissions in GitHub:
- ability to create and manage workflows
- ability to create and store GitHub secrets
The first order of business is to export your Sauce Labs account credentials and store them as GitHub Secrets.
Navigate to your project repository and select the settings icon
Click the New secret button
Add the following:
- Value: 'your-sauce-username'
Click Add secret to finish.
Repeat the same steps above for your
SAUCE_ACCESS_KEY(Not sure where to find
SAUCE_ACCESS_KEYin Sauce Labs? They're here).
In your root project directory, create the following directory tree:
.github/workflows. In the
workflows directory create a file called
Add the following to the top of your file:
env at the top of the file enables it globally in this workflow, so all jobs have access to these variables.
In the examples below, we illustrate the different run modes that
saucectl has: Docker and the Sauce Cloud— both determine where tests execute. Docker refers to executing tests locally in a container, while Sauce refers to executing tests on Sauce Cloud (i.e. Sauce Labs infrastructure).
If you run your tests on the Sauce Cloud, you will likely require a tunnel back to where your application is running. A tunnel enables the remote browser to access your local network.
For this, we are going to use Sauce Connect.
For more detailed information on setting event-driven actions and jobs, please visit the GitHub Action documentation.
- Sauce Cloud
You can reference our example workflows here.
Now when you commit these files, GitHub will detect the new workflow actions and launch
saucectl to run your tests.
To see the output:
Log in to GitHub
Navigate to your repository page
Click on Actions
Your output may look something like this: