Merge pull request #6198 from appwrite/chhore-parallelize-tests
chore: test parallel executions
This commit is contained in:
commit
2b939a57d0
4 changed files with 124 additions and 44 deletions
107
.github/workflows/tests.yml
vendored
107
.github/workflows/tests.yml
vendored
|
@ -4,28 +4,22 @@ concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
on: [pull_request]
|
env:
|
||||||
jobs:
|
IMAGE: appwrite-dev
|
||||||
tests:
|
CACHE_KEY: appwrite-dev-${{ github.event.pull_request.head.sha }}
|
||||||
name: Unit & E2E
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
|
on: [pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
setup:
|
||||||
|
name: Setup & Build Appwrite Image
|
||||||
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
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
|
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
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
@ -34,27 +28,94 @@ jobs:
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: false
|
push: false
|
||||||
tags: appwrite-dev
|
tags: ${{ env.IMAGE }}
|
||||||
load: true
|
load: true
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
outputs: type=docker,dest=/tmp/${{ env.IMAGE }}.tar
|
||||||
build-args: |
|
build-args: |
|
||||||
DEBUG=false
|
DEBUG=false
|
||||||
TESTING=true
|
TESTING=true
|
||||||
VERSION=dev
|
VERSION=dev
|
||||||
|
|
||||||
- name: Start Appwrite
|
- 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: |
|
run: |
|
||||||
|
docker load --input /tmp/${{ env.IMAGE }}.tar
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
sleep 30
|
sleep 10
|
||||||
|
|
||||||
- name: Doctor
|
- name: Doctor
|
||||||
run: |
|
run: docker compose exec -T appwrite doctor
|
||||||
docker compose logs appwrite
|
|
||||||
docker compose exec -T appwrite doctor
|
|
||||||
|
|
||||||
- name: Environment Variables
|
- name: Environment Variables
|
||||||
run: docker compose exec -T appwrite vars
|
run: docker compose exec -T appwrite vars
|
||||||
|
|
||||||
- name: Run Tests
|
- name: Run Unit Tests
|
||||||
run: docker compose exec -T appwrite test --debug
|
run: docker compose exec appwrite test /usr/src/code/tests/unit
|
||||||
|
|
||||||
|
e2e_test:
|
||||||
|
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,
|
||||||
|
]
|
||||||
|
|
||||||
|
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 ${{matrix.service}} Tests
|
||||||
|
run: docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug
|
|
@ -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