From b078c00492b8d53ce6468ce9485941ce7156f1c5 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 8 Sep 2022 14:10:09 +0200 Subject: [PATCH 1/2] Migrated to custom doctrine cli entry point, as the built-in is deprecated --- bin/doctrine | 12 ++++++++++++ composer.json | 2 +- config/autoload/installer.global.php | 6 ++++++ config/test/bootstrap_api_tests.php | 7 ++++++- config/test/bootstrap_cli_tests.php | 7 ++++++- config/test/bootstrap_db_tests.php | 7 ++++++- docker/docker-entrypoint.sh | 4 ++-- module/CLI/src/Command/Db/CreateDatabaseCommand.php | 2 +- 8 files changed, 40 insertions(+), 7 deletions(-) create mode 100755 bin/doctrine diff --git a/bin/doctrine b/bin/doctrine new file mode 100755 index 00000000..4fec1714 --- /dev/null +++ b/bin/doctrine @@ -0,0 +1,12 @@ +#!/usr/bin/env php +value => [ 'command' => 'bin/cli ' . Command\Db\MigrateDatabaseCommand::NAME, ], + InstallationCommand::ORM_PROXIES->value => [ + 'command' => 'bin/doctrine orm:generate-proxies', + ], + InstallationCommand::ORM_CLEAR_CACHE->value => [ + 'command' => 'bin/doctrine orm:clear-cache:metadata', + ], InstallationCommand::GEOLITE_DOWNLOAD_DB->value => [ 'command' => 'bin/cli ' . Command\Visit\DownloadGeoLiteDbCommand::NAME, ], diff --git a/config/test/bootstrap_api_tests.php b/config/test/bootstrap_api_tests.php index bc119284..2653b552 100644 --- a/config/test/bootstrap_api_tests.php +++ b/config/test/bootstrap_api_tests.php @@ -28,6 +28,11 @@ register_shutdown_function(function () use ($httpClient): void { ); }); -$testHelper->createTestDb(['bin/cli', 'db:create'], ['bin/cli', 'db:migrate']); +$testHelper->createTestDb( + ['bin/cli', 'db:create'], + ['bin/cli', 'db:migrate'], + ['bin/doctrine', 'orm:schema-tool:drop'], + ['bin/doctrine', 'dbal:run-sql'], +); ApiTest\ApiTestCase::setApiClient($httpClient); ApiTest\ApiTestCase::setSeedFixturesCallback(fn () => $testHelper->seedFixtures($em, $config['data_fixtures'] ?? [])); diff --git a/config/test/bootstrap_cli_tests.php b/config/test/bootstrap_cli_tests.php index 893bdfd7..c8c33721 100644 --- a/config/test/bootstrap_cli_tests.php +++ b/config/test/bootstrap_cli_tests.php @@ -22,7 +22,12 @@ if (file_exists($covFile)) { unlink($covFile); } -$testHelper->createTestDb(['bin/cli', 'db:create'], ['bin/cli', 'db:migrate']); +$testHelper->createTestDb( + ['bin/cli', 'db:create'], + ['bin/cli', 'db:migrate'], + ['bin/doctrine', 'orm:schema-tool:drop'], + ['bin/doctrine', 'dbal:run-sql'], +); CliTest\CliTestCase::setSeedFixturesCallback( static fn () => $testHelper->seedFixtures($em, $config['data_fixtures'] ?? []), ); diff --git a/config/test/bootstrap_db_tests.php b/config/test/bootstrap_db_tests.php index 0237d741..5aa8ea51 100644 --- a/config/test/bootstrap_db_tests.php +++ b/config/test/bootstrap_db_tests.php @@ -8,5 +8,10 @@ use Psr\Container\ContainerInterface; /** @var ContainerInterface $container */ $container = require __DIR__ . '/../container.php'; -$container->get(Helper\TestHelper::class)->createTestDb(['bin/cli', 'db:create'], ['bin/cli', 'db:migrate']); +$container->get(Helper\TestHelper::class)->createTestDb( + ['bin/cli', 'db:create'], + ['bin/cli', 'db:migrate'], + ['bin/doctrine', 'orm:schema-tool:drop'], + ['bin/doctrine', 'dbal:run-sql'], +); DbTest\DatabaseTestCase::setEntityManager($container->get('em')); diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index 1955f0ec..f28627d2 100644 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -13,10 +13,10 @@ echo "Updating database..." php bin/cli db:migrate -n ${flags} echo "Generating proxies..." -php vendor/doctrine/orm/bin/doctrine.php orm:generate-proxies -n ${flags} +php bin/doctrine orm:generate-proxies -n ${flags} echo "Clearing entities cache..." -php vendor/doctrine/orm/bin/doctrine.php orm:clear-cache:metadata -n ${flags} +php bin/doctrine orm:clear-cache:metadata -n ${flags} # Try to download GeoLite2 db file only if the license key env var was defined if [ ! -z "${GEOLITE_LICENSE_KEY}" ]; then diff --git a/module/CLI/src/Command/Db/CreateDatabaseCommand.php b/module/CLI/src/Command/Db/CreateDatabaseCommand.php index 415290a3..5cc6a184 100644 --- a/module/CLI/src/Command/Db/CreateDatabaseCommand.php +++ b/module/CLI/src/Command/Db/CreateDatabaseCommand.php @@ -22,7 +22,7 @@ use const Shlinkio\Shlink\MIGRATIONS_TABLE; class CreateDatabaseCommand extends AbstractDatabaseCommand { public const NAME = 'db:create'; - public const DOCTRINE_SCRIPT = 'vendor/doctrine/orm/bin/doctrine.php'; + public const DOCTRINE_SCRIPT = 'bin/doctrine'; public const DOCTRINE_CREATE_SCHEMA_COMMAND = 'orm:schema-tool:create'; public function __construct( From 5b78b363f0c81b54df5e06b674c7ebea2a911d5d Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 8 Sep 2022 14:11:01 +0200 Subject: [PATCH 2/2] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12c68daa..921e45d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this ### Changed * [#1339](https://github.com/shlinkio/shlink/issues/1339) Added new test suite for CLI E2E tests. * [#1503](https://github.com/shlinkio/shlink/issues/1503) Drastically improved build time in GitHub Actions, by optimizing parallelization, adding php extensions cache and running mutation tests only for changed files. +* [#1525](https://github.com/shlinkio/shlink/issues/1525) Migrated to custom doctrine CLI entry point. ### Deprecated * *Nothing*