Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): misc improvments in CI permutations #797

Merged
merged 2 commits into from
Feb 1, 2025
Merged
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
66 changes: 40 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,54 @@ on:

jobs:
tests:
name: P:${{ matrix.php }}, S:${{ matrix.symfony }}, D:${{ matrix.database }}, PU:${{ matrix.phpunit }}${{ matrix.deps == 'lowest' && ' (lowest)' || '' }}${{ matrix.without-dama == 0 && contains(matrix.database, 'sql') && ' (dama)' || '' }}${{ matrix.use-phpunit-extension == 1 && ' (phpunit extension)' || '' }}
name: P:${{ matrix.php }}, S:${{ matrix.symfony }}, D:${{ matrix.database }}, PU:${{ matrix.phpunit }}${{ matrix.deps == 'lowest' && ' (lowest)' || '' }}${{ matrix.use-phpunit-extension == 1 && ' (phpunit extension)' || '' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ 8.1, 8.2, 8.3, 8.4 ]
php: [ 8.2, 8.3, 8.4 ]
symfony: [ 6.4.*, 7.1.*, 7.2.* ]
database: [ mysql, mongo ]
phpunit: [ 9, 11 ]
database: [ mysql|mongo ]
phpunit: [ 11 ]

# default values:
# deps: [ highest ]
# without-dama: [ 0 ]
# use-phpunit-extension: [ 0 ]

exclude:
- {php: 8.1, symfony: 7.1.*}
- {php: 8.1, symfony: 7.2.*}
- {php: 8.1, phpunit: 11 }
include:
# php 8.1
- {php: 8.1, symfony: 6.4.*, phpunit: 9, database: mysql}

# old PHPUnit versions
- {php: 8.3, symfony: '*', phpunit: 9, database: mysql}
- {php: 8.3, symfony: '*', phpunit: 10, database: mysql}

# test with no database (PHPUnit 9 is used to prevent some problems with empty data providers)
- {php: 8.3, symfony: '*', phpunit: 9, database: none}
- {php: 8.3, symfony: '*', phpunit: 11, database: mysql|mongo}
- {php: 8.3, symfony: '*', phpunit: 11, database: pgsql|mongo}
- {php: 8.3, symfony: '*', phpunit: 11, database: pgsql, without-dama: 1}
- {php: 8.3, symfony: '*', phpunit: 11, database: sqlite, without-dama: 1}
- {php: 8.3, symfony: '*', phpunit: 9, database: sqlite, without-dama: 1, deps: lowest}
- {php: 8.3, symfony: '*', phpunit: 9, database: none, deps: lowest}

# One permutation per DBMS
- {php: 8.3, symfony: '*', phpunit: 11, database: mongo}
- {php: 8.3, symfony: '*', phpunit: 11, database: pgsql}
- {php: 8.3, symfony: '*', phpunit: 11, database: sqlite}
- {php: 8.3, symfony: '*', phpunit: 11, database: mysql}

# lowest deps (one per DBMS)
- {php: 8.3, symfony: '*', phpunit: 9, database: mysql|mongo, deps: lowest}
- {php: 8.3, symfony: '*', phpunit: 9, database: mongo, deps: lowest}
- {php: 8.3, symfony: '*', phpunit: 9, database: pgsql, deps: lowest}
- {php: 8.3, symfony: '*', phpunit: 9, database: sqlite, deps: lowest}
- {php: 8.3, symfony: '*', phpunit: 9, database: mysql, deps: lowest}
- {php: 8.3, symfony: '*', phpunit: 10, database: mysql|mongo}

# using Foundry's PHPUnit extension
- {php: 8.3, symfony: '*', phpunit: 11, database: mysql|mongo, use-phpunit-extension: 1}
- {php: 8.3, symfony: '*', phpunit: 11, database: mysql|mongo, use-phpunit-extension: 1, without-dama: 1}
env:
DATABASE_URL: ${{ contains(matrix.database, 'mysql') && 'mysql://root:root@localhost:3306/foundry?serverVersion=5.7.42' || contains(matrix.database, 'pgsql') && 'postgresql://root:root@localhost:5432/foundry?serverVersion=15' || contains(matrix.database, 'sqlite') && 'sqlite:///%kernel.project_dir%/var/data.db' || '' }}
MONGO_URL: ${{ contains(matrix.database, 'mongo') && 'mongodb://127.0.0.1:27017/dbName?compressors=disabled&gssapiServiceName=mongodb' || '' }}
USE_DAMA_DOCTRINE_TEST_BUNDLE: ${{ matrix.without-dama == 0 && contains(matrix.database, 'sql') && 1 || 0 }}
USE_DAMA_DOCTRINE_TEST_BUNDLE: ${{ contains(matrix.database, 'sql') && 1 || 0 }}
USE_FOUNDRY_PHPUNIT_EXTENSION: ${{ matrix.use-phpunit-extension || 0 }}
PHPUNIT_VERSION: ${{ matrix.phpunit }}
services:
Expand Down Expand Up @@ -90,25 +104,20 @@ jobs:
shell: bash

test-reset-database:
name: Test reset database - D:${{ matrix.database }} ${{ matrix.use-dama == 1 && ' (dama)' || '' }} ${{ matrix.reset-database-mode == 'migrate' && ' (migrate)' || '' }} ${{ contains(matrix.with-migration-configuration-file, 'transactional') && '(configuration file transactional)' || contains(matrix.with-migration-configuration-file, 'configuration') && '(configuration file)' || '' }}
name: Reset DB - D:${{ matrix.database }} ${{ matrix.use-dama == 1 && ' (dama)' || '' }} ${{ matrix.reset-database-mode == 'migrate' && ' (migrate)' || '' }} ${{ contains(matrix.with-migration-configuration-file, 'transactional') && '(configuration file transactional)' || contains(matrix.with-migration-configuration-file, 'configuration') && '(configuration file)' || '' }}${{ matrix.deps == 'lowest' && ' (lowest)' || '' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
database: [ mysql, pgsql, sqlite, mysql|mongo ]
use-dama: [ 0, 1 ]
reset-database-mode: [ schema, migrate ]
migration-configuration-file: ['no', 'migration-configuration', 'migration-configuration-transactional']
migration-configuration-file: ['no']
deps: [ highest, lowest ]
include:
- { database: mongo, migration-configuration-file: 'no', use-dama: 0, reset-database-mode: schema }
exclude:
# there is currently a bug with MySQL and transactional migrations
- database: mysql
migration-configuration-file: 'migration-configuration-transactional'
- reset-database-mode: schema
migration-configuration-file: 'migration-configuration'
- reset-database-mode: schema
migration-configuration-file: 'migration-configuration-transactional'
- { database: pgsql, migration-configuration-file: 'migration-configuration', use-dama: 0, reset-database-mode: migration }
- { database: pgsql, migration-configuration-file: 'migration-configuration-transactional', use-dama: 0, reset-database-mode: migration }
env:
DATABASE_URL: ${{ contains(matrix.database, 'mysql') && 'mysql://root:root@localhost:3306/foundry?serverVersion=5.7.42' || contains(matrix.database, 'pgsql') && 'postgresql://root:root@localhost:5432/foundry?serverVersion=15' || 'sqlite:///%kernel.project_dir%/var/data.db' }}
MONGO_URL: ${{ contains(matrix.database, 'mongo') && 'mongodb://127.0.0.1:27017/dbName?compressors=disabled&gssapiServiceName=mongodb' || '' }}
Expand Down Expand Up @@ -148,7 +157,7 @@ jobs:
- name: Install dependencies
uses: ramsey/composer-install@v2
with:
dependency-versions: highest
dependency-versions: ${{ matrix.deps }}
composer-options: --prefer-dist
env:
SYMFONY_REQUIRE: 7.1.*
Expand All @@ -158,7 +167,12 @@ jobs:
run: sudo /etc/init.d/mysql start

- name: Test
run: ./phpunit --testsuite reset-database --bootstrap tests/bootstrap-reset-database.php
run: |
./phpunit --testsuite reset-database --bootstrap tests/bootstrap-reset-database.php

# We should be able to run the tests twice in order to check if the second run also starts from a fresh db
# some bugs could be detected this way
./phpunit --testsuite reset-database --bootstrap tests/bootstrap-reset-database.php
shell: bash

test-with-paratest:
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8",
"brianium/paratest": "^6|^7",
"dama/doctrine-test-bundle": "^7.0|^8.0",
"dama/doctrine-test-bundle": "^8.0",
"doctrine/collections": "^1.7|^2.0",
"doctrine/common": "^2|^3",
"doctrine/common": "^3.2.2",
"doctrine/doctrine-bundle": "^2.10",
"doctrine/doctrine-migrations-bundle": "^2.2|^3.0",
"doctrine/mongodb-odm-bundle": "^4.6|^5.0",
"doctrine/mongodb-odm": "^2.4",
"doctrine/orm": "^2.16|^3.0",
"phpunit/phpunit": "^9.5.0 || ^10.0 || ^11.0",
"symfony/console": "^6.4|^7.0",
Expand Down
1 change: 0 additions & 1 deletion src/Exception/FactoriesTraitNotUsed.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public static function throwIfComingFromKernelTestCaseWithoutFactoriesTrait(): v
&& isset($trace['class'])
&& KernelTestCase::class !== $trace['class']
&& \is_a($trace['class'], KernelTestCase::class, allow_string: true)
&& !(new \ReflectionClass($trace['class']))->hasMethod('_bootFoundry')
) {
self::throwIfClassDoesNotHaveFactoriesTrait($trace['class']);
}
Expand Down
3 changes: 1 addition & 2 deletions src/ORM/ResetDatabase/BaseOrmResetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpKernel\KernelInterface;
use Zenstruck\Foundry\ORM\DoctrineOrmVersionGuesser;

use function Zenstruck\Foundry\runCommand;

Expand Down Expand Up @@ -68,7 +67,7 @@ final protected function dropAndResetDatabase(Application $application): void
// let's only drop the .db file

$dbPath = $connection->getParams()['path'] ?? null;
if (DoctrineOrmVersionGuesser::isOrmV3() && $dbPath && (new Filesystem())->exists($dbPath)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test on orm version seems to not be needed anymore

if ($dbPath && (new Filesystem())->exists($dbPath)) {
\file_put_contents($dbPath, '');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* @author Nicolas PHILIPPE <[email protected]>
*/
#[ORM\Entity]
#[ORM\Table('inversed_one_to_one_with_non_nullable_owning_inverse_side')]
#[ORM\Table('inversed_one_to_one_non_nullable_owning_inverse_side')]
Copy link
Member Author

@nikophil nikophil Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the name was too long for PG sequences 😅

class InverseSide extends Base
{
public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

return [
'migrations_paths' => [
'Zenstruck\\Foundry\\Tests\\Fixture\\ResetDatabase\\Migrations' => \dirname(__DIR__).'/Migrations',
'Zenstruck\\Foundry\\Tests\\Fixture\\ResetDatabase\\Migrations' => \dirname(__DIR__, 4).'/var/cache/Migrations',
],
'transactional' => true,
];
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

return [
'migrations_paths' => [
'Zenstruck\\Foundry\\Tests\\Fixture\\ResetDatabase\\Migrations' => \dirname(__DIR__, 4).'/var/Migrations',
'Zenstruck\\Foundry\\Tests\\Fixture\\ResetDatabase\\Migrations' => \dirname(__DIR__, 4).'/var/cache/Migrations',
],
'transactional' => false,
];
4 changes: 2 additions & 2 deletions tests/bootstrap-reset-database.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@

$fs = new Filesystem();

$fs->remove(__DIR__.'/../var');
$fs->remove(__DIR__.'/../var/cache');

(new Dotenv())->usePutenv()->loadEnv(__DIR__.'/../.env');

if (FoundryTestKernel::usesMigrations()) {
$fs->mkdir(__DIR__.'/../var/Migrations');
$fs->mkdir(__DIR__.'/../var/cache/Migrations');

$kernel = new ResetDatabaseTestKernel('test', true);
$kernel->boot();
Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

$fs = new Filesystem();

$fs->remove(__DIR__.'/../var');
$fs->remove(__DIR__.'/../var/cache');

(new Dotenv())->usePutenv()->loadEnv(__DIR__.'/../.env');