mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-04-07 05:01:24 +00:00
Merge pull request #1045 from bigcapitalhq/self-contained-e2e-github-action
feat(ci): self contained e2e GitHub action
This commit is contained in:
142
.github/workflows/e2e.yml
vendored
142
.github/workflows/e2e.yml
vendored
@@ -1,5 +1,6 @@
|
||||
name: E2E
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
@@ -23,46 +24,131 @@ defaults:
|
||||
shell: 'bash'
|
||||
|
||||
jobs:
|
||||
test_setup:
|
||||
name: Test setup
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
preview_url: ${{ steps.waitForVercelPreviewDeployment.outputs.url }}
|
||||
steps:
|
||||
- name: Wait for Vercel preview deployment to be ready
|
||||
uses: patrickedqvist/wait-for-vercel-preview@v1.3.1
|
||||
id: waitForVercelPreviewDeployment
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
max_timeout: 3000
|
||||
|
||||
test_e2e:
|
||||
runs-on: ubuntu-latest
|
||||
needs: test_setup
|
||||
name: Playwright tests
|
||||
timeout-minutes: 15
|
||||
environment: ${{ vars.ENVIRONMENT_STAGE }}
|
||||
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@v2
|
||||
- uses: actions/setup-node@v2
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 14 # Need for npm >=7.7
|
||||
cache: 'npm'
|
||||
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: npm install
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Install Playwright with deps
|
||||
run: npx playwright install --with-deps
|
||||
- name: Build shared packages
|
||||
run: pnpm build
|
||||
|
||||
- name: Run tests
|
||||
run: npm run test:e2e
|
||||
- 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:
|
||||
PLAYWRIGHT_TEST_BASE_URL: ${{ needs.test_setup.outputs.preview_url }}
|
||||
NODE_ENV: production
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
- 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
|
||||
retention-days: 30
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"test:watch": "jest --watch",
|
||||
"test:cov": "jest --coverage",
|
||||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||
"test:e2e": "jest --config ./test/jest-e2e.json --watchAll",
|
||||
"test:e2e": "jest --config ./test/jest-e2e.json --forceExit",
|
||||
"cli": "ts-node -r tsconfig-paths/register src/cli.ts",
|
||||
"cli:system:migrate:latest": "ts-node -r tsconfig-paths/register src/cli.ts system:migrate:latest",
|
||||
"cli:system:migrate:rollback": "ts-node -r tsconfig-paths/register src/cli.ts system:migrate:rollback",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"testRegex": "auth.e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
},
|
||||
|
||||
@@ -11,6 +11,8 @@ const config: PlaywrightTestConfig = {
|
||||
workers: 1,
|
||||
// Test directory
|
||||
testDir: path.join(__dirname, 'e2e'),
|
||||
// Only run authentication tests
|
||||
testMatch: 'authentication.spec.ts',
|
||||
// If a test fails, retry it additional 2 times
|
||||
retries: 0,
|
||||
// Artifacts folder where screenshots, videos, and traces are stored.
|
||||
|
||||
Reference in New Issue
Block a user