mirror of
https://github.com/AppFlowy-IO/AppFlowy-Web.git
synced 2025-12-19 01:47:11 +08:00
* chore: add editor integration test * chore: merge test * chore: merge test * chore: update * chore: merge tests * chore: add tests * chore: update * chore: add test * chore: update test * chore: update test * chore: update test * chore: update * chore: update * chore: update test * chore: update test
203 lines
6.9 KiB
YAML
203 lines
6.9 KiB
YAML
name: E2E Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
CLOUD_VERSION: latest-amd64
|
|
|
|
jobs:
|
|
# Run different test categories in parallel for 6x speedup
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false # Don't cancel other jobs if one fails
|
|
matrix:
|
|
# Group tests by directory/feature for parallel execution
|
|
test-group:
|
|
- name: "auth"
|
|
spec: "cypress/e2e/auth/**/*.cy.ts"
|
|
description: "Authentication (OAuth, OTP, Password, Login/Logout)"
|
|
- name: "editor"
|
|
spec: "cypress/e2e/editor/**/*.cy.ts"
|
|
description: "Document editing and formatting"
|
|
- name: "database"
|
|
spec: "cypress/e2e/database/**/*.cy.ts"
|
|
description: "Database and grid operations"
|
|
- name: "embedded"
|
|
spec: "cypress/e2e/embeded/database/**/*.cy.ts"
|
|
description: "Embedded database operations"
|
|
- name: "page"
|
|
spec: "cypress/e2e/page/**/*.cy.ts"
|
|
description: "Page management (create, delete, share, publish)"
|
|
- name: "chat"
|
|
spec: "cypress/e2e/chat/**/*.cy.ts"
|
|
description: "AI chat features"
|
|
- name: "account-space-user"
|
|
spec: "cypress/e2e/{account,space,user,app}/**/*.cy.ts"
|
|
description: "Account, Space, User, and App tests"
|
|
name: "${{ matrix.test-group.name }}"
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '24'
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v2
|
|
with:
|
|
version: 10.9.0
|
|
|
|
# Cache pnpm dependencies for faster installs
|
|
- name: Get pnpm store directory
|
|
id: pnpm-cache
|
|
shell: bash
|
|
run: |
|
|
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Cache pnpm dependencies
|
|
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-
|
|
|
|
# Cache Cypress binary for faster setup
|
|
- name: Cache Cypress binary
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.cache/Cypress
|
|
key: ${{ runner.os }}-cypress-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cypress-
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
pnpm install --frozen-lockfile
|
|
npx cypress install
|
|
|
|
- name: Setup environment
|
|
run: cp deploy.env .env
|
|
|
|
- name: Checkout AppFlowy-Cloud-Premium
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: AppFlowy-IO/AppFlowy-Cloud-Premium
|
|
ref: main
|
|
token: ${{ secrets.CI_TOKEN }}
|
|
path: AppFlowy-Cloud-Premium
|
|
|
|
- name: Setup AppFlowy Cloud
|
|
working-directory: AppFlowy-Cloud-Premium
|
|
run: |
|
|
# Copy and configure the cloud environment
|
|
cp deploy.env .env
|
|
|
|
# Configure authentication settings
|
|
sed -i 's/GOTRUE_EXTERNAL_GOOGLE_ENABLED=.*/GOTRUE_EXTERNAL_GOOGLE_ENABLED=true/' .env
|
|
sed -i 's|GOTRUE_MAILER_AUTOCONFIRM=.*|GOTRUE_MAILER_AUTOCONFIRM=true|' .env
|
|
sed -i 's|API_EXTERNAL_URL=.*|API_EXTERNAL_URL=http://localhost|' .env
|
|
sed -i 's|AI_OPENAI_API_KEY=.*|AI_OPENAI_API_KEY=${{ secrets.CI_OPENAI_API_KEY }}|' .env
|
|
sed -i 's|APPFLOWY_SPAM_DETECT_ENABLED=.*|APPFLOWY_SPAM_DETECT_ENABLED=false|' .env
|
|
|
|
|
|
- name: Log in to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
|
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
|
|
|
- name: Start Docker services
|
|
working-directory: AppFlowy-Cloud-Premium
|
|
env:
|
|
APPFLOWY_CLOUD_VERSION: ${{ env.CLOUD_VERSION }}
|
|
APPFLOWY_AI_VERSION: ${{ env.CLOUD_VERSION }}
|
|
APPFLOWY_WORKER_VERSION: ${{ env.CLOUD_VERSION }}
|
|
RUST_LOG: appflowy_cloud=info
|
|
run: |
|
|
# Pull and start all backend services
|
|
docker compose pull appflowy_cloud gotrue ai appflowy_worker
|
|
docker compose -f docker-compose-web-ci.yml up -d
|
|
|
|
# Extended health check with detailed logging
|
|
echo "Waiting for backend services..."
|
|
timeout 180 bash -c 'until curl -sf http://localhost/api/health > /dev/null 2>&1; do
|
|
echo "Waiting for backend... ($(date +%T))"
|
|
sleep 5
|
|
done' && echo "✓ Backend is ready" || (
|
|
echo "❌ Backend failed to start after 3 minutes"
|
|
echo "Docker container status:"
|
|
docker compose -f docker-compose-web-ci.yml ps
|
|
echo "Docker logs:"
|
|
docker compose -f docker-compose-web-ci.yml logs --tail=50
|
|
exit 1
|
|
)
|
|
|
|
# Run HTTP API integration tests (only once, in auth group)
|
|
- name: Run HTTP API integration tests
|
|
if: matrix.test-group.name == 'auth'
|
|
run: |
|
|
echo "Running HTTP API integration tests..."
|
|
pnpm run test:http-api
|
|
|
|
# Cache build artifacts
|
|
- name: Cache build
|
|
id: cache-build
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: dist
|
|
key: ${{ runner.os }}-build-${{ hashFiles('src/**/*', 'package.json', 'vite.config.ts', 'tsconfig.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-build-
|
|
|
|
- name: Build project
|
|
if: steps.cache-build.outputs.cache-hit != 'true'
|
|
run: pnpm run build
|
|
|
|
- name: Start preview server
|
|
run: |
|
|
pnpm run start &
|
|
echo $! > preview-server.pid
|
|
|
|
# Optimized preview server health check
|
|
timeout 60 bash -c 'until curl -sf http://localhost:3000 > /dev/null 2>&1; do
|
|
echo "Waiting for preview server... ($(date +%T))"
|
|
sleep 2
|
|
done' && echo "✓ Preview server is ready" || (echo "❌ Preview server failed to start" && exit 1)
|
|
|
|
- name: Run ${{ matrix.test-group.name }} tests
|
|
run: |
|
|
pnpm cypress run \
|
|
--spec '${{ matrix.test-group.spec }}' \
|
|
--config video=false
|
|
|
|
- name: Upload artifacts (${{ matrix.test-group.name }})
|
|
if: failure()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: test-results-${{ matrix.test-group.name }}
|
|
path: |
|
|
cypress/screenshots/**
|
|
cypress/logs/**
|
|
if-no-files-found: ignore
|
|
retention-days: 3
|
|
|
|
- name: Cleanup
|
|
if: always()
|
|
run: |
|
|
# Kill preview server
|
|
if [ -f preview-server.pid ]; then
|
|
kill $(cat preview-server.pid) 2>/dev/null || true
|
|
fi
|
|
pkill -f "vite preview" 2>/dev/null || true
|
|
|
|
# Stop Docker services
|
|
cd AppFlowy-Cloud-Premium && docker compose down || true |