1
0
Fork 0
mirror of synced 2024-07-30 10:46:35 +12:00
appwrite/.github/workflows/tests.yml
2023-09-08 22:03:32 +00:00

160 lines
3.9 KiB
YAML

name: "Tests"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
TAG: appwrite-dev
on: [pull_request]
jobs:
setup:
name: Setup & Build Appwrite Image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
# Fetch submodules
submodules: recursive
# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
# This is a separate action that sets up buildx runner
- 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.TAG }}
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=docker,dest=/tmp/${{ env.TAG }}.tar
build-args: |
DEBUG=false
TESTING=true
VERSION=dev
# - name: Cache Docker Image
# uses: actions/cache@v3
# with:
# key: ${{ env.TAG }}
# path: /tmp/${{ env.TAG }}.tar
# - name: Upload Docker Image
# uses: actions/upload-artifact@v3
# with:
# name: ${{ env.TAG }}
# path: /tmp/${{ env.TAG }}.tar
unit_test:
name: Unit Test
runs-on: ubuntu-latest
needs: setup
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 1
submodules: recursive
# - name: Download artifact
# uses: actions/download-artifact@v3
# with:
# name: ${{ env.TAG }}
# path: /tmp
- name: Load Cache
uses: actions/cache@v3
with:
key: ${{ env.TAG }}
path: /tmp/${{ env.TAG }}.tar
- name: Load Docker image
run: |
docker load --input /tmp/${{ env.TAG }}.tar
docker image ls -a
- name: Start Appwrite
run: |
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
accounts_test:
name: Accounts Test
runs-on: ubuntu-latest
needs: setup
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 1
submodules: recursive
- name: Load Cache
uses: actions/cache@v3
with:
key: ${{ env.TAG }}
path: /tmp/${{ env.TAG }}.tar
- name: Load Docker image
run: |
docker load --input /tmp/${{ env.TAG }}.tar
docker image ls -a
- name: Start Appwrite
run: |
docker compose up -d
sleep 10
- name: Run Accounts Tests
run: docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/Account --debug
# e2e_test:
# name: E2E Test
# runs-on: ubuntu-latest
# needs: build
# strategy:
# fail-fast: false
# matrix:
# services: [Account,Avatars,Console,Databases,Functions,GraphQL,Health,Locale,Projects,Realtime,Storage,Teams,Users,Webhooks]
# steps:
# - name: checkout
# uses: actions/checkout@v2
# with:
# fetch-depth: 2
# submodules: recursive
# - name: Start Appwrite
# run: |
# docker compose up -d
# sleep 30
# - name: Run ${{matrix.services}} Tests
# run: docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.services}} --debug