Skip to content

Use query lib

Use query lib #4293

Workflow file for this run

name: "Tests"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
IMAGE: databases-dev
CACHE_KEY: databases-dev-${{ github.event.pull_request.head.sha || github.sha }}
CACHE_5_KEY: databases-dev-cache-5-${{ github.event.pull_request.head.sha || github.sha }}
on: [pull_request, workflow_dispatch]
jobs:
setup:
name: Setup & Build Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Build Docker Image
uses: docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6 # v3.3.1
with:
context: .
file: Dockerfile
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
- name: Cache Docker Image
uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Load Cache
uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0
with:
key: ${{ env.CACHE_KEY }}
path: /tmp/${{ env.IMAGE }}.tar
fail-on-cache-miss: true
- name: Load and Start Services
run: |
docker load --input /tmp/${{ env.IMAGE }}.tar
docker compose up -d --wait
- name: Run Unit Tests
run: docker compose exec -e XDEBUG_MODE=off tests vendor/bin/paratest --configuration phpunit.xml --functional --processes 4 /usr/src/code/tests/unit
adapter_test:
name: "Adapter Tests (${{ matrix.adapter }})"
runs-on: ubuntu-latest
needs: setup
strategy:
fail-fast: false
matrix:
include:
- adapter: MongoDB
profiles: "--profile mongo"
- adapter: MariaDB
profiles: "--profile mariadb"
- adapter: MySQL
profiles: "--profile mysql"
- adapter: Postgres
profiles: "--profile postgres"
- adapter: SQLite
profiles: ""
- adapter: Memory
profiles: ""
- adapter: Mirror
profiles: "--profile mariadb --profile mariadb-mirror --profile redis-mirror"
- adapter: Pool
profiles: "--profile mysql"
- adapter: Redis
profiles: ""
- adapter: SharedTables/MongoDB
profiles: "--profile mongo"
- adapter: SharedTables/MariaDB
profiles: "--profile mariadb"
- adapter: SharedTables/MySQL
profiles: "--profile mysql"
- adapter: SharedTables/Postgres
profiles: "--profile postgres"
- adapter: SharedTables/SQLite
profiles: ""
- adapter: SharedTables/Redis
profiles: ""
- adapter: Schemaless/MongoDB
profiles: "--profile mongo"
steps:
- name: checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Load Cache
uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0
with:
key: ${{ env.CACHE_KEY }}
path: /tmp/${{ env.IMAGE }}.tar
fail-on-cache-miss: true
- name: Load and Start Services
run: |
docker load --input /tmp/${{ env.IMAGE }}.tar
docker compose ${{ matrix.profiles }} up -d --wait
- name: Run Tests
run: docker compose exec -T -e XDEBUG_MODE=off tests vendor/bin/paratest --configuration phpunit.xml --functional --processes 4 /usr/src/code/tests/e2e/Adapter/${{matrix.adapter}}Test.php
setup_cache_5:
name: Setup & Build Docker Image (utopia-php/cache 5.x)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Build Docker Image
uses: docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6 # v3.3.1
with:
context: .
file: Dockerfile
build-args: |
UTOPIA_CACHE_VERSION=^5.1
push: false
tags: ${{ env.IMAGE }}
load: true
cache-from: |
type=gha
type=gha,scope=cache-5
cache-to: type=gha,mode=max,scope=cache-5
outputs: type=docker,dest=/tmp/${{ env.IMAGE }}.tar
- name: Cache Docker Image
uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0
with:
key: ${{ env.CACHE_5_KEY }}
path: /tmp/${{ env.IMAGE }}.tar
cache_5_test:
name: "Cache 5.x Tests (${{ matrix.suite }})"
runs-on: ubuntu-latest
needs: setup_cache_5
strategy:
fail-fast: false
matrix:
include:
- suite: Unit
profiles: ""
path: /usr/src/code/tests/unit
- suite: MariaDB
profiles: "--profile mariadb"
path: /usr/src/code/tests/e2e/Adapter/MariaDBTest.php
steps:
- name: checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Load Cache
uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0
with:
key: ${{ env.CACHE_5_KEY }}
path: /tmp/${{ env.IMAGE }}.tar
fail-on-cache-miss: true
- name: Load and Start Services
run: |
docker load --input /tmp/${{ env.IMAGE }}.tar
docker compose ${{ matrix.profiles }} up -d --wait
- name: Check utopia-php/cache Version
run: |
docker compose exec -T tests php -r '
require "vendor/autoload.php";
$version = \Composer\InstalledVersions::getPrettyVersion("utopia-php/cache");
echo "utopia-php/cache {$version}", PHP_EOL;
exit(\str_starts_with((string) $version, "5.") ? 0 : 1);
'
- name: Run Tests
run: docker compose exec -T -e XDEBUG_MODE=off tests vendor/bin/paratest --configuration phpunit.xml --functional --processes 4 ${{ matrix.path }}