Skip to content

Commit

Permalink
More optionality
Browse files Browse the repository at this point in the history
  • Loading branch information
actuallymentor committed Oct 10, 2023
1 parent 577fee4 commit af01cb9
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 8 deletions.
9 changes: 9 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# Define which compose files to use
# see: https://www.perplexity.ai/search/6d5732a8-89ba-479b-bdf6-00c93d19b9a9?s=u

# Director only (no dashboard etc)
COMPOSE_FILE=docker-compose.network.yml,docker-compose.director.yml

# The full stack with dashboard etc
#COMPOSE_FILE=docker-compose.network.yml,docker-compose.full.yml

# SSH configuration
SSH_IP=1.1.1.1
SSH_PORT=22
Expand Down
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,54 @@ Authentication is done using basic auth, which is set up based on environment va
## Setting up sorry-cypress

1. Follow the [sorry-cypress setup instructions](https://docs.sorry-cypress.dev/guide/get-started)
- `npm i cypress-cloud`
- Edit `cypress` CLI for `cypress-coud` [see docs](https://docs.sorry-cypress.dev/guide/get-started#running-cypress-tests-in-parallel)
- Add `cloudPlugin` to `cypress.config.js`
2. Set `cloudServiceUrl` in your `currents.config.js` to `https://your_user:[email protected]_domain.com`
3. See `.github-actions.example.yml` for an example for how to set up a parallel resting CI on Github

### Example usage in Github actions

You can use the director in Github Actions by setting `currents.config.js` to:

```js
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:

```bash
sed -i "s;%%cypress_cloud_service_url%%;${{ secrets.CYPRESS_CLOUD_SERVICE_URL }};g" currents.config.js
```

You can then run parallel testing using:

```yml
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:
```yml
# 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
```

## Notes

**Buildjet is highly recommended**
Expand Down
72 changes: 72 additions & 0 deletions docker-compose.director.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
version: '3'

services:

## ###############
## Infra services
## ###############

# MongoDB service, this is used by the cypress services to store data
mongo:
image: mongo:4.4
container_name: mongo
volumes:
- ./data/data-mongo-cypress:/data/db
networks:
- internal
restart: unless-stopped

# Reverse proxy service, this is used to expose the cypress services to the world securely
swag:
image: lscr.io/linuxserver/swag:latest
container_name: swag
cap_add:
- NET_ADMIN
environment:
# Environment setup
- PUID=1000
- PGID=1000
- TZ=Europe/London
# Automatic SSL certificate provisioning
- URL=${PROXY_SERVER_DOMAIN}
- VALIDATION=http
- SUBDOMAINS=${PROXY_DIRECTOR_SUBDOMAIN},${PROXY_API_SUBDOMAIN},${PROXY_DASHBOARD_SUBDOMAIN}
- ONLY_SUBDOMAINS=true
volumes:
- ./swag:/config
ports:
- 443:443
- 80:80
depends_on:
- director
- mongo
networks:
- internal
- external
restart: unless-stopped


## ###############
## Cypress services
## ###############

# Cypress director (required)
# Coordinates & parallelizes tests, saves test results, this is the container that the cypress test runner connects to
# This is the only **required** service to run parallel tests, see: https://docs.sorry-cypress.dev/configuration/in-memory
director:
image: agoldis/sorry-cypress-director:latest
container_name: sorry-cypress-director
environment:
MONGODB_URI: 'mongodb://mongo:27017'
MONGODB_DATABASE: 'sorry-cypress'
EXECUTION_DRIVER: '../execution/mongo/driver'
GITLAB_JOB_RETRIES: 'false'
#S3_REGION: us-east-1
PROBE_LOGGER: "false"
ports:
- 1234:1234
networks:
- internal
depends_on:
- mongo
restart: unless-stopped
9 changes: 1 addition & 8 deletions docker-compose.yml → docker-compose.full.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
version: '3'

# Network configuration, we'll make one internal network for the cypress container, and one publicly available network for the proxy
networks:
internal:
name: internal
# internal: true
external:
name: external

services:

## ###############
Expand Down Expand Up @@ -138,4 +130,5 @@ services:
- minio
networks:
- internal
- external # note that the dashboard requires this to make calls from the frontend
restart: unless-stopped
9 changes: 9 additions & 0 deletions docker-compose.network.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '3'

# Network configuration, we'll make one internal network for the cypress container, and one publicly available network for the proxy
networks:
internal:
name: internal
internal: true
external:
name: external

0 comments on commit af01cb9

Please sign in to comment.