Skip to content

End-to-end tests #57090

End-to-end tests

End-to-end tests #57090

Workflow file for this run

name: End-to-end tests
on: [ deployment_status ]
jobs:
files-changed:
if: github.ref != 'refs/heads/main'
name: Detect what files changed
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
frontend: ${{ steps.changes.outputs.frontend == 'true' || steps.overrides.outputs.frontend == 'true' }}
backend: ${{ steps.changes.outputs.backend == 'true' || steps.overrides.outputs.backend == 'true' }}
steps:
- uses: actions/checkout@v4
- name: Check for files changes
uses: dorny/paths-filter@v3
id: changes
with:
token: ${{ github.token }}
filters: .github/file-filters.yml
- uses: 8BitJonny/[email protected]
id: PR
- name: Check for keyword overrides
id: overrides
run: |
echo "PR ${{ steps.PR.outputs.number }}"
echo "Frontend override: ${{contains(steps.PR.outputs.pr_body, 'test-frontend')}}"
echo "Backend override: ${{contains(steps.PR.outputs.pr_body, 'test-backend')}}"
echo "frontend=${{ contains(steps.PR.outputs.pr_body, 'test-frontend') }}" >> "$GITHUB_OUTPUT"
echo "backend=${{ contains(steps.PR.outputs.pr_body, 'test-backend') }}" >> "$GITHUB_OUTPUT"
prepare-preview:
# Only trigger for correct environment and status
runs-on: ubuntu-latest
if: needs.files-changed.outputs.frontend == 'true' || needs.files-changed.outputs.backend == 'true'
needs: files-changed
outputs:
url: ${{ github.event.deployment_status.environment_url }}
steps:
- name: is render ready
if: ${{ !(github.event.deployment_status.state == 'success' && github.event.deployment_status.environment_url != null) }}
run: |
echo "Render environment ${{ github.event.deployment.environment }} is not ready: ${{ github.event.deployment_status.state }} ${{ github.event.deployment_status.environment_url }}"
exit 1
api-tests:
if: needs.files-changed.outputs.backend == 'true'
timeout-minutes: 30
runs-on: ubuntu-latest
needs: prepare-preview
name: API tests
steps:
- name: Checkout
uses: actions/checkout@v4
# Install packages
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
- name: Install packages
run: yarn install --frozen-lockfile
# Build packages
- name: Build packages/common module
run: yarn common-build
- name: create-json
id: create-json
uses: jsdaniell/[email protected]
with:
name: "credentials.json"
json: ${{ secrets.GCP_CREDENTIALS }}
dir: "./packages/e2e/cypress/fixtures/"
# Run API tests
- name: Cypress run
uses: cypress-io/github-action@v6
with:
project: ./packages/e2e
spec: packages/e2e/cypress/e2e/api/**/*
# Set the PR deployment url and disable video recording
config: 'baseUrl=${{needs.prepare-preview.outputs.url}},video=false'
env:
CYPRESS_PGHOST: ${{secrets.PGHOST}}
CYPRESS_PGPASSWORD: ${{secrets.PGPASSWORD}}
CYPRESS_DATABRICKS_HOST: ${{secrets.DATABRICKS_HOST}}
CYPRESS_DATABRICKS_PATH: ${{secrets.DATABRICKS_PATH}}
CYPRESS_DATABRICKS_TOKEN: ${{secrets.DATABRICKS_TOKEN}}
CYPRESS_SNOWFLAKE_ACCOUNT: ${{secrets.SNOWFLAKE_ACCOUNT}}
CYPRESS_SNOWFLAKE_USER: ${{secrets.SNOWFLAKE_USER}}
CYPRESS_SNOWFLAKE_PASSWORD: ${{secrets.SNOWFLAKE_PASSWORD}}
CYPRESS_TRINO_HOST: ${{secrets.TRINO_HOST}}
CYPRESS_TRINO_PORT: ${{secrets.TRINO_PORT}}
CYPRESS_TRINO_USER: ${{secrets.TRINO_USER}}
CYPRESS_TRINO_PASSWORD: ${{secrets.TRINO_PASSWORD}}
TZ: 'UTC'
CYPRESS_TZ: 'UTC'
build-cypress-e2e-image:
runs-on: ubuntu-latest
name: Build cypress e2e image
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: GitHub Registry Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v5
with:
file: ./packages/e2e/dockerfile
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ghcr.io/lightdash/lightdash-cypress-e2e:latest
push: true
app-tests:
if: needs.files-changed.outputs.frontend == 'true'
timeout-minutes: 30
runs-on: ubuntu-latest
needs: prepare-preview
container:
image: ghcr.io/lightdash/lightdash-cypress-e2e:latest
options: --user 1001
strategy:
fail-fast: false
matrix:
containers: [ 1, 2, 3 ]
name: App (${{ matrix.containers }}/${{ strategy.job-total }})
steps:
- name: Checkout
uses: actions/checkout@v4
# Install packages
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
- name: Install packages
run: yarn install --frozen-lockfile
# Build packages
- name: Build packages/common module
run: yarn common-build
# Prepare bigquery credentials for Cypress
- name: create-json
id: create-json
uses: jsdaniell/[email protected]
with:
name: "credentials.json"
json: ${{ secrets.GCP_CREDENTIALS }}
dir: "./packages/e2e/cypress/fixtures/"
# Run E2E tests
- name: Cypress run
uses: cypress-io/github-action@v6
with:
browser: chrome
project: ./packages/e2e
# Set the PR deployment url and disable video recording
config: 'baseUrl=${{needs.prepare-preview.outputs.url}},specPattern=cypress/e2e/app/**/*.cy.{js,jsx,ts,tsx},video=false'
env:
SPLIT: ${{ strategy.job-total }}
SPLIT_INDEX: ${{ strategy.job-index }}
CYPRESS_PGHOST: ${{secrets.PGHOST}}
CYPRESS_PGPASSWORD: ${{secrets.PGPASSWORD}}
CYPRESS_DATABRICKS_HOST: ${{secrets.DATABRICKS_HOST}}
CYPRESS_DATABRICKS_PATH: ${{secrets.DATABRICKS_PATH}}
CYPRESS_DATABRICKS_TOKEN: ${{secrets.DATABRICKS_TOKEN}}
CYPRESS_SNOWFLAKE_ACCOUNT: ${{secrets.SNOWFLAKE_ACCOUNT}}
CYPRESS_SNOWFLAKE_USER: ${{secrets.SNOWFLAKE_USER}}
CYPRESS_SNOWFLAKE_PASSWORD: ${{secrets.SNOWFLAKE_PASSWORD}}
CYPRESS_TRINO_HOST: ${{secrets.TRINO_HOST}}
CYPRESS_TRINO_PORT: ${{secrets.TRINO_PORT}}
CYPRESS_TRINO_USER: ${{secrets.TRINO_USER}}
CYPRESS_TRINO_PASSWORD: ${{secrets.TRINO_PASSWORD}}
TZ: 'UTC'
CYPRESS_TZ: 'UTC'
# After the test run completes
# store videos and any screenshots
- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots-and-videos-${{ strategy.job-index }}
path: |
packages/e2e/cypress/screenshots
packages/e2e/cypress/videos
if-no-files-found: ignore
timezone-tests:
if: needs.files-changed.outputs.frontend == 'true'
timeout-minutes: 30
runs-on: ubuntu-latest
needs: prepare-preview
container:
image: ghcr.io/lightdash/lightdash-cypress-e2e:latest
options: --user 1001
strategy:
fail-fast: false
matrix:
timezone: ['America/New_York', 'Europe/Madrid', 'Asia/Tokyo' ]
name: Timezone (${{ matrix.timezone }})
steps:
- name: Checkout
uses: actions/checkout@v4
# Install packages
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
- name: Install packages
run: yarn install --frozen-lockfile
# Build packages
- name: Build packages/common module
run: yarn common-build
# Prepare bigquery credentials for Cypress
- name: create-json
id: create-json
uses: jsdaniell/[email protected]
with:
name: "credentials.json"
json: ${{ secrets.GCP_CREDENTIALS }}
dir: "./packages/e2e/cypress/fixtures/"
# Run E2E tests
- name: Cypress run
uses: cypress-io/github-action@v6
with:
project: ./packages/e2e
spec: packages/e2e/cypress/e2e/app/dates.cy.ts
# Set the PR deployment url and disable video recording
config: 'baseUrl=${{needs.prepare-preview.outputs.url}},video=false'
env:
TZ: ${{ matrix.timezone }}
CYPRESS_TZ: ${{ matrix.timezone }}
# After the test run completes
# store videos and any screenshots
- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots-and-videos-timezone-${{ strategy.job-index }}
path: |
packages/e2e/cypress/screenshots
packages/e2e/cypress/videos
if-no-files-found: ignore