134 lines
4.9 KiB
YAML
134 lines
4.9 KiB
YAML
name: AppFlowy-Cloud Integrations
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
paths:
|
|
- 'src/**'
|
|
- 'libs/**'
|
|
- 'services/**'
|
|
- 'admin_frontend/**'
|
|
pull_request:
|
|
branches: [ main ]
|
|
paths:
|
|
- 'src/**'
|
|
- 'libs/**'
|
|
- 'services/**'
|
|
- 'admin_frontend/**'
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
LOCALHOST_URL: http://localhost
|
|
LOCALHOST_WS: ws://localhost/ws
|
|
APPFLOWY_REDIS_URI: redis://redis:6379
|
|
LOCALHOST_GOTRUE: http://localhost/gotrue
|
|
DATABASE_URL: postgres://postgres:password@localhost:5432/postgres
|
|
SQLX_OFFLINE: true
|
|
|
|
jobs:
|
|
setup:
|
|
name: Setup Environment
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Install prerequisites
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install protobuf-compiler
|
|
sudo update-ca-certificates
|
|
|
|
- name: Build Docker Images
|
|
run: |
|
|
docker compose build appflowy_cloud appflowy_history
|
|
|
|
- name: Push docker images to docker hub
|
|
run: |
|
|
docker tag appflowyinc/appflowy_cloud appflowyinc/appflowy_cloud:${GITHUB_SHA}
|
|
docker tag appflowyinc/appflowy_history appflowyinc/appflowy_history:${GITHUB_SHA}
|
|
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login --username appflowyinc --password-stdin
|
|
docker push appflowyinc/appflowy_cloud:${GITHUB_SHA}
|
|
docker push appflowyinc/appflowy_history:${GITHUB_SHA}
|
|
APPFLOWY_HISTORY_VERSION=${GITHUB_SHA} APPFLOWY_AI_VERSION=${GITHUB_SHA}
|
|
|
|
|
|
test:
|
|
name: Integration Tests
|
|
runs-on: ubuntu-latest
|
|
needs: setup
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- test_service: "appflowy_cloud"
|
|
test_cmd: "--workspace --exclude appflowy-history"
|
|
- test_service: "appflowy_history"
|
|
test_cmd: "-p appflowy-history"
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
workspaces: "AppFlowy-Cloud"
|
|
|
|
- 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=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/API_EXTERNAL_URL=http:\/\/localhost/' .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/APPFLOWY_AI_OPENAI_API_KEY=.*/APPFLOWY_AI_OPENAI_API_KEY=${{ secrets.CI_OPENAI_API_KEY }}/' .env
|
|
|
|
- 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: Run Docker-Compose
|
|
run: |
|
|
export APPFLOWY_HISTORY_VERSION=${GITHUB_SHA}
|
|
export APPFLOWY_CLOUD_VERSION=${GITHUB_SHA}
|
|
docker compose -f docker-compose-ci.yml up -d
|
|
docker ps -a
|
|
|
|
- name: install prerequisites
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install protobuf-compiler
|
|
|
|
- name: Run Tests
|
|
run: |
|
|
echo "Running tests for ${{ matrix.test_service }} with flags: ${{ matrix.test_cmd }}"
|
|
RUST_LOG="info" DISABLE_CI_TEST_LOG="true" cargo test ${{ matrix.test_cmd }}
|
|
|
|
- name: Install Node.js
|
|
uses: actions/setup-node@v2
|
|
with:
|
|
node-version: '14'
|
|
|
|
- name: Run WASM tests
|
|
working-directory: ./libs/wasm-test
|
|
run: |
|
|
cargo install wasm-pack
|
|
wasm-pack test --headless --firefox
|
|
|
|
cleanup:
|
|
name: Cleanup Docker Images
|
|
if: always()
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Remove Docker Images from Docker Hub
|
|
run: |
|
|
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "appflowyinc", "password": "${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
|
|
curl -s -X DELETE -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/appflowyinc/${{ matrix.test_service }}/tags/${GITHUB_SHA}/ |