This repository is intended as a setup script to configure a remote server as a sorry-cypress stack. It:
- Installs
docker
- Starts a
docker-compose
stack with a full sorry-cypress stack - Starts a reverse proxy for the cypress director and dashboard
Authentication is done using basic auth, which is set up based on environment variables in the .env
file.
- An Ubuntu 22.04 server with a public IP address (recommended minimum of 1G RAM)
- 3 subdomains of a main domain name pointing to the server
- Clone this repository
- Populate the
.env
file with the required variables, see.env.example
- Run
bash scripts/provision.sh
- Follow the instructions in the script
- Follow the sorry-cypress setup instructions
npm i cypress-cloud
- Edit
cypress
CLI forcypress-coud
see docs - Add
cloudPlugin
tocypress.config.js
, example:// Setting up sorry cypress const { cloudPlugin } = require( "cypress-cloud/plugin" ) return cloudPlugin( on, config )
- Set
cloudServiceUrl
in yourcurrents.config.js
tohttps://your_user:[email protected]_domain.com
- See
.github-actions.example.yml
for an example for how to set up a parallel resting CI on Github
You can use the director in Github Actions by setting currents.config.js
to:
module.exports = {
projectId: "APP NAME", // the projectId, can be any values for sorry-cypress users
recordKey: "xxx", // the record key, can be any value for sorry-cypress users
cloudServiceUrl: "%%cypress_cloud_service_url%%", // Sorry Cypress users - set the director service URL
}
And in Github Actions add the URL with authentication using:
sed -i "s;%%cypress_cloud_service_url%%;${{ secrets.CYPRESS_CLOUD_SERVICE_URL }};g" currents.config.js
You can then run parallel testing using:
strategy:
fail-fast: false
matrix:
# run 3 copies of the current job in parallel
containers: [ 1, 2, 3 ]
You can save the artifacts of the containers for debugging by using:
# If CI failed, upload the videos for debugging
- name: Upload cypress video files
if: always() # you can optionally set this to failure()
uses: actions/upload-artifact@v3
with:
name: cypress-videos ${{ matrix.containers }}
path: |
cypress/videos
cypress/screenshots
Buildjet is highly recommended
Buildjet (no affiliation) supplies Github Action runners that have more resources. It makes running tests in parallel a lot faster. They have a free tier, and the paid tiers are priced reasonably based on usage. If Cypress charged reasonable fees like Buildjet, this repository would not exist. I hope you're listening Cypress.
Only the director is essential
The dashboard and API containers are nice for having a dashboard to view from, but there is no need for them if you just want to run tests in parallel and use local recordings for debugging.
Containers are isolated from the internet
The docker stack only exposes the sorry-cypress
containers through the reverse proxy. You can test this by running:
source .env
function test_port() {
nc -vz $SSH_IP $1
}
# Testing the cypress ports
test_port 1234
test_port 4000
test_port 8080
# Testing the reverse proxy ports
test_port 80
test_port 443