Skip to content

Commit 46464cc

Browse files
authored
chore(ci): misc improvments in CI permutations (#797)
1 parent 86c5aab commit 46464cc

File tree

9 files changed

+50
-37
lines changed

9 files changed

+50
-37
lines changed

.github/workflows/ci.yml

+40-26
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,54 @@ on:
88

99
jobs:
1010
tests:
11-
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)' || '' }}
11+
name: P:${{ matrix.php }}, S:${{ matrix.symfony }}, D:${{ matrix.database }}, PU:${{ matrix.phpunit }}${{ matrix.deps == 'lowest' && ' (lowest)' || '' }}${{ matrix.use-phpunit-extension == 1 && ' (phpunit extension)' || '' }}
1212
runs-on: ubuntu-latest
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
php: [ 8.1, 8.2, 8.3, 8.4 ]
16+
php: [ 8.2, 8.3, 8.4 ]
1717
symfony: [ 6.4.*, 7.1.*, 7.2.* ]
18-
database: [ mysql, mongo ]
19-
phpunit: [ 9, 11 ]
18+
database: [ mysql|mongo ]
19+
phpunit: [ 11 ]
2020

2121
# default values:
2222
# deps: [ highest ]
23-
# without-dama: [ 0 ]
2423
# use-phpunit-extension: [ 0 ]
2524

2625
exclude:
2726
- {php: 8.1, symfony: 7.1.*}
2827
- {php: 8.1, symfony: 7.2.*}
29-
- {php: 8.1, phpunit: 11 }
3028
include:
29+
# php 8.1
30+
- {php: 8.1, symfony: 6.4.*, phpunit: 9, database: mysql}
31+
32+
# old PHPUnit versions
33+
- {php: 8.3, symfony: '*', phpunit: 9, database: mysql}
34+
- {php: 8.3, symfony: '*', phpunit: 10, database: mysql}
35+
36+
# test with no database (PHPUnit 9 is used to prevent some problems with empty data providers)
3137
- {php: 8.3, symfony: '*', phpunit: 9, database: none}
32-
- {php: 8.3, symfony: '*', phpunit: 11, database: mysql|mongo}
33-
- {php: 8.3, symfony: '*', phpunit: 11, database: pgsql|mongo}
34-
- {php: 8.3, symfony: '*', phpunit: 11, database: pgsql, without-dama: 1}
35-
- {php: 8.3, symfony: '*', phpunit: 11, database: sqlite, without-dama: 1}
36-
- {php: 8.3, symfony: '*', phpunit: 9, database: sqlite, without-dama: 1, deps: lowest}
38+
- {php: 8.3, symfony: '*', phpunit: 9, database: none, deps: lowest}
39+
40+
# One permutation per DBMS
41+
- {php: 8.3, symfony: '*', phpunit: 11, database: mongo}
42+
- {php: 8.3, symfony: '*', phpunit: 11, database: pgsql}
43+
- {php: 8.3, symfony: '*', phpunit: 11, database: sqlite}
44+
- {php: 8.3, symfony: '*', phpunit: 11, database: mysql}
45+
46+
# lowest deps (one per DBMS)
47+
- {php: 8.3, symfony: '*', phpunit: 9, database: mysql|mongo, deps: lowest}
48+
- {php: 8.3, symfony: '*', phpunit: 9, database: mongo, deps: lowest}
49+
- {php: 8.3, symfony: '*', phpunit: 9, database: pgsql, deps: lowest}
50+
- {php: 8.3, symfony: '*', phpunit: 9, database: sqlite, deps: lowest}
3751
- {php: 8.3, symfony: '*', phpunit: 9, database: mysql, deps: lowest}
38-
- {php: 8.3, symfony: '*', phpunit: 10, database: mysql|mongo}
52+
53+
# using Foundry's PHPUnit extension
3954
- {php: 8.3, symfony: '*', phpunit: 11, database: mysql|mongo, use-phpunit-extension: 1}
40-
- {php: 8.3, symfony: '*', phpunit: 11, database: mysql|mongo, use-phpunit-extension: 1, without-dama: 1}
4155
env:
4256
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' || '' }}
4357
MONGO_URL: ${{ contains(matrix.database, 'mongo') && 'mongodb://127.0.0.1:27017/dbName?compressors=disabled&gssapiServiceName=mongodb' || '' }}
44-
USE_DAMA_DOCTRINE_TEST_BUNDLE: ${{ matrix.without-dama == 0 && contains(matrix.database, 'sql') && 1 || 0 }}
58+
USE_DAMA_DOCTRINE_TEST_BUNDLE: ${{ contains(matrix.database, 'sql') && 1 || 0 }}
4559
USE_FOUNDRY_PHPUNIT_EXTENSION: ${{ matrix.use-phpunit-extension || 0 }}
4660
PHPUNIT_VERSION: ${{ matrix.phpunit }}
4761
services:
@@ -90,25 +104,20 @@ jobs:
90104
shell: bash
91105

92106
test-reset-database:
93-
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)' || '' }}
107+
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)' || '' }}
94108
runs-on: ubuntu-latest
95109
strategy:
96110
fail-fast: false
97111
matrix:
98112
database: [ mysql, pgsql, sqlite, mysql|mongo ]
99113
use-dama: [ 0, 1 ]
100114
reset-database-mode: [ schema, migrate ]
101-
migration-configuration-file: ['no', 'migration-configuration', 'migration-configuration-transactional']
115+
migration-configuration-file: ['no']
116+
deps: [ highest, lowest ]
102117
include:
103118
- { database: mongo, migration-configuration-file: 'no', use-dama: 0, reset-database-mode: schema }
104-
exclude:
105-
# there is currently a bug with MySQL and transactional migrations
106-
- database: mysql
107-
migration-configuration-file: 'migration-configuration-transactional'
108-
- reset-database-mode: schema
109-
migration-configuration-file: 'migration-configuration'
110-
- reset-database-mode: schema
111-
migration-configuration-file: 'migration-configuration-transactional'
119+
- { database: pgsql, migration-configuration-file: 'migration-configuration', use-dama: 0, reset-database-mode: migration }
120+
- { database: pgsql, migration-configuration-file: 'migration-configuration-transactional', use-dama: 0, reset-database-mode: migration }
112121
env:
113122
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' }}
114123
MONGO_URL: ${{ contains(matrix.database, 'mongo') && 'mongodb://127.0.0.1:27017/dbName?compressors=disabled&gssapiServiceName=mongodb' || '' }}
@@ -148,7 +157,7 @@ jobs:
148157
- name: Install dependencies
149158
uses: ramsey/composer-install@v2
150159
with:
151-
dependency-versions: highest
160+
dependency-versions: ${{ matrix.deps }}
152161
composer-options: --prefer-dist
153162
env:
154163
SYMFONY_REQUIRE: 7.1.*
@@ -158,7 +167,12 @@ jobs:
158167
run: sudo /etc/init.d/mysql start
159168

160169
- name: Test
161-
run: ./phpunit --testsuite reset-database --bootstrap tests/bootstrap-reset-database.php
170+
run: |
171+
./phpunit --testsuite reset-database --bootstrap tests/bootstrap-reset-database.php
172+
173+
# We should be able to run the tests twice in order to check if the second run also starts from a fresh db
174+
# some bugs could be detected this way
175+
./phpunit --testsuite reset-database --bootstrap tests/bootstrap-reset-database.php
162176
shell: bash
163177

164178
test-with-paratest:

composer.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@
2828
"require-dev": {
2929
"bamarni/composer-bin-plugin": "^1.8",
3030
"brianium/paratest": "^6|^7",
31-
"dama/doctrine-test-bundle": "^7.0|^8.0",
31+
"dama/doctrine-test-bundle": "^8.0",
3232
"doctrine/collections": "^1.7|^2.0",
33-
"doctrine/common": "^2|^3",
33+
"doctrine/common": "^3.2.2",
3434
"doctrine/doctrine-bundle": "^2.10",
3535
"doctrine/doctrine-migrations-bundle": "^2.2|^3.0",
3636
"doctrine/mongodb-odm-bundle": "^4.6|^5.0",
37+
"doctrine/mongodb-odm": "^2.4",
3738
"doctrine/orm": "^2.16|^3.0",
3839
"phpunit/phpunit": "^9.5.0 || ^10.0 || ^11.0",
3940
"symfony/console": "^6.4|^7.0",

src/Exception/FactoriesTraitNotUsed.php

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public static function throwIfComingFromKernelTestCaseWithoutFactoriesTrait(): v
4141
&& isset($trace['class'])
4242
&& KernelTestCase::class !== $trace['class']
4343
&& \is_a($trace['class'], KernelTestCase::class, allow_string: true)
44-
&& !(new \ReflectionClass($trace['class']))->hasMethod('_bootFoundry')
4544
) {
4645
self::throwIfClassDoesNotHaveFactoriesTrait($trace['class']);
4746
}

src/ORM/ResetDatabase/BaseOrmResetter.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use Symfony\Bundle\FrameworkBundle\Console\Application;
2121
use Symfony\Component\Filesystem\Filesystem;
2222
use Symfony\Component\HttpKernel\KernelInterface;
23-
use Zenstruck\Foundry\ORM\DoctrineOrmVersionGuesser;
2423

2524
use function Zenstruck\Foundry\runCommand;
2625

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

7069
$dbPath = $connection->getParams()['path'] ?? null;
71-
if (DoctrineOrmVersionGuesser::isOrmV3() && $dbPath && (new Filesystem())->exists($dbPath)) {
70+
if ($dbPath && (new Filesystem())->exists($dbPath)) {
7271
\file_put_contents($dbPath, '');
7372
}
7473

tests/Fixture/Entity/EdgeCases/InversedOneToOneWithNonNullableOwning/InverseSide.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* @author Nicolas PHILIPPE <[email protected]>
2121
*/
2222
#[ORM\Entity]
23-
#[ORM\Table('inversed_one_to_one_with_non_nullable_owning_inverse_side')]
23+
#[ORM\Table('inversed_one_to_one_non_nullable_owning_inverse_side')]
2424
class InverseSide extends Base
2525
{
2626
public function __construct(

tests/Fixture/ResetDatabase/migration-configs/migration-configuration-transactional.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
return [
1313
'migrations_paths' => [
14-
'Zenstruck\\Foundry\\Tests\\Fixture\\ResetDatabase\\Migrations' => \dirname(__DIR__).'/Migrations',
14+
'Zenstruck\\Foundry\\Tests\\Fixture\\ResetDatabase\\Migrations' => \dirname(__DIR__, 4).'/var/cache/Migrations',
1515
],
1616
'transactional' => true,
1717
];

tests/Fixture/ResetDatabase/migration-configs/migration-configuration.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
return [
1313
'migrations_paths' => [
14-
'Zenstruck\\Foundry\\Tests\\Fixture\\ResetDatabase\\Migrations' => \dirname(__DIR__, 4).'/var/Migrations',
14+
'Zenstruck\\Foundry\\Tests\\Fixture\\ResetDatabase\\Migrations' => \dirname(__DIR__, 4).'/var/cache/Migrations',
1515
],
1616
'transactional' => false,
1717
];

tests/bootstrap-reset-database.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121

2222
$fs = new Filesystem();
2323

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

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

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

3131
$kernel = new ResetDatabaseTestKernel('test', true);
3232
$kernel->boot();

tests/bootstrap.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616

1717
$fs = new Filesystem();
1818

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

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

0 commit comments

Comments
 (0)