Skip to content

commercial-cloud-integration-ci #1419

commercial-cloud-integration-ci

commercial-cloud-integration-ci #1419

name: AppFlowy-Cloud Commercial Integrations
on:
repository_dispatch:
types: [commercial-cloud-integration-ci]
concurrency:
group: ${{ github.workflow }}-${{ github.event.client_payload.pr_number || github.run_id }}
cancel-in-progress: true
env:
LOCALHOST_URL: http://localhost
LOCALHOST_WS: ws://localhost/ws/v1
LOCALHOST_WS_V2: ws://localhost/ws/v2
APPFLOWY_REDIS_URI: redis://redis:6379
APPFLOWY_AI_REDIS_URL: redis://redis:6379
LOCALHOST_GOTRUE: http://localhost/gotrue
POSTGRES_PASSWORD: password
DATABASE_URL: postgres://postgres:password@localhost:5432/postgres
SQLX_OFFLINE: true
RUST_TOOLCHAIN: "1.86.0"
CLOUD_VERSION: "latest-amd64"
jobs:
setup:
name: Setup Environment and Build Images
runs-on: ubuntu-latest
steps:
- name: Checkout Private Repo
uses: actions/checkout@v4
with:
repository: AppFlowy-IO/AppFlowy-Cloud-Premium
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
ref: ${{ github.event.client_payload.pr_ref }}
- name: Install prerequisites
run: |
sudo apt-get update
sudo apt-get install protobuf-compiler
sudo update-ca-certificates
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Build Docker Images
run: |
export DOCKER_DEFAULT_PLATFORM=linux/amd64
cp deploy.env .env
docker compose build \
--parallel \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--build-arg PROFILE=debug \
--build-arg FEATURES="self-host-af, commercial-ci" \
appflowy_cloud
- name: Save Docker Images
run: |
docker save appflowyinc/appflowy_cloud_premium:latest | gzip > appflowy_cloud.tar.gz
- name: Upload Docker Images as Artifacts
uses: actions/upload-artifact@v4
with:
name: docker-images
path: |
appflowy_cloud.tar.gz
retention-days: 1
test:
name: Integration Tests
runs-on: ubuntu-latest
needs: setup
timeout-minutes: 60
steps:
- name: Checkout Private Repo
uses: actions/checkout@v4
with:
repository: AppFlowy-IO/AppFlowy-Cloud-Premium
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
ref: ${{ github.event.client_payload.pr_ref }}
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
workspaces: "AppFlowy-Cloud"
- name: Download Docker Images
uses: actions/download-artifact@v4
with:
name: docker-images
- name: Load Docker Images
run: |
docker load < appflowy_cloud.tar.gz
docker tag appflowyinc/appflowy_cloud_premium:latest appflowyinc/appflowy_cloud_premium:${{ env.CLOUD_VERSION }}
- name: Copy and rename deploy.env to .env
run: cp deploy.env .env
- name: Replace values in .env
run: |
# log level
sed -i 's|RUST_LOG=.*|RUST_LOG='appflowy_cloud=trace,appflowy_worker=trace,database=trace,indexer=trace'|' .env
sed -i 's|GOTRUE_SMTP_USER=.*|GOTRUE_SMTP_USER=${{ secrets.CI_GOTRUE_SMTP_USER }}|' .env
sed -i 's|GOTRUE_SMTP_PASS=.*|GOTRUE_SMTP_PASS=${{ secrets.CI_GOTRUE_SMTP_PASS }}|' .env
sed -i 's|GOTRUE_SMTP_ADMIN_EMAIL=.*|GOTRUE_SMTP_ADMIN_EMAIL=${{ secrets.CI_GOTRUE_SMTP_ADMIN_EMAIL }}|' .env
sed -i 's|GOTRUE_EXTERNAL_GOOGLE_ENABLED=.*|GOTRUE_EXTERNAL_GOOGLE_ENABLED=true|' .env
sed -i 's|GOTRUE_MAILER_AUTOCONFIRM=.*|GOTRUE_MAILER_AUTOCONFIRM=false|' .env
sed -i 's|API_EXTERNAL_URL=http://your-host/gotrue|API_EXTERNAL_URL=http://localhost/gotrue|' .env
sed -i 's|GOTRUE_RATE_LIMIT_EMAIL_SENT=100|GOTRUE_RATE_LIMIT_EMAIL_SENT=1000|' .env
sed -i 's|APPFLOWY_MAILER_SMTP_USERNAME=.*|APPFLOWY_MAILER_SMTP_USERNAME=${{ secrets.CI_GOTRUE_SMTP_USER }}|' .env
sed -i 's|APPFLOWY_MAILER_SMTP_PASSWORD=.*|APPFLOWY_MAILER_SMTP_PASSWORD=${{ secrets.CI_GOTRUE_SMTP_PASS }}|' .env
sed -i 's|AI_OPENAI_API_KEY=.*|AI_OPENAI_API_KEY=${{ secrets.CI_OPENAI_API_KEY }}|' .env
sed -i 's|AI_OPENAI_API_SUMMARY_MODEL=.*|AI_OPENAI_API_SUMMARY_MODEL="gpt-4o-mini"|' .env
sed -i 's|APPFLOWY_EMBEDDING_CHUNK_SIZE=.*|APPFLOWY_EMBEDDING_CHUNK_SIZE=500|' .env
sed -i 's|APPFLOWY_EMBEDDING_CHUNK_OVERLAP=.*|APPFLOWY_EMBEDDING_CHUNK_OVERLAP=50|' .env
sed -i 's|ANTHROPIC_API_KEY=.*|ANTHROPIC_API_KEY=${{ secrets.CI_AI_ANTHROPIC_API_KEY }}|' .env
sed -i 's|AI_APPFLOWY_HOST=.*|AI_APPFLOWY_HOST=http://localhost|' .env
sed -i 's|APPFLOWY_WEB_URL=.*|APPFLOWY_WEB_URL=http://localhost:3000|' .env
sed -i 's|.*APPFLOWY_S3_PRESIGNED_URL_ENDPOINT=.*|APPFLOWY_S3_PRESIGNED_URL_ENDPOINT=http://localhost/minio-api|' .env
sed -i 's|APPFLOWY_SPAM_USER_DETECT_THRESHOLD=.*|APPFLOWY_SPAM_USER_DETECT_THRESHOLD=1|' .env
# Ensure there's a newline at the end of .env before adding new variables
echo "" >> .env
echo 'APPFLOWY_CLOUD_BILLING_STRIPE_API_SECRET_KEY=${{ secrets.CI_APPFLOWY_CLOUD_BILLING_STRIPE_API_SECRET_KEY }}' >> .env
echo 'APPFLOWY_CLOUD_BILLING_STRIPE_WEBHOOK_URL=${{ secrets.CI_APPFLOWY_CLOUD_BILLING_STRIPE_WEBHOOK_URL }}' >> .env
echo 'APPFLOWY_BILLING_ENDPOINT_ID=${{ secrets.CI_APPFLOWY_BILLING_ENDPOINT_ID }}' >> .env
echo 'APPFLOWY_BILLING_SIGNING_SECRET=${{ secrets.CI_APPFLOWY_BILLING_SIGNING_SECRET }}' >> .env
echo 'APPFLOWY_SELF_HOST_BILLING_URL=http://appflowy_billing:4242' >> .env
shell: bash
- name: Update Nginx Configuration
# the wasm-pack headless tests will run on random ports, so we need to allow all origins
run: sed -i 's/http:\/\/127\.0\.0\.1:8000/http:\/\/127.0.0.1/g' nginx/nginx.conf
- 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
run: |
export APPFLOWY_WORKER_VERSION=${{ env.CLOUD_VERSION }}
export APPFLOWY_CLOUD_VERSION=${{ env.CLOUD_VERSION }}
export APPFLOWY_ADMIN_FRONTEND_VERSION=${{ env.CLOUD_VERSION }}
export APPFLOWY_AI_VERSION=${{ env.CLOUD_VERSION }}
docker compose -f docker-compose-ci.yml down
docker compose -f docker-compose-ci.yml up -d
- name: Wait for services to be ready
run: |
echo "Waiting for services to be ready..."
timeout 300 bash -c 'until curl -f http://localhost/api/health 2>/dev/null; do sleep 5; done' || echo "Health check timeout - proceeding anyway"
- name: Install prerequisites
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Run Tests
run: |
cat .env
RUST_LOG="info" DISABLE_CI_TEST_LOG="true" cargo test commercial_test --features=commercial-ci -- --test-threads=1
- name: Test Server Info Endpoint
run: |
# Make request to server-info endpoint and capture response
response=$(curl -s http://localhost/api/server-info)
if [ $? -ne 0 ]; then
echo "Failed to connect to server-info endpoint"
exit 1
fi
echo "Server info response: $response"
# Extract self_hosted field and assert it's true
self_hosted=$(echo "$response" | jq -r '.data.self_hosted')
if [ "$self_hosted" != "true" ]; then
echo "ERROR: self_hosted field is '$self_hosted', expected 'true'"
exit 1
fi
echo "✓ Server info test passed: self_hosted is true"
- name: appflowy cloud Logs
if: failure()
run: |
docker ps -a
docker compose -f docker-compose-ci.yml logs appflowy_cloud