From 97c5f300d7e19ba80da5f3719ed8b8242c258d82 Mon Sep 17 00:00:00 2001 From: Nicolas Joubert Date: Thu, 8 Oct 2026 15:20:15 +0200 Subject: [PATCH] fix #129 Run the migrations on MySQL, MariaDB and PostgreSQL in the CI `migrations` job of test.yml, with DBAL 3 and 4: migrate, doctrine:schema:validate (not with DBAL 3 on PostgreSQL, which does not read the identity columns), migrate first, migrate again. Console of the test application, database URL overridable with DATABASE_URL (SQLite by default). Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/workflows/test.yml | 90 ++++++++++++++++++++++++++++++++++ CHANGELOG.md | 1 + tests/App/bin/console | 21 ++++++++ tests/App/config/packages.yaml | 4 +- 4 files changed, 115 insertions(+), 1 deletion(-) create mode 100755 tests/App/bin/console diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b49e0ce..8f97dd3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -103,3 +103,93 @@ jobs: # uses: codecov/codecov-action@v4 # with: # files: build/logs/clover.xml + + migrations: + name: Migrations ${{ matrix.database }} + DBAL ${{ matrix.dbal }} + runs-on: ubuntu-latest + env: + SYMFONY_REQUIRE: ${{ matrix.symfony-require }} + DATABASE_URL: ${{ matrix.database-url }} + + strategy: + fail-fast: false + matrix: + database: [mysql, mariadb, postgresql] + dbal: ['3', '4'] + include: + - database: mysql + image: mysql:8.4 + port: 3306 + health-cmd: mysqladmin ping -h 127.0.0.1 + database-url: mysql://app:app@127.0.0.1:3306/app?serverVersion=8.4.0 + - database: mariadb + image: mariadb:11.4 + port: 3306 + health-cmd: healthcheck.sh --connect --innodb_initialized + database-url: mysql://app:app@127.0.0.1:3306/app?serverVersion=11.4.0-MariaDB + - database: postgresql + image: postgres:17 + port: 5432 + health-cmd: pg_isready -U app + database-url: postgresql://app:app@127.0.0.1:5432/app?serverVersion=17&charset=utf8 + - dbal: '3' + php-version: '8.4' + symfony-require: 7.4.* + - dbal: '4' + php-version: '8.5' + symfony-require: '' + + services: + database: + image: ${{ matrix.image }} + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: app + MYSQL_USER: app + MYSQL_PASSWORD: app + MARIADB_ROOT_PASSWORD: root + MARIADB_DATABASE: app + MARIADB_USER: app + MARIADB_PASSWORD: app + POSTGRES_DB: app + POSTGRES_USER: app + POSTGRES_PASSWORD: app + ports: + - ${{ matrix.port }}:${{ matrix.port }} + options: >- + --health-cmd "${{ matrix.health-cmd }}" + --health-interval 5s + --health-timeout 5s + --health-retries 20 + + steps: + - name: Checkout + uses: actions/checkout@v7 + - name: Install PHP with extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: pdo_mysql, pdo_pgsql + coverage: none + tools: composer:v2, flex + - name: Require DBAL 3 + if: matrix.dbal == '3' + run: composer require doctrine/dbal:^3.10 --no-update + - name: Install Composer dependencies + uses: ramsey/composer-install@v4 + with: + dependency-versions: highest + - name: Run the migrations + run: tests/App/bin/console doctrine:migrations:migrate --no-interaction + # DBAL 3 does not read the PostgreSQL identity columns created by the migrations (it expects sequences): the + # schema is always reported as out of sync, inserts work (the ORM uses the sequence of the identity column) + - name: Validate the schema + if: matrix.dbal != '3' || matrix.database != 'postgresql' + run: tests/App/bin/console doctrine:schema:validate + - name: Revert the migrations + run: tests/App/bin/console doctrine:migrations:migrate first --no-interaction + - name: Run the migrations again + run: tests/App/bin/console doctrine:migrations:migrate --no-interaction + - name: Validate the schema again + if: matrix.dbal != '3' || matrix.database != 'postgresql' + run: tests/App/bin/console doctrine:schema:validate diff --git a/CHANGELOG.md b/CHANGELOG.md index 3460d4a..3b8712c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Latest * [#83](https://github.com/cleverage/ui-process-bundle/issues/83) Remove `UploadAndExecuteAction` (route `process_upload_and_execute`), `ProcessUploadFileType` and `ProcessConfigurationValueResolver`: the action was broken and unreachable, file uploads are handled by `LaunchAction` (`entrypoint_type: file`). * [#84](https://github.com/cleverage/ui-process-bundle/issues/84) Add `LogRecord::hasContextInfo()`, deprecate the misnamed `LogRecord::contextIsEmpty()` (it returns `true` when the context is not empty). Add tests. * [#85](https://github.com/cleverage/ui-process-bundle/issues/85) `ProcessHandler`: default report increment level aligned on the bundle configuration (`Warning`); declare the `symfony/ux-twig-component` dependency. Add tests. +* [#129](https://github.com/cleverage/ui-process-bundle/issues/129) CI: `migrations` job running the migrations on MySQL, MariaDB and PostgreSQL, with DBAL 3 and 4 (`migrate`, `doctrine:schema:validate`, `migrate first`, `migrate` again); console of the test application (`tests/App/bin/console`), database URL overridable with `DATABASE_URL` (SQLite by default). ## Fixes * [#89](https://github.com/cleverage/ui-process-bundle/issues/89) `ProcessConfigurationsManager`: resolve the `ui.default` option with a normalizer instead of nested options defined with `setDefault()` (deprecated since symfony/options-resolver 7.3, removed in 8.0). With Symfony 8, a process launched with the UI form (`ui_launch_mode: form`) without `ui.default` no longer fails (`Cannot use object of type Closure as array`), and `ui.default` is validated again. Add tests. diff --git a/tests/App/bin/console b/tests/App/bin/console new file mode 100755 index 0000000..fbe279a --- /dev/null +++ b/tests/App/bin/console @@ -0,0 +1,21 @@ +#!/usr/bin/env php +run()); diff --git a/tests/App/config/packages.yaml b/tests/App/config/packages.yaml index cd4704e..60bd2b8 100644 --- a/tests/App/config/packages.yaml +++ b/tests/App/config/packages.yaml @@ -1,5 +1,7 @@ parameters: upload_directory: '%kernel.cache_dir%/uploads' + # SQLite by default; the CI runs the migrations on MySQL / MariaDB / PostgreSQL with DATABASE_URL + env(DATABASE_URL): 'sqlite:///%kernel.cache_dir%/test.db' framework: secret: 'test' @@ -26,7 +28,7 @@ security: doctrine: dbal: - url: 'sqlite:///%kernel.cache_dir%/test.db' + url: '%env(resolve:DATABASE_URL)%' orm: auto_mapping: true # As the Symfony recipe: the indexes of the bundle entities use snake_case column names