Skip to content

Running Cypress e2e tests on prod #4631

Running Cypress e2e tests on prod

Running Cypress e2e tests on prod #4631

Workflow file for this run

name: run-e2e-prod
run-name: Running Cypress e2e tests on prod
on:
push:
branches:
- e2e-on-prod
workflow_dispatch:
branches:
- e2e-on-prod
schedule:
# Run at minute 45 past every 3rd hour on every day-of-week from Sunday through Saturday.
- cron: '45 */3 * * 0-6'
repository_dispatch:
types: [trigger_e2e]
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
cypress-run:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: e2e-on-prod
# Launch NucliaDB in docker
- run: |
docker network create nucliadb-network
docker run -it -d --name pg --network nucliadb-network \
-p 5432:5432 \
-e POSTGRES_USER=nucliadb \
-e POSTGRES_PASSWORD=nucliadb \
-e POSTGRES_DB=nucliadb \
postgres:latest
docker pull nuclia/nucliadb:latest
docker build -t nucliadb-server .
docker run --network nucliadb-network \
-p 8080:8080 \
-v nucliadb-standalone:/data \
-e NUA_API_KEY=${{ secrets.NUA_KEY_PROD_EUROPE }} \
-e DRIVER=PG \
-e DRIVER_PG_URL="postgresql://nucliadb:nucliadb@pg:5432/nucliadb" \
nucliadb-server &
# Install npm dependencies, cache them correctly and run all Cypress tests
- name: Cypress run
id: cypress
uses: cypress-io/github-action@v6
with:
install-command: yarn install
env:
CYPRESS_BASE_URL: https://nuclia.cloud
CYPRESS_BEARER_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN_PROD }}
CYPRESS_NUA_KEY_EUROPE: ${{ secrets.NUA_KEY_PROD_EUROPE }}
CYPRESS_NUA_KEY_USA: ${{ secrets.NUA_KEY_PROD_USA }}
CYPRESS_USER_NAME: ${{ secrets.USER_NAME_PROD }}
CYPRESS_USER_PWD: ${{ secrets.USER_PWD_PROD }}
CYPRESS_RUNNING_ENV: prod
# after the test run completes store reports and any screenshots
- name: Cypress reports
id: report
uses: actions/upload-artifact@v4
if: ${{ failure() && steps.cypress.conclusion == 'failure' }}
with:
name: cypress-reports
path: cypress/reports
if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn`
- name: Slack notification
id: slack
uses: slackapi/slack-github-action@v1.25.0
if: ${{ failure() && steps.cypress.conclusion == 'failure' }}
with:
payload: |
{
"text": "‼️️Cypress E2E failed on PROD ‼️\nRun #${{ github.run_number }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\nCypress report: ${{ steps.report.outputs.artifact-url }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_HOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK