mirror of
https://github.com/AppFlowy-IO/AppFlowy-Web.git
synced 2025-12-19 01:47:11 +08:00
174 lines
5.5 KiB
YAML
174 lines
5.5 KiB
YAML
name: E2E Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
pull_request:
|
|
branches: [main, develop]
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
CLOUD_VERSION: latest-amd64
|
|
|
|
jobs:
|
|
run_e2e_tests:
|
|
runs-on: ubuntu-latest
|
|
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
|
|
- name: Run HTTP API integration tests
|
|
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 tests
|
|
run: |
|
|
pnpm cypress run \
|
|
--spec 'cypress/e2e/**/*.cy.ts' \
|
|
--config video=false
|
|
|
|
- name: Upload artifacts
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: test-results
|
|
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 |