5caa4bce61
feat(ci): self contained e2e GitHub action
155 lines
3.8 KiB
YAML
155 lines
3.8 KiB
YAML
name: E2E
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- main
|
|
- develop
|
|
paths:
|
|
- '**.ts'
|
|
- '**.tsx'
|
|
- '**/tsconfig.json'
|
|
- 'pnpm-lock.yaml'
|
|
- '.github/workflows/e2e.yml'
|
|
pull_request:
|
|
paths:
|
|
- '**.ts'
|
|
- '**.tsx'
|
|
- '**/tsconfig.json'
|
|
- 'pnpm-lock.yaml'
|
|
- '.github/workflows/e2e.yml'
|
|
|
|
defaults:
|
|
run:
|
|
shell: 'bash'
|
|
|
|
jobs:
|
|
test_e2e:
|
|
runs-on: ubuntu-latest
|
|
name: Playwright tests
|
|
timeout-minutes: 20
|
|
|
|
services:
|
|
mysql:
|
|
image: mariadb:10.6
|
|
env:
|
|
MYSQL_ROOT_PASSWORD: root
|
|
MYSQL_DATABASE: bigcapital_system
|
|
MYSQL_USER: bigcapital
|
|
MYSQL_PASSWORD: bigcapital
|
|
ports:
|
|
- 3306:3306
|
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
|
|
|
|
redis:
|
|
image: redis:7-alpine
|
|
ports:
|
|
- 6379:6379
|
|
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=5
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 18.16.1
|
|
|
|
- uses: pnpm/action-setup@v2
|
|
with:
|
|
version: 9
|
|
|
|
- name: Get pnpm store directory
|
|
shell: bash
|
|
run: |
|
|
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
|
|
id: pnpm-cache
|
|
|
|
- name: Setup pnpm cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pnpm-store-
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Build shared packages
|
|
run: pnpm build
|
|
|
|
- name: Create server .env file
|
|
run: |
|
|
cat > packages/server/.env << EOF
|
|
# Database
|
|
DB_HOST=127.0.0.1
|
|
DB_USER=bigcapital
|
|
DB_PASSWORD=bigcapital
|
|
DB_ROOT_PASSWORD=root
|
|
DB_CHARSET=utf8
|
|
|
|
# System database
|
|
SYSTEM_DB_NAME=bigcapital_system
|
|
|
|
# Tenant databases
|
|
TENANT_DB_NAME_PERFIX=bigcapital_tenant_
|
|
|
|
# Application
|
|
BASE_URL=http://localhost:3000
|
|
JWT_SECRET=test-jwt-secret-for-e2e-testing
|
|
APP_JWT_SECRET=test-app-jwt-secret
|
|
|
|
# Sign-up
|
|
SIGNUP_DISABLED=false
|
|
|
|
# API rate limit
|
|
API_RATE_LIMIT=120,60,600
|
|
|
|
# Redis
|
|
REDIS_HOST=127.0.0.1
|
|
REDIS_PORT=6379
|
|
|
|
# S3 (placeholder values for E2E tests)
|
|
S3_REGION=us-east-1
|
|
S3_ACCESS_KEY_ID=test-access-key
|
|
S3_SECRET_ACCESS_KEY=test-secret-key
|
|
S3_ENDPOINT=http://localhost:9000
|
|
S3_BUCKET=test-bucket
|
|
|
|
# Mail (placeholder values for E2E tests)
|
|
MAIL_HOST=localhost
|
|
MAIL_PORT=1025
|
|
MAIL_FROM_NAME=Bigcapital
|
|
MAIL_FROM_ADDRESS=test@bigcapital.app
|
|
EOF
|
|
|
|
- name: Run database migrations
|
|
run: pnpm system:migrate:latest
|
|
|
|
- name: Start server in background
|
|
run: |
|
|
cd packages/server && pnpm start:prod &
|
|
sleep 10
|
|
env:
|
|
NODE_ENV: production
|
|
|
|
- name: Start webapp in background
|
|
run: |
|
|
cd packages/webapp && pnpm dev &
|
|
sleep 10
|
|
|
|
- name: Install Playwright browsers
|
|
run: pnpm exec playwright install chromium
|
|
|
|
- name: Run E2E tests
|
|
run: pnpm run test:e2e
|
|
env:
|
|
PLAYWRIGHT_TEST_BASE_URL: http://localhost:4000
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: playwright-report
|
|
path: test-results/
|
|
retention-days: 30
|