122 lines
2.9 KiB
YAML
122 lines
2.9 KiB
YAML
# GitLab CI Template for E2E Testing
|
|
# Include this in your project's .gitlab-ci.yml:
|
|
#
|
|
# include:
|
|
# - project: 'transquinnftw/playwright-e2e-docker'
|
|
# file: '/templates/gitlab-ci.yml'
|
|
# ref: main
|
|
#
|
|
# Or copy and customize for your needs.
|
|
|
|
variables:
|
|
PLAYWRIGHT_VERSION: "1.57.0"
|
|
PNPM_VERSION: "8.15.0"
|
|
NODE_VERSION: "22"
|
|
|
|
# Base job for E2E tests
|
|
.e2e-base:
|
|
image: mcr.microsoft.com/playwright:v${PLAYWRIGHT_VERSION}-noble
|
|
variables:
|
|
DISPLAY: ":99"
|
|
ELECTRON_DISABLE_GPU: "1"
|
|
CI: "true"
|
|
before_script:
|
|
- corepack enable
|
|
- corepack prepare pnpm@${PNPM_VERSION} --activate
|
|
- pnpm install --frozen-lockfile
|
|
- pnpm build
|
|
artifacts:
|
|
when: always
|
|
paths:
|
|
- test-results/
|
|
- playwright-report/
|
|
reports:
|
|
junit: test-results/junit.xml
|
|
expire_in: 7 days
|
|
|
|
# Standard E2E test job
|
|
e2e-tests:
|
|
extends: .e2e-base
|
|
stage: test
|
|
script:
|
|
- xvfb-run --auto-servernum --server-args="-screen 0 1920x1080x24" pnpm test:e2e
|
|
rules:
|
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
- if: $CI_COMMIT_BRANCH == "main"
|
|
- if: $CI_COMMIT_BRANCH == "develop"
|
|
|
|
# E2E with mock services (Docker-in-Docker)
|
|
.e2e-docker:
|
|
extends: .e2e-base
|
|
image: docker:24
|
|
services:
|
|
- docker:24-dind
|
|
variables:
|
|
DOCKER_HOST: tcp://docker:2376
|
|
DOCKER_TLS_CERTDIR: "/certs"
|
|
DOCKER_DRIVER: overlay2
|
|
before_script:
|
|
- apk add --no-cache nodejs npm
|
|
- npm install -g pnpm@${PNPM_VERSION}
|
|
- pnpm install --frozen-lockfile
|
|
script:
|
|
- docker compose -f e2e/docker-compose.yml up --build --abort-on-container-exit --exit-code-from e2e-tests
|
|
|
|
# E2E with external services
|
|
.e2e-services:
|
|
extends: .e2e-base
|
|
services:
|
|
- postgres:16-alpine
|
|
- redis:7-alpine
|
|
variables:
|
|
POSTGRES_DB: test_db
|
|
POSTGRES_USER: test_user
|
|
POSTGRES_PASSWORD: test_password
|
|
POSTGRES_HOST: postgres
|
|
REDIS_HOST: redis
|
|
script:
|
|
- xvfb-run --auto-servernum pnpm test:e2e
|
|
|
|
# Web-only E2E (no Electron/Xvfb needed)
|
|
.e2e-web:
|
|
image: mcr.microsoft.com/playwright:v${PLAYWRIGHT_VERSION}-noble
|
|
variables:
|
|
CI: "true"
|
|
before_script:
|
|
- corepack enable
|
|
- corepack prepare pnpm@${PNPM_VERSION} --activate
|
|
- pnpm install --frozen-lockfile
|
|
- pnpm build
|
|
script:
|
|
- pnpm test:e2e
|
|
artifacts:
|
|
when: always
|
|
paths:
|
|
- test-results/
|
|
- playwright-report/
|
|
reports:
|
|
junit: test-results/junit.xml
|
|
expire_in: 7 days
|
|
|
|
# Scheduled full regression
|
|
e2e-regression:
|
|
extends: .e2e-base
|
|
stage: test
|
|
script:
|
|
- xvfb-run --auto-servernum pnpm test:e2e --project=all
|
|
rules:
|
|
- if: $CI_PIPELINE_SOURCE == "schedule"
|
|
allow_failure: true
|
|
|
|
# Visual regression testing
|
|
.e2e-visual:
|
|
extends: .e2e-base
|
|
script:
|
|
- xvfb-run --auto-servernum pnpm test:e2e --update-snapshots
|
|
artifacts:
|
|
paths:
|
|
- test-results/
|
|
- "**/__screenshots__/"
|
|
when: always
|
|
rules:
|
|
- if: $CI_COMMIT_MESSAGE =~ /\[update-snapshots\]/
|