Files
AppFlowy-Web/.github/workflows/integration-test.yml
2025-09-05 16:34:50 +08:00

128 lines
3.8 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
- 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: update_nginx_conf
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: Run Docker-Compose (without web service)
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=debug
run: |
# Pull and start all backend services (excluding web)
docker compose pull appflowy_cloud gotrue ai appflowy_worker
docker compose -f docker-compose-web-ci.yml up -d
# Wait for services to be ready
echo "Waiting for services to start..."
sleep 30
# Check health
for i in {1..30}; do
if curl -sf http://localhost/api/health > /dev/null 2>&1; then
echo "✓ Backend is ready"
break
fi
echo "Waiting for backend... (attempt $i/30)"
sleep 5
done
- name: Start dev server
run: |
pnpm run dev &
echo $! > dev-server.pid
# Wait for dev server
for i in {1..30}; do
if curl -sf http://localhost:3000 > /dev/null 2>&1; then
echo "✓ Dev server is ready"
break
fi
echo "Waiting for dev server... (attempt $i/30)"
sleep 3
done
- name: Run tests
run: pnpm cypress run --spec 'cypress/e2e/**/*.cy.ts'
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
cypress/screenshots/**
cypress/videos/**
cypress/logs/**
if-no-files-found: ignore
retention-days: 3
- name: Cleanup
if: always()
run: |
if [ -f dev-server.pid ]; then
kill $(cat dev-server.pid) || true
fi
cd AppFlowy-Cloud-Premium && docker compose down || true