1
0
Fork 0
mirror of synced 2024-09-29 08:51:28 +13:00
appwrite/.github/workflows/tests.yml

219 lines
7.2 KiB
YAML
Raw Normal View History

name: "Tests"
2022-02-10 08:29:26 +13:00
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
2023-09-09 07:03:55 +12:00
env:
2023-09-09 10:11:40 +12:00
IMAGE: appwrite-dev
2023-10-27 05:43:50 +13:00
CACHE_KEY: appwrite-dev-${{ github.event.pull_request.head.sha }}
2023-09-09 07:03:55 +12:00
on: [pull_request]
2023-09-09 08:07:13 +12:00
jobs:
2023-09-09 07:03:55 +12:00
setup:
name: Setup & Build Appwrite Image
runs-on: ubuntu-latest
steps:
2023-10-27 05:15:52 +13:00
- 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:
2023-10-27 05:24:14 +13:00
key: ${{ env.CACHE_KEY }}
2023-10-27 05:15:52 +13:00
path: /tmp/${{ env.IMAGE }}.tar
2023-09-09 06:49:02 +12:00
2023-09-09 12:00:06 +12:00
unit_test:
name: Unit Test
runs-on: ubuntu-latest
needs: setup
steps:
- name: checkout
uses: actions/checkout@v2
2023-10-27 05:15:52 +13:00
2023-09-09 12:00:06 +12:00
- name: Load Cache
uses: actions/cache@v3
with:
2023-10-27 05:24:14 +13:00
key: ${{ env.CACHE_KEY }}
2023-09-09 13:29:56 +12:00
path: /tmp/${{ env.IMAGE }}.tar
2023-09-09 12:00:06 +12:00
fail-on-cache-miss: true
2023-10-27 05:15:52 +13:00
2023-09-09 12:00:06 +12:00
- name: Load and Start Appwrite
2023-10-27 05:15:52 +13:00
run: |
2023-09-09 13:29:56 +12:00
docker load --input /tmp/${{ env.IMAGE }}.tar
2023-09-09 12:00:06 +12:00
docker compose up -d
sleep 10
2023-09-09 11:12:11 +12:00
2023-09-09 12:00:06 +12:00
- name: Doctor
run: docker compose exec -T appwrite doctor
2023-09-09 11:12:11 +12:00
2023-09-09 12:00:06 +12:00
- name: Environment Variables
2023-10-27 05:15:52 +13:00
run: docker compose exec -T appwrite vars
2023-09-09 11:12:11 +12:00
2023-09-09 12:00:06 +12:00
- name: Run Unit Tests
2023-10-27 05:15:52 +13:00
run: docker compose exec appwrite test /usr/src/code/tests/unit
2023-09-09 11:12:11 +12:00
2024-01-04 08:48:31 +13:00
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
2023-09-09 12:11:14 +12:00
runs-on: ubuntu-latest
needs: setup
strategy:
fail-fast: false
matrix:
2023-10-27 05:26:13 +13:00
service:
2023-10-27 05:15:52 +13:00
[
2024-02-25 00:27:09 +13:00
Account,
Avatars,
Console,
Databases,
2023-10-27 05:15:52 +13:00
Functions,
2024-02-25 00:27:09 +13:00
GraphQL,
Health,
Locale,
Projects,
Realtime,
Storage,
Teams,
Users,
Webhooks,
VCS,
Messaging,
2023-10-27 05:15:52 +13:00
]
2023-09-09 12:11:14 +12:00
steps:
- name: checkout
2023-10-27 05:24:14 +13:00
uses: actions/checkout@v3
2023-09-09 12:11:14 +12:00
- name: Load Cache
uses: actions/cache@v3
with:
2023-10-27 05:24:14 +13:00
key: ${{ env.CACHE_KEY }}
2023-09-09 13:29:56 +12:00
path: /tmp/${{ env.IMAGE }}.tar
2023-09-09 12:11:14 +12:00
fail-on-cache-miss: true
- name: Load and Start Appwrite
2023-10-27 05:15:52 +13:00
run: |
2023-09-09 13:29:56 +12:00
docker load --input /tmp/${{ env.IMAGE }}.tar
2023-09-09 12:11:14 +12:00
docker compose up -d
2024-02-25 00:20:31 +13:00
sleep 25
2023-10-27 05:15:52 +13:00
2023-10-27 05:26:13 +13:00
- name: Run ${{matrix.service}} Tests
2024-01-04 08:48:31 +13:00
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
2024-07-20 02:47:39 +12:00
benchamrking:
name: Benchmark
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout repository
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: |
sed -i 's/traefik/localhost/g' .env
docker load --input /tmp/${{ env.IMAGE }}.tar
docker compose up -d
sleep 10
- name: Install Oha
run: |
echo "deb [signed-by=/usr/share/keyrings/azlux-archive-keyring.gpg] http://packages.azlux.fr/debian/ stable main" | sudo tee /etc/apt/sources.list.d/azlux.list
sudo wget -O /usr/share/keyrings/azlux-archive-keyring.gpg https://azlux.fr/repo.gpg
sudo apt update
sudo apt install oha
- name: Benchmark PR
run: oha -z 180s http://localhost/v1/health/version -j > benchmark.json
- name: Cleaning
run: docker compose down -v
- name: Installing latest version
run: |
rm docker-compose.yml
rm .env
curl https://appwrite.io/install/compose -o docker-compose.yml
curl https://appwrite.io/install/env -o .env
sed -i 's/_APP_OPTIONS_ABUSE=enabled/_APP_OPTIONS_ABUSE=disabled/g' .env
docker compose up -d
sleep 10
- name: Benchmark Latest
run: oha -z 180s http://localhost/v1/health/version -j > benchmark-latest.json
- name: Prepare comment
run: |
echo '## :sparkles: Benchmark results' > benchmark.txt
echo ' ' >> benchmark.txt
2024-07-20 05:19:34 +12:00
echo "- Requests per second: $(jq -r '.summary.requestsPerSec|tonumber?|floor|tostring|[while(length>0;.[:-3])|.[-3:]]|reverse|join(",")' benchmark.json)" >> benchmark.txt
echo "- Requests with 200 status code: $(jq -r '.statusCodeDistribution."200"|tostring|[while(length>0;.[:-3])|.[-3:]]|reverse|join(",")' benchmark.json)" >> benchmark.txt
2024-07-20 05:40:15 +12:00
echo "- P99 latency: $(jq -r '.latencyPercentiles.p99' benchmark.json )" >> benchmark.txt
2024-07-20 02:47:39 +12:00
echo " " >> benchmark.txt
echo " " >> benchmark.txt
echo "## :zap: Benchmark Comparison" >> benchmark.txt
echo " " >> benchmark.txt
echo "| Metric | This PR | Latest version | " >> benchmark.txt
echo "| --- | --- | --- | " >> benchmark.txt
2024-07-20 05:40:15 +12:00
echo "| RPS | $(jq -r '.summary.requestsPerSec|tonumber?|floor|tostring|[while(length>0;.[:-3])|.[-3:]]|reverse|join(",")' benchmark.json) | $(jq -r '.summary.requestsPerSec|tonumber|floor|tostring|[while(length>0;.[:-3])|.[-3:]]|reverse|join(",")' benchmark-latest.json) | " >> benchmark.txt
echo "| 200 | $(jq -r '.statusCodeDistribution."200"|tostring|[while(length>0;.[:-3])|.[-3:]]|reverse|join(",")' benchmark.json) | $(jq -r '.statusCodeDistribution."200"|tostring|[while(length>0;.[:-3])|.[-3:]]|reverse|join(",")' benchmark-latest.json) | " >> benchmark.txt
echo "| P99 | $(jq -r '.latencyPercentiles.p99' benchmark.json ) | $(jq -r '.latencyPercentiles.p99' benchmark-latest.json ) | " >> benchmark.txt
2024-07-20 02:47:39 +12:00
- name: Save results
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: benchmark.json
path: benchmark.json
retention-days: 7
- name: Comment on PR
uses: thollander/actions-comment-pull-request@v2
with:
filePath: benchmark.txt