commit
3700751592
145
.github/workflows/tests.yml
vendored
145
.github/workflows/tests.yml
vendored
|
@ -4,57 +4,118 @@ concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: appwrite-dev
|
||||||
|
CACHE_KEY: appwrite-dev-${{ github.event.pull_request.head.sha }}
|
||||||
|
|
||||||
on: [pull_request]
|
on: [pull_request]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
setup:
|
||||||
name: Unit & E2E
|
name: Setup & Build Appwrite Image
|
||||||
runs-on: ubuntu-latest
|
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:
|
steps:
|
||||||
- name: Checkout repository
|
- name: checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v2
|
||||||
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
|
- name: Load Cache
|
||||||
# the head of the pull request instead of the merge commit.
|
uses: actions/cache@v3
|
||||||
- run: git checkout HEAD^2
|
with:
|
||||||
if: ${{ github.event_name == 'pull_request' }}
|
key: ${{ env.CACHE_KEY }}
|
||||||
|
path: /tmp/${{ env.IMAGE }}.tar
|
||||||
|
fail-on-cache-miss: true
|
||||||
|
|
||||||
# This is a separate action that sets up buildx runner
|
- name: Load and Start Appwrite
|
||||||
- name: Set up Docker Buildx
|
run: |
|
||||||
uses: docker/setup-buildx-action@v2
|
docker load --input /tmp/${{ env.IMAGE }}.tar
|
||||||
|
docker compose up -d
|
||||||
|
sleep 10
|
||||||
|
|
||||||
- name: Build Appwrite
|
- name: Doctor
|
||||||
uses: docker/build-push-action@v3
|
run: docker compose exec -T appwrite doctor
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: false
|
|
||||||
tags: appwrite-dev
|
|
||||||
load: true
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
build-args: |
|
|
||||||
DEBUG=false
|
|
||||||
TESTING=true
|
|
||||||
VERSION=dev
|
|
||||||
|
|
||||||
- name: Start Appwrite
|
- name: Environment Variables
|
||||||
run: |
|
run: docker compose exec -T appwrite vars
|
||||||
docker compose up -d
|
|
||||||
sleep 30
|
|
||||||
|
|
||||||
- name: Doctor
|
- name: Run Unit Tests
|
||||||
run: |
|
run: docker compose exec appwrite test /usr/src/code/tests/unit
|
||||||
docker compose logs appwrite
|
|
||||||
docker compose exec -T appwrite doctor
|
|
||||||
|
|
||||||
- name: Environment Variables
|
e2e_test:
|
||||||
run: docker compose exec -T appwrite vars
|
name: E2E 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,
|
||||||
|
]
|
||||||
|
|
||||||
- name: Run Tests
|
steps:
|
||||||
run: docker compose exec -T appwrite test --debug
|
- 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 ${{matrix.service}} Tests
|
||||||
|
run: docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug
|
|
@ -8,7 +8,7 @@ tasks:
|
||||||
command: |
|
command: |
|
||||||
docker run --rm --interactive --tty \
|
docker run --rm --interactive --tty \
|
||||||
--volume $PWD:/app \
|
--volume $PWD:/app \
|
||||||
composer update \
|
composer install \
|
||||||
--ignore-platform-reqs \
|
--ignore-platform-reqs \
|
||||||
--optimize-autoloader \
|
--optimize-autoloader \
|
||||||
--no-plugins \
|
--no-plugins \
|
||||||
|
|
|
@ -65,7 +65,7 @@ Table of Contents:
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Appwrite is designed to run in a containerized environment. Running your server is as easy as running one command from your terminal. You can either run Appwrite on your localhost using docker-compose or on any other container orchestration tool, such as Kubernetes, Docker Swarm, or Rancher.
|
Appwrite is designed to run in a containerized environment. Running your server is as easy as running one command from your terminal. You can either run Appwrite on your localhost using docker-compose or on any other container orchestration tool, such as [Kubernetes](https://kubernetes.io/docs/home/), [Docker Swarm](https://docs.docker.com/engine/swarm/), or [Rancher](https://rancher.com/docs/).
|
||||||
|
|
||||||
The easiest way to start running your Appwrite server is by running our docker-compose file. Before running the installation command, make sure you have [Docker](https://www.docker.com/products/docker-desktop) installed on your machine:
|
The easiest way to start running your Appwrite server is by running our docker-compose file. Before running the installation command, make sure you have [Docker](https://www.docker.com/products/docker-desktop) installed on your machine:
|
||||||
|
|
||||||
|
|
|
@ -33,10 +33,9 @@ use Utopia\Logger\Logger;
|
||||||
use Utopia\Pools\Group;
|
use Utopia\Pools\Group;
|
||||||
use Utopia\Queue\Connection;
|
use Utopia\Queue\Connection;
|
||||||
|
|
||||||
Authorization::setDefaultStatus(false);
|
Authorization::disable();
|
||||||
Runtime::enableCoroutine(SWOOLE_HOOK_ALL);
|
Runtime::enableCoroutine(SWOOLE_HOOK_ALL);
|
||||||
|
|
||||||
|
|
||||||
Server::setResource('register', fn () => $register);
|
Server::setResource('register', fn () => $register);
|
||||||
|
|
||||||
Server::setResource('dbForConsole', function (Cache $cache, Registry $register) {
|
Server::setResource('dbForConsole', function (Cache $cache, Registry $register) {
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace Tests\E2E\Services\GraphQL;
|
namespace Tests\E2E\Services\GraphQL;
|
||||||
|
|
||||||
|
use Utopia\CLI\Console;
|
||||||
|
|
||||||
trait Base
|
trait Base
|
||||||
{
|
{
|
||||||
// Databases
|
// Databases
|
||||||
|
@ -1933,4 +1935,13 @@ trait Base
|
||||||
|
|
||||||
throw new \InvalidArgumentException('Invalid query type');
|
throw new \InvalidArgumentException('Invalid query type');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function-related methods
|
||||||
|
protected string $stdout = '';
|
||||||
|
protected string $stderr = '';
|
||||||
|
|
||||||
|
protected function packageCode($folder)
|
||||||
|
{
|
||||||
|
Console::execute('cd ' . realpath(__DIR__ . "/../../../resources/functions") . "/$folder && tar --exclude code.tar.gz -czf code.tar.gz .", '', $this->stdout, $this->stderr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,11 @@ class FunctionsClientTest extends Scope
|
||||||
{
|
{
|
||||||
$projectId = $this->getProject()['$id'];
|
$projectId = $this->getProject()['$id'];
|
||||||
$query = $this->getQuery(self::$CREATE_DEPLOYMENT);
|
$query = $this->getQuery(self::$CREATE_DEPLOYMENT);
|
||||||
$code = realpath(__DIR__ . '/../../../resources/functions') . "/php/code.tar.gz";
|
|
||||||
|
$folder = 'php';
|
||||||
|
$code = realpath(__DIR__ . '/../../../resources/functions') . "/$folder/code.tar.gz";
|
||||||
|
$this->packageCode($folder);
|
||||||
|
|
||||||
$gqlPayload = [
|
$gqlPayload = [
|
||||||
'operations' => \json_encode([
|
'operations' => \json_encode([
|
||||||
'query' => $query,
|
'query' => $query,
|
||||||
|
|
|
@ -81,7 +81,11 @@ class FunctionsServerTest extends Scope
|
||||||
{
|
{
|
||||||
$projectId = $this->getProject()['$id'];
|
$projectId = $this->getProject()['$id'];
|
||||||
$query = $this->getQuery(self::$CREATE_DEPLOYMENT);
|
$query = $this->getQuery(self::$CREATE_DEPLOYMENT);
|
||||||
$code = realpath(__DIR__ . '/../../../resources/functions') . "/php/code.tar.gz";
|
|
||||||
|
$folder = 'php';
|
||||||
|
$code = realpath(__DIR__ . '/../../../resources/functions') . "/$folder/code.tar.gz";
|
||||||
|
$this->packageCode($folder);
|
||||||
|
|
||||||
$gqlPayload = [
|
$gqlPayload = [
|
||||||
'operations' => \json_encode([
|
'operations' => \json_encode([
|
||||||
'query' => $query,
|
'query' => $query,
|
||||||
|
|
Loading…
Reference in a new issue