Skip to content

Commit

Permalink
Move phpunit tests for postgres and mysql to CI workflow on GitHub Ac…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
teohhanhui committed Oct 15, 2019
1 parent b81ca8d commit b959c6a
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 34 deletions.
128 changes: 128 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,134 @@ jobs:
- name: Run PHPUnit tests
run: vendor/bin/phpunit --colors=always

phpunit-postgresql:
name: PHPUnit (PHP ${{ matrix.php }}) (PostgreSQL)
runs-on: ubuntu-latest
container:
image: php:${{ matrix.php }}-alpine
services:
postgres:
image: postgres:10-alpine
env:
POSTGRES_DB: api_platform_test
POSTGRES_PASSWORD: hk7dFAByeQVVxpLtmZ6GVUzP
POSTGRES_USER: api-platform
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
strategy:
matrix:
php:
- '7.3'
fail-fast: false
env:
APP_ENV: postgres
DATABASE_URL: postgres://api-platform:hk7dFAByeQVVxpLtmZ6GVUzP@postgres/api_platform_test
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install system packages
run: |
apk add \
unzip \
- name: Install PHP extensions
run: |
apk add \
$PHPIZE_DEPS \
postgresql-dev \
;
docker-php-ext-install -j$(nproc) \
pdo_pgsql \
;
- name: Install mongodb PHP extension
if: matrix.php != '7.1'
run: |
apk add $PHPIZE_DEPS
pecl install mongodb-1.5.5
docker-php-ext-enable mongodb
- name: Disable PHP memory limit
run: echo 'memory_limit=-1' >> /usr/local/etc/php/php.ini
- name: Install Composer
run: wget -qO - https://raw.githubusercontent.com/composer/getcomposer.org/fb22b78362d31c0d2bf516d1f8cdfd2745caa431/web/installer | php -- --install-dir=/usr/local/bin --filename=composer --quiet
- name: Install Symfony Flex
run: |
composer global require --prefer-dist --no-progress --no-suggest --ansi \
symfony/flex
- name: Remove Doctrine MongoDB ODM
if: matrix.php == '7.1'
run: |
composer remove --dev --no-progress --no-update --ansi \
doctrine/mongodb-odm \
doctrine/mongodb-odm-bundle \
- name: Update project dependencies
run: composer update --no-progress --no-suggest --ansi
- name: Clear test app cache
run: tests/Fixtures/app/console cache:clear --ansi
- name: Run PHPUnit tests
run: vendor/bin/phpunit --colors=always

phpunit-mysql:
name: PHPUnit (PHP ${{ matrix.php }}) (MySQL)
runs-on: ubuntu-latest
container:
image: php:${{ matrix.php }}-alpine
services:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: api_platform_test
MYSQL_PASSWORD: LUhGR5tJ7WA2gbGumknCYBcB
MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
MYSQL_USER: api-platform
options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 5
strategy:
matrix:
php:
- '7.3'
fail-fast: false
env:
APP_ENV: mysql
DATABASE_URL: mysql://api-platform:LUhGR5tJ7WA2gbGumknCYBcB@mysql/api_platform_test
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install system packages
run: |
apk add \
unzip \
- name: Install PHP extensions
run: |
apk add \
$PHPIZE_DEPS \
;
docker-php-ext-install -j$(nproc) \
pdo_mysql \
;
- name: Install mongodb PHP extension
if: matrix.php != '7.1'
run: |
apk add $PHPIZE_DEPS
pecl install mongodb-1.5.5
docker-php-ext-enable mongodb
- name: Disable PHP memory limit
run: echo 'memory_limit=-1' >> /usr/local/etc/php/php.ini
- name: Install Composer
run: wget -qO - https://raw.githubusercontent.com/composer/getcomposer.org/fb22b78362d31c0d2bf516d1f8cdfd2745caa431/web/installer | php -- --install-dir=/usr/local/bin --filename=composer --quiet
- name: Install Symfony Flex
run: |
composer global require --prefer-dist --no-progress --no-suggest --ansi \
symfony/flex
- name: Remove Doctrine MongoDB ODM
if: matrix.php == '7.1'
run: |
composer remove --dev --no-progress --no-update --ansi \
doctrine/mongodb-odm \
doctrine/mongodb-odm-bundle \
- name: Update project dependencies
run: composer update --no-progress --no-suggest --ansi
- name: Clear test app cache
run: tests/Fixtures/app/console cache:clear --ansi
- name: Run PHPUnit tests
run: vendor/bin/phpunit --colors=always

phpunit-no-deprecations:
name: PHPUnit (PHP ${{ matrix.php }}) (no deprecations)
runs-on: ubuntu-latest
Expand Down
26 changes: 16 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ cache:
.steps:
- &clear-test-app-cache |
tests/Fixtures/app/console cache:clear
- &create-test-database |
tests/Fixtures/app/console doctrine:database:create
- &disable-php-memory-limit |
echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- &disable-xdebug-php-extension |
Expand Down Expand Up @@ -151,8 +153,13 @@ jobs:
- *validate-openapi-v3-json
- *validate-openapi-v3-yaml

- php: '7.3'
env: APP_ENV=postgres
- name: 'Behat (PHP 7.3) (PostgreSQL)'
php: '7.3'
env: >-
APP_ENV=postgres
DATABASE_URL=postgres://postgres:@localhost/api_platform_test
addons:
postgresql: '10'
services:
- postgresql
before_install:
Expand All @@ -164,18 +171,19 @@ jobs:
- *update-project-dependencies
before_script:
- *clear-test-app-cache
- psql --command 'CREATE DATABASE api_platform_test;' --username postgres
- *create-test-database
script:
- *run-phpunit-tests
- *clear-test-app-cache
- vendor/bin/behat --format=progress --profile=postgres --no-interaction
- *validate-openapi-v2-json
- *validate-openapi-v2-yaml
- *validate-openapi-v3-json
- *validate-openapi-v3-yaml

- php: '7.3'
env: APP_ENV=mysql
- name: 'Behat (PHP 7.3) (MySQL)'
php: '7.3'
env: >-
APP_ENV=mysql
DATABASE_URL=mysql://travis:@localhost/api_platform_test
services:
- mysql
before_install:
Expand All @@ -187,10 +195,8 @@ jobs:
- *update-project-dependencies
before_script:
- *clear-test-app-cache
- mysql --execute 'CREATE DATABASE api_platform_test;'
- *create-test-database
script:
- *run-phpunit-tests
- *clear-test-app-cache
- *run-behat-tests
- *validate-openapi-v2-json
- *validate-openapi-v2-yaml
Expand Down
16 changes: 9 additions & 7 deletions tests/Fixtures/app/config/config_mysql.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
imports:
- { resource: parameters_mysql.yml }
- { resource: config_test.yml }

parameters:
env(DATABASE_URL): mysql://root:@localhost/api_platform_test
env(MYSQL_VERSION): '5.7'

doctrine:
dbal:
driver: 'pdo_mysql'
dbname: '%dbname%'
user: '%user%'
password: '%password%'
host: '%host%'
driver: pdo_mysql
url: '%env(resolve:DATABASE_URL)%'
path: ~
server_version: '%env(MYSQL_VERSION)%'
types:
uuid: Ramsey\Uuid\Doctrine\UuidType
uuid: Ramsey\Uuid\Doctrine\UuidType
16 changes: 9 additions & 7 deletions tests/Fixtures/app/config/config_postgres.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
imports:
- { resource: parameters_postgres.yml }
- { resource: config_test.yml }

parameters:
env(DATABASE_URL): postgres://postgres:@localhost/api_platform_test
env(POSTGRES_VERSION): '10'

doctrine:
dbal:
driver: 'pdo_pgsql'
dbname: '%dbname%'
user: '%user%'
password: '%password%'
host: '%host%'
driver: pdo_pgsql
url: '%env(resolve:DATABASE_URL)%'
path: ~
server_version: '%env(POSTGRES_VERSION)%'
types:
uuid: Ramsey\Uuid\Doctrine\UuidType
uuid: Ramsey\Uuid\Doctrine\UuidType
5 changes: 0 additions & 5 deletions tests/Fixtures/app/config/parameters_mysql.yml

This file was deleted.

5 changes: 0 additions & 5 deletions tests/Fixtures/app/config/parameters_postgres.yml

This file was deleted.

0 comments on commit b959c6a

Please sign in to comment.