From 28dea63f4657949e4d889d59127eade9fa4bd380 Mon Sep 17 00:00:00 2001 From: Thibault Buathier Date: Thu, 18 Apr 2024 19:22:36 +0200 Subject: [PATCH 1/8] feat: add github ci --- .github/workflows/ci.yml | 67 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 42 ------------------------- 2 files changed, 67 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000000..83dc08521e2 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,67 @@ +name: CI + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-23.04 + strategy: + matrix: + php: [7.3, 7.4] + db_image_name: [mysql, mariadb, percona, postgres] + include: + - db_image_name: mysql + db_image_version: 8 + db: mysql + vars: '-e MYSQL_PASSWORD=travis -e MYSQL_DATABASE=doctrine_extensions_tests -e MYSQL_USER=travis -e MYSQL_ROOT_PASSWORD=travis' + db_port: 3306 + - db_image_name: mariadb + db_image_version: 11 + db: mysql + vars: '-e MYSQL_PASSWORD=travis -e MYSQL_DATABASE=doctrine_extensions_tests -e MYSQL_USER=travis -e MYSQL_ROOT_PASSWORD=travis' + db_port: 3306 + - db_image_name: percona + db_image_version: 8 + db: mysql + vars: '-e MYSQL_PASSWORD=travis -e MYSQL_DATABASE=doctrine_extensions_tests -e MYSQL_USER=travis -e MYSQL_ROOT_PASSWORD=travis' + db_port: 3306 + - db_image_name: postgres + db_image_version: 15 + db: mysql + vars: '-e POSTGRES_DB=doctrine_extensions_tests -e POSTGRES_USER=travis -e POSTGRES_PASSWORD=travis' + db_port: 5432 + + services: + database: + image: ${{ matrix.db_image }} + ports: + - ${{ matrix.db_port }}:{{ matrix.db_port }} + options: >- + ${{ matrix.vars }} + + steps: + - uses: actions/checkout@v3 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: mbstring, xml, ctype, iconv, intl, pdo_mysql, pdo_pgsql + coverage: none + + - name: Install dependencies + run: | + composer self-update + composer install --prefer-dist --optimize-autoloader --no-interaction --no-suggest + + - name: Run setup tests + run: vendor/bin/phpunit --configuration tests/config/${{ matrix.db }}.phpunit.xml tests/Oro/Tests/Connection/SetupTest.php + + - name: Run test suite + run: vendor/bin/phpunit --configuration tests/config/${{ matrix.db }}.phpunit.xml --testsuite="Oro Doctrine Extensions Test Suite" + + - name: Check code style + run: vendor/bin/phpcs src/ tests/ -p --encoding=utf-8 --extensions=php --standard=psr2 + + - name: Tear down tests + run: vendor/bin/phpunit --configuration tests/config/${{ matrix.db }}.phpunit.xml tests/Oro/Tests/Connection/TearDownTest.php \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c4d9a8fa86e..00000000000 --- a/.travis.yml +++ /dev/null @@ -1,42 +0,0 @@ -os: linux -dist: xenial -language: php - -jobs: - include: - - php: 7.3 - env: DB=mysql DB_IMAGE=mysql:8.0.3 VARS='-p 33060:3306 -e MYSQL_PASSWORD=travis -e MYSQL_DATABASE=doctrine_extensions_tests -e MYSQL_USER=travis -e MYSQL_ALLOW_EMPTY_PASSWORD=yes' - - php: 7.4 - env: DB=mysql DB_IMAGE=mysql:8.0.3 VARS='-p 33060:3306 -e MYSQL_PASSWORD=travis -e MYSQL_DATABASE=doctrine_extensions_tests -e MYSQL_USER=travis -e MYSQL_ALLOW_EMPTY_PASSWORD=yes' - - - php: 7.3 - env: DB=mysql DB_IMAGE=mariadb:10.1 VARS='-p 33060:3306 -e MYSQL_PASSWORD=travis -e MYSQL_DATABASE=doctrine_extensions_tests -e MYSQL_USER=travis -e MYSQL_ALLOW_EMPTY_PASSWORD=yes' - - php: 7.4 - env: DB=mysql DB_IMAGE=mariadb:10.1 VARS='-p 33060:3306 -e MYSQL_PASSWORD=travis -e MYSQL_DATABASE=doctrine_extensions_tests -e MYSQL_USER=travis -e MYSQL_ALLOW_EMPTY_PASSWORD=yes' - - - php: 7.3 - env: DB=mysql DB_IMAGE=percona:5.7 VARS='-p 33060:3306 -e MYSQL_PASSWORD=travis -e MYSQL_DATABASE=doctrine_extensions_tests -e MYSQL_USER=travis -e MYSQL_ALLOW_EMPTY_PASSWORD=yes' - - php: 7.4 - env: DB=mysql DB_IMAGE=percona:5.7 VARS='-p 33060:3306 -e MYSQL_PASSWORD=travis -e MYSQL_DATABASE=doctrine_extensions_tests -e MYSQL_USER=travis -e MYSQL_ALLOW_EMPTY_PASSWORD=yes' - - - php: 7.3 - env: DB=pgsql DB_IMAGE=postgres:9.6 VARS='-p 54320:5432 -e POSTGRES_DB=doctrine_extensions_tests -e POSTGRES_USER=travis -e POSTGRES_PASSWORD=travis' - - php: 7.4 - env: DB=pgsql DB_IMAGE=postgres:9.6 VARS='-p 54320:5432 -e POSTGRES_DB=doctrine_extensions_tests -e POSTGRES_USER=travis -e POSTGRES_PASSWORD=travis' - -install: - - composer self-update - - composer install --prefer-dist --optimize-autoloader --no-interaction --no-suggest - - docker pull ${DB_IMAGE} - - docker run -d --name database ${VARS} ${DB_IMAGE} - - sleep 30s - -before_script: - - vendor/bin/phpunit --configuration tests/config/$DB.phpunit.xml tests/Oro/Tests/Connection/SetupTest.php - -script: - - vendor/bin/phpunit --configuration tests/config/$DB.phpunit.xml --testsuite="Oro Doctrine Extensions Test Suite" - - vendor/bin/phpcs src/ tests/ -p --encoding=utf-8 --extensions=php --standard=psr2 - -after_success: - - vendor/bin/phpunit --configuration tests/config/$DB.phpunit.xml tests/Oro/Tests/Connection/TearDownTest.php From fc5885447e69052ef8f1109921295ae2a3292a8b Mon Sep 17 00:00:00 2001 From: Thibault Buathier Date: Thu, 18 Apr 2024 19:25:39 +0200 Subject: [PATCH 2/8] fix: use latest ubuntu --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 83dc08521e2..4b3590d320f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,7 @@ on: [push, pull_request] jobs: build: - runs-on: ubuntu-23.04 + runs-on: ubuntu-latest strategy: matrix: php: [7.3, 7.4] From 05347739b38b38a1593c26098cf08378e60d3d99 Mon Sep 17 00:00:00 2001 From: Thibault Buathier Date: Thu, 18 Apr 2024 19:28:52 +0200 Subject: [PATCH 3/8] fix: test on php 8.1 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b3590d320f..0c4374c767d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: [7.3, 7.4] + php: [8.1] db_image_name: [mysql, mariadb, percona, postgres] include: - db_image_name: mysql From 029ace0b6eea90a24c12dc6f4be3b5b15c736b9e Mon Sep 17 00:00:00 2001 From: Thibault Buathier Date: Thu, 18 Apr 2024 19:31:05 +0200 Subject: [PATCH 4/8] fix: database host for tests --- tests/config/mysql.phpunit.xml | 40 +++++++++++++--------------------- tests/config/pgsql.phpunit.xml | 40 +++++++++++++--------------------- 2 files changed, 30 insertions(+), 50 deletions(-) diff --git a/tests/config/mysql.phpunit.xml b/tests/config/mysql.phpunit.xml index b727c27087a..5ed9c527744 100644 --- a/tests/config/mysql.phpunit.xml +++ b/tests/config/mysql.phpunit.xml @@ -1,27 +1,17 @@ - - - - - - - - - - - - - - ../Oro/Tests/ORM - ../Oro/Tests/DBAL - - + + + + + + + + + + + + ../Oro/Tests/ORM + ../Oro/Tests/DBAL + + diff --git a/tests/config/pgsql.phpunit.xml b/tests/config/pgsql.phpunit.xml index 06e798c2dc3..2786537d39c 100644 --- a/tests/config/pgsql.phpunit.xml +++ b/tests/config/pgsql.phpunit.xml @@ -1,27 +1,17 @@ - - - - - - - - - - - - - - ../Oro/Tests/ORM - ../Oro/Tests/DBAL - - + + + + + + + + + + + + ../Oro/Tests/ORM + ../Oro/Tests/DBAL + + From fe20cf9be7f0d46262ac1e8747f0db9abc624009 Mon Sep 17 00:00:00 2001 From: Thibault Buathier Date: Thu, 18 Apr 2024 19:35:34 +0200 Subject: [PATCH 5/8] fix: add missing health --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c4374c767d..0b6fb7e3d7a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,20 +15,24 @@ jobs: db: mysql vars: '-e MYSQL_PASSWORD=travis -e MYSQL_DATABASE=doctrine_extensions_tests -e MYSQL_USER=travis -e MYSQL_ROOT_PASSWORD=travis' db_port: 3306 + health: '--health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10' - db_image_name: mariadb db_image_version: 11 db: mysql vars: '-e MYSQL_PASSWORD=travis -e MYSQL_DATABASE=doctrine_extensions_tests -e MYSQL_USER=travis -e MYSQL_ROOT_PASSWORD=travis' db_port: 3306 + health: '--health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10' - db_image_name: percona db_image_version: 8 db: mysql vars: '-e MYSQL_PASSWORD=travis -e MYSQL_DATABASE=doctrine_extensions_tests -e MYSQL_USER=travis -e MYSQL_ROOT_PASSWORD=travis' db_port: 3306 + health: '--health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10' - db_image_name: postgres db_image_version: 15 db: mysql vars: '-e POSTGRES_DB=doctrine_extensions_tests -e POSTGRES_USER=travis -e POSTGRES_PASSWORD=travis' + health: '--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5' db_port: 5432 services: @@ -38,6 +42,7 @@ jobs: - ${{ matrix.db_port }}:{{ matrix.db_port }} options: >- ${{ matrix.vars }} + ${{ matrix.health }} steps: - uses: actions/checkout@v3 From fafc5b96c10d94f1a9dc849515f708404d634478 Mon Sep 17 00:00:00 2001 From: Thibault Buathier Date: Thu, 18 Apr 2024 19:38:17 +0200 Subject: [PATCH 6/8] fix: ci error --- .github/workflows/ci.yml | 16 +++++----------- src/Oro/ORM/Query/AST/FunctionFactory.php | 23 +++++++++++++++++++++-- tests/config/mysql.phpunit.xml | 4 ++-- tests/config/pgsql.phpunit.xml | 4 ++-- 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b6fb7e3d7a..1d79d717855 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,12 +3,12 @@ name: CI on: [push, pull_request] jobs: - build: + test: runs-on: ubuntu-latest strategy: matrix: php: [8.1] - db_image_name: [mysql, mariadb, percona, postgres] + db_image_name: [mysql, percona, postgres] include: - db_image_name: mysql db_image_version: 8 @@ -16,12 +16,6 @@ jobs: vars: '-e MYSQL_PASSWORD=travis -e MYSQL_DATABASE=doctrine_extensions_tests -e MYSQL_USER=travis -e MYSQL_ROOT_PASSWORD=travis' db_port: 3306 health: '--health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10' - - db_image_name: mariadb - db_image_version: 11 - db: mysql - vars: '-e MYSQL_PASSWORD=travis -e MYSQL_DATABASE=doctrine_extensions_tests -e MYSQL_USER=travis -e MYSQL_ROOT_PASSWORD=travis' - db_port: 3306 - health: '--health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10' - db_image_name: percona db_image_version: 8 db: mysql @@ -30,16 +24,16 @@ jobs: health: '--health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10' - db_image_name: postgres db_image_version: 15 - db: mysql + db: pgsql vars: '-e POSTGRES_DB=doctrine_extensions_tests -e POSTGRES_USER=travis -e POSTGRES_PASSWORD=travis' health: '--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5' db_port: 5432 services: database: - image: ${{ matrix.db_image }} + image: ${{ matrix.db_image_name }}:${{ matrix.db_image_version }} ports: - - ${{ matrix.db_port }}:{{ matrix.db_port }} + - ${{ matrix.db_port }}:${{ matrix.db_port }} options: >- ${{ matrix.vars }} ${{ matrix.health }} diff --git a/src/Oro/ORM/Query/AST/FunctionFactory.php b/src/Oro/ORM/Query/AST/FunctionFactory.php index b6ba3f4d1f7..ca8bef268b2 100644 --- a/src/Oro/ORM/Query/AST/FunctionFactory.php +++ b/src/Oro/ORM/Query/AST/FunctionFactory.php @@ -3,6 +3,9 @@ namespace Oro\ORM\Query\AST; +use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Platforms\MySQLPlatform; +use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\ORM\Query\QueryException; use Oro\ORM\Query\AST\Platform\Functions\PlatformFunctionNode; @@ -13,8 +16,24 @@ class FunctionFactory * * @throws QueryException */ - public static function create(string $platformName, string $functionName, array $parameters): PlatformFunctionNode - { + public static function create( + AbstractPlatform $platform, + string $functionName, + array $parameters + ): PlatformFunctionNode { + if ($platform instanceof PostgreSQLPlatform) { + $platformName = 'postgresql'; + } elseif ($platform instanceof MySQLPlatform) { + $platformName = 'mysql'; + } else { + throw QueryException::syntaxError( + \sprintf( + 'Not supported platform "%s"', + $platform::class + ) + ); + } + $className = __NAMESPACE__ . '\\Platform\\Functions\\' . static::classify(\strtolower($platformName)) diff --git a/tests/config/mysql.phpunit.xml b/tests/config/mysql.phpunit.xml index 5ed9c527744..5840cd42481 100644 --- a/tests/config/mysql.phpunit.xml +++ b/tests/config/mysql.phpunit.xml @@ -2,11 +2,11 @@ - + - + diff --git a/tests/config/pgsql.phpunit.xml b/tests/config/pgsql.phpunit.xml index 2786537d39c..26f2b83d3d9 100644 --- a/tests/config/pgsql.phpunit.xml +++ b/tests/config/pgsql.phpunit.xml @@ -2,11 +2,11 @@ - + - + From 80747e16e734353f45ec34c32428812f81603331 Mon Sep 17 00:00:00 2001 From: Thibault Buathier Date: Fri, 19 Apr 2024 16:49:10 +0200 Subject: [PATCH 7/8] ci: change the database user/password --- .github/workflows/ci.yml | 6 +++--- tests/config/mysql.phpunit.xml | 4 ++-- tests/config/pgsql.phpunit.xml | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d79d717855..0084dcceea6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,19 +13,19 @@ jobs: - db_image_name: mysql db_image_version: 8 db: mysql - vars: '-e MYSQL_PASSWORD=travis -e MYSQL_DATABASE=doctrine_extensions_tests -e MYSQL_USER=travis -e MYSQL_ROOT_PASSWORD=travis' + vars: '-e MYSQL_PASSWORD=myPassword -e MYSQL_DATABASE=doctrine_extensions_tests -e MYSQL_USER=u_doctrine_extensions -e MYSQL_ROOT_PASSWORD=myPassword' db_port: 3306 health: '--health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10' - db_image_name: percona db_image_version: 8 db: mysql - vars: '-e MYSQL_PASSWORD=travis -e MYSQL_DATABASE=doctrine_extensions_tests -e MYSQL_USER=travis -e MYSQL_ROOT_PASSWORD=travis' + vars: '-e MYSQL_PASSWORD=myPassword -e MYSQL_DATABASE=doctrine_extensions_tests -e MYSQL_USER=u_doctrine_extensions -e MYSQL_ROOT_PASSWORD=myPassword' db_port: 3306 health: '--health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10' - db_image_name: postgres db_image_version: 15 db: pgsql - vars: '-e POSTGRES_DB=doctrine_extensions_tests -e POSTGRES_USER=travis -e POSTGRES_PASSWORD=travis' + vars: '-e POSTGRES_DB=doctrine_extensions_tests -e POSTGRES_USER=u_doctrine_extensions -e POSTGRES_PASSWORD=myPassword' health: '--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5' db_port: 5432 diff --git a/tests/config/mysql.phpunit.xml b/tests/config/mysql.phpunit.xml index 5840cd42481..bb77b059e28 100644 --- a/tests/config/mysql.phpunit.xml +++ b/tests/config/mysql.phpunit.xml @@ -3,8 +3,8 @@ - - + + diff --git a/tests/config/pgsql.phpunit.xml b/tests/config/pgsql.phpunit.xml index 26f2b83d3d9..0ac03db90f2 100644 --- a/tests/config/pgsql.phpunit.xml +++ b/tests/config/pgsql.phpunit.xml @@ -3,8 +3,8 @@ - - + + From c0d8e5436c54dba8f64c21bf42b283cd043ef2b0 Mon Sep 17 00:00:00 2001 From: Dmytro Khrysiev Date: Wed, 24 Apr 2024 12:58:02 +0200 Subject: [PATCH 8/8] CI for 2.x compatibility --- src/Oro/ORM/Query/AST/FunctionFactory.php | 23 ++----------- tests/config/mysql.phpunit.xml | 40 ++++++++++++++--------- tests/config/pgsql.phpunit.xml | 40 ++++++++++++++--------- 3 files changed, 52 insertions(+), 51 deletions(-) diff --git a/src/Oro/ORM/Query/AST/FunctionFactory.php b/src/Oro/ORM/Query/AST/FunctionFactory.php index ca8bef268b2..b6ba3f4d1f7 100644 --- a/src/Oro/ORM/Query/AST/FunctionFactory.php +++ b/src/Oro/ORM/Query/AST/FunctionFactory.php @@ -3,9 +3,6 @@ namespace Oro\ORM\Query\AST; -use Doctrine\DBAL\Platforms\AbstractPlatform; -use Doctrine\DBAL\Platforms\MySQLPlatform; -use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\ORM\Query\QueryException; use Oro\ORM\Query\AST\Platform\Functions\PlatformFunctionNode; @@ -16,24 +13,8 @@ class FunctionFactory * * @throws QueryException */ - public static function create( - AbstractPlatform $platform, - string $functionName, - array $parameters - ): PlatformFunctionNode { - if ($platform instanceof PostgreSQLPlatform) { - $platformName = 'postgresql'; - } elseif ($platform instanceof MySQLPlatform) { - $platformName = 'mysql'; - } else { - throw QueryException::syntaxError( - \sprintf( - 'Not supported platform "%s"', - $platform::class - ) - ); - } - + public static function create(string $platformName, string $functionName, array $parameters): PlatformFunctionNode + { $className = __NAMESPACE__ . '\\Platform\\Functions\\' . static::classify(\strtolower($platformName)) diff --git a/tests/config/mysql.phpunit.xml b/tests/config/mysql.phpunit.xml index bb77b059e28..0f700f4e87f 100644 --- a/tests/config/mysql.phpunit.xml +++ b/tests/config/mysql.phpunit.xml @@ -1,17 +1,27 @@ - - - - - - - - - - - - ../Oro/Tests/ORM - ../Oro/Tests/DBAL - - + + + + + + + + + + + + + + ../Oro/Tests/ORM + ../Oro/Tests/DBAL + + diff --git a/tests/config/pgsql.phpunit.xml b/tests/config/pgsql.phpunit.xml index 0ac03db90f2..ec2268a6645 100644 --- a/tests/config/pgsql.phpunit.xml +++ b/tests/config/pgsql.phpunit.xml @@ -1,17 +1,27 @@ - - - - - - - - - - - - ../Oro/Tests/ORM - ../Oro/Tests/DBAL - - + + + + + + + + + + + + + + ../Oro/Tests/ORM + ../Oro/Tests/DBAL + +