Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
name: "Linter"

on: [ pull_request ]

jobs:
lint:
name: Linter
name: Run Linter on PHP ${{ matrix.php }}
runs-on: ubuntu-latest

strategy:
matrix:
php: ['8.1', '8.2']

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}

- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2

- run: git checkout HEAD^2

- run: git checkout HEAD^2
- name: Install dependencies
run: composer update --ignore-platform-reqs --optimize-autoloader --no-plugins --no-scripts --prefer-dist

- name: Run Linter
run: |
docker run --rm -v $PWD:/app composer sh -c \
"composer install --profile --ignore-platform-reqs && composer lint"
- run: composer lint
12 changes: 5 additions & 7 deletions .github/workflows/tests.yml → .github/workflows/test80.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: "Tests"

on: [pull_request]
jobs:
tests:
name: Unit & E2E
test:
name: Unit & E2E (PHP 8.0)
runs-on: ubuntu-latest

steps:
Expand All @@ -22,8 +22,9 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile-8.0
push: false
tags: database-dev
tags: database-80
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
Expand All @@ -34,7 +35,4 @@ jobs:
sleep 10

- name: Run Tests
run: docker compose exec -T tests vendor/bin/phpunit --configuration phpunit.xml

- name: Check Coverage
run: docker compose exec -T tests vendor/bin/coverage-check tmp/clover.xml 90
run: docker compose exec -T tests80 vendor/bin/phpunit --configuration phpunit.xml
38 changes: 38 additions & 0 deletions .github/workflows/test81.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "Tests"

on: [pull_request]
jobs:
test:
name: Unit & E2E (PHP 8.1)
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2
submodules: recursive

- run: git checkout HEAD^2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile-8.1
push: false
tags: database-81
load: true
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Start Databases
run: |
docker compose up -d
sleep 10

- name: Run Tests
run: docker compose exec -T tests81 vendor/bin/phpunit --configuration phpunit.xml
38 changes: 38 additions & 0 deletions .github/workflows/test82.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "Tests"

on: [pull_request]
jobs:
test:
name: Unit & E2E (PHP 8.2)
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2
submodules: recursive

- run: git checkout HEAD^2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile-8.2
push: false
tags: database-82
load: true
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Start Databases
run: |
docker compose up -d
sleep 10

- name: Run Tests
run: docker compose exec -T tests82 vendor/bin/phpunit --configuration phpunit.xml
File renamed without changes.
93 changes: 93 additions & 0 deletions Dockerfile-8.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
FROM composer:2.0 as composer

ARG TESTING=false
ENV TESTING=$TESTING

WORKDIR /usr/local/src/

COPY composer.lock /usr/local/src/
COPY composer.json /usr/local/src/

RUN composer install --ignore-platform-reqs --optimize-autoloader \
--no-plugins --no-scripts --prefer-dist

FROM php:8.1-cli-alpine as compile

ENV PHP_REDIS_VERSION=5.3.4 \
PHP_SWOOLE_VERSION=v4.8.0 \
PHP_MONGO_VERSION=1.11.1

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN \
apk update \
&& apk add --no-cache postgresql-libs postgresql-dev make automake autoconf gcc g++ git brotli-dev \
&& docker-php-ext-install opcache pgsql pdo_mysql pdo_pgsql \
&& apk del postgresql-dev \
&& rm -rf /var/cache/apk/*

# Redis Extension
FROM compile AS redis
RUN \
git clone --depth 1 --branch $PHP_REDIS_VERSION https://github.com/phpredis/phpredis.git \
&& cd phpredis \
&& phpize \
&& ./configure \
&& make && make install

## Swoole Extension
FROM compile AS swoole
RUN \
git clone --depth 1 --branch $PHP_SWOOLE_VERSION https://github.com/swoole/swoole-src.git \
&& cd swoole-src \
&& phpize \
&& ./configure --enable-http2 \
&& make && make install

## MongoDB Extension
FROM compile AS mongodb
RUN \
git clone --depth 1 --branch $PHP_MONGO_VERSION https://github.com/mongodb/mongo-php-driver.git \
&& cd mongo-php-driver \
&& git submodule update --init \
&& phpize \
&& ./configure \
&& make && make install

## PCOV Extension
FROM compile AS pcov
RUN \
git clone https://github.com/krakjoe/pcov.git \
&& cd pcov \
&& phpize \
&& ./configure --enable-pcov \
&& make && make install

FROM compile as final

LABEL maintainer="team@appwrite.io"

WORKDIR /usr/src/code

RUN echo extension=redis.so >> /usr/local/etc/php/conf.d/redis.ini
RUN echo extension=swoole.so >> /usr/local/etc/php/conf.d/swoole.ini
RUN echo extension=mongodb.so >> /usr/local/etc/php/conf.d/mongodb.ini
RUN echo extension=pcov.so >> /usr/local/etc/php/conf.d/pcov.ini

RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

RUN echo "opcache.enable_cli=1" >> $PHP_INI_DIR/php.ini

RUN echo "memory_limit=1024M" >> $PHP_INI_DIR/php.ini

COPY --from=composer /usr/local/src/vendor /usr/src/code/vendor
COPY --from=swoole /usr/local/lib/php/extensions/no-debug-non-zts-20210902/swoole.so /usr/local/lib/php/extensions/no-debug-non-zts-20210902/
COPY --from=redis /usr/local/lib/php/extensions/no-debug-non-zts-20210902/redis.so /usr/local/lib/php/extensions/no-debug-non-zts-20210902/
COPY --from=mongodb /usr/local/lib/php/extensions/no-debug-non-zts-20210902/mongodb.so /usr/local/lib/php/extensions/no-debug-non-zts-20210902/
COPY --from=pcov /usr/local/lib/php/extensions/no-debug-non-zts-20210902/pcov.so /usr/local/lib/php/extensions/no-debug-non-zts-20210902/

# Add Source Code
COPY ./bin /usr/src/code/bin
COPY ./src /usr/src/code/src

CMD [ "tail", "-f", "/dev/null" ]
94 changes: 94 additions & 0 deletions Dockerfile-8.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
FROM composer:2.0 as composer

ARG TESTING=false
ENV TESTING=$TESTING

WORKDIR /usr/local/src/

COPY composer.lock /usr/local/src/
COPY composer.json /usr/local/src/

RUN composer install --ignore-platform-reqs --optimize-autoloader \
--no-plugins --no-scripts --prefer-dist

FROM php:8.2-cli-alpine3.18 as compile

ENV PHP_REDIS_VERSION=5.3.4 \
PHP_SWOOLE_VERSION=v4.8.0 \
PHP_MONGO_VERSION=1.11.1

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN \
apk update \
linux-headers \
&& apk add --no-cache postgresql-libs postgresql-dev make automake autoconf gcc g++ git brotli-dev \
&& docker-php-ext-install opcache pgsql pdo_mysql pdo_pgsql \
&& apk del postgresql-dev \
&& rm -rf /var/cache/apk/*

# Redis Extension
FROM compile AS redis
RUN \
git clone --depth 1 --branch $PHP_REDIS_VERSION https://github.com/phpredis/phpredis.git \
&& cd phpredis \
&& phpize \
&& ./configure \
&& make && make install

## Swoole Extension
FROM compile AS swoole
RUN \
git clone --depth 1 --branch $PHP_SWOOLE_VERSION https://github.com/swoole/swoole-src.git \
&& cd swoole-src \
&& phpize \
&& ./configure --enable-http2 \
&& make && make install

## MongoDB Extension
FROM compile AS mongodb
RUN \
git clone --depth 1 --branch $PHP_MONGO_VERSION https://github.com/mongodb/mongo-php-driver.git \
&& cd mongo-php-driver \
&& git submodule update --init \
&& phpize \
&& ./configure \
&& make && make install

## PCOV Extension
FROM compile AS pcov
RUN \
git clone https://github.com/krakjoe/pcov.git \
&& cd pcov \
&& phpize \
&& ./configure --enable-pcov \
&& make && make install

FROM compile as final

LABEL maintainer="team@appwrite.io"

WORKDIR /usr/src/code

RUN echo extension=redis.so >> /usr/local/etc/php/conf.d/redis.ini
RUN echo extension=swoole.so >> /usr/local/etc/php/conf.d/swoole.ini
RUN echo extension=mongodb.so >> /usr/local/etc/php/conf.d/mongodb.ini
RUN echo extension=pcov.so >> /usr/local/etc/php/conf.d/pcov.ini

RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

RUN echo "opcache.enable_cli=1" >> $PHP_INI_DIR/php.ini

RUN echo "memory_limit=1024M" >> $PHP_INI_DIR/php.ini

COPY --from=composer /usr/local/src/vendor /usr/src/code/vendor
COPY --from=swoole /usr/local/lib/php/extensions/no-debug-non-zts-20220829/swoole.so /usr/local/lib/php/extensions/no-debug-non-zts-20220829/
COPY --from=redis /usr/local/lib/php/extensions/no-debug-non-zts-20220829/redis.so /usr/local/lib/php/extensions/no-debug-non-zts-20220829/
COPY --from=mongodb /usr/local/lib/php/extensions/no-debug-non-zts-20220829/mongodb.so /usr/local/lib/php/extensions/no-debug-non-zts-20220829/
COPY --from=pcov /usr/local/lib/php/extensions/no-debug-non-zts-20220829/pcov.so /usr/local/lib/php/extensions/no-debug-non-zts-20220829/

# Add Source Code
COPY ./bin /usr/src/code/bin
COPY ./src /usr/src/code/src

CMD [ "tail", "-f", "/dev/null" ]
39 changes: 36 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,44 @@ version: '3.1'

services:

tests:
container_name: tests
image: database-dev
tests80:
container_name: tests80
image: database-80
build:
context: .
dockerfile: Dockerfile-8.0
networks:
- database
volumes:
- ./bin:/usr/src/code/bin
- ./src:/usr/src/code/src
- ./tests:/usr/src/code/tests
- ./phpunit.xml:/usr/src/code/phpunit.xml
ports:
- "8708:8708"

tests81:
container_name: tests81
image: database-81
build:
context: .
dockerfile: Dockerfile-8.1
networks:
- database
volumes:
- ./bin:/usr/src/code/bin
- ./src:/usr/src/code/src
- ./tests:/usr/src/code/tests
- ./phpunit.xml:/usr/src/code/phpunit.xml
ports:
- "8708:8708"

tests82:
container_name: tests82
image: database-82
build:
context: .
dockerfile: Dockerfile-8.2
networks:
- database
volumes:
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Adapter/MariaDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ public function find(string $collection, array $queries = [], ?int $limit = 25,
$orderType = $orderType === Database::ORDER_ASC ? Database::ORDER_DESC : Database::ORDER_ASC;
}

$orders[] = "`${attribute}` ${orderType}";
$orders[] = "`{$attribute}` {$orderType}";
}

// Allow after pagination without any order
Expand Down
Loading