150 lines
3.7 KiB
YAML
150 lines
3.7 KiB
YAML
name: "Tests"
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
IMAGE: appwrite-dev
|
|
CACHE_KEY: appwrite-dev-${{ github.event.pull_request.head.sha }}
|
|
|
|
on: [pull_request]
|
|
|
|
jobs:
|
|
setup:
|
|
name: Setup & Build Appwrite Image
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Build Appwrite
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
context: .
|
|
push: false
|
|
tags: ${{ env.IMAGE }}
|
|
load: true
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
outputs: type=docker,dest=/tmp/${{ env.IMAGE }}.tar
|
|
build-args: |
|
|
DEBUG=false
|
|
TESTING=true
|
|
VERSION=dev
|
|
|
|
- name: Cache Docker Image
|
|
uses: actions/cache@v3
|
|
with:
|
|
key: ${{ env.CACHE_KEY }}
|
|
path: /tmp/${{ env.IMAGE }}.tar
|
|
|
|
unit_test:
|
|
name: Unit Test
|
|
runs-on: ubuntu-latest
|
|
needs: setup
|
|
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Load Cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
key: ${{ env.CACHE_KEY }}
|
|
path: /tmp/${{ env.IMAGE }}.tar
|
|
fail-on-cache-miss: true
|
|
|
|
- name: Load and Start Appwrite
|
|
run: |
|
|
docker load --input /tmp/${{ env.IMAGE }}.tar
|
|
docker compose up -d
|
|
sleep 10
|
|
|
|
- name: Doctor
|
|
run: docker compose exec -T appwrite doctor
|
|
|
|
- name: Environment Variables
|
|
run: docker compose exec -T appwrite vars
|
|
|
|
- name: Run Unit Tests
|
|
run: docker compose exec appwrite test /usr/src/code/tests/unit
|
|
|
|
e2e_general_test:
|
|
name: E2E General Test
|
|
runs-on: ubuntu-latest
|
|
needs: setup
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Load Cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
key: ${{ env.CACHE_KEY }}
|
|
path: /tmp/${{ env.IMAGE }}.tar
|
|
fail-on-cache-miss: true
|
|
|
|
- name: Load and Start Appwrite
|
|
run: |
|
|
docker load --input /tmp/${{ env.IMAGE }}.tar
|
|
docker compose up -d
|
|
sleep 10
|
|
|
|
- name: Run General Tests
|
|
run: docker compose exec -T appwrite test /usr/src/code/tests/e2e/General --debug
|
|
|
|
e2e_service_test:
|
|
name: E2E Service Test
|
|
runs-on: ubuntu-latest
|
|
needs: setup
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
service:
|
|
[
|
|
Account,
|
|
Avatars,
|
|
Console,
|
|
Databases,
|
|
Functions,
|
|
GraphQL,
|
|
Health,
|
|
Locale,
|
|
Projects,
|
|
Realtime,
|
|
Storage,
|
|
Teams,
|
|
Users,
|
|
Webhooks,
|
|
VCS,
|
|
Messaging,
|
|
]
|
|
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Load Cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
key: ${{ env.CACHE_KEY }}
|
|
path: /tmp/${{ env.IMAGE }}.tar
|
|
fail-on-cache-miss: true
|
|
|
|
- name: Load and Start Appwrite
|
|
run: |
|
|
docker load --input /tmp/${{ env.IMAGE }}.tar
|
|
docker compose up -d
|
|
sleep 25
|
|
|
|
- name: Run ${{matrix.service}} Tests
|
|
run: docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug
|
|
|
|
- name: Run ${{matrix.service}} Shared Tables Tests
|
|
run: _APP_DATABASE_SHARED_TABLES=database_db_main docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug
|