Skip to content

fix(supported-version): model MariaDB as a separate service from MySQL#370

Draft
rhoerr wants to merge 2 commits into
mage-os:mainfrom
rhoerr:fix/mariadb-service
Draft

fix(supported-version): model MariaDB as a separate service from MySQL#370
rhoerr wants to merge 2 commits into
mage-os:mainfrom
rhoerr:fix/mariadb-service

Conversation

@rhoerr
Copy link
Copy Markdown
Contributor

@rhoerr rhoerr commented May 16, 2026

Summary

Fixes the 2.4.9 setup-install CI failure reported in #365 by promoting MariaDB to its own first-class service in the matrix schema, mirroring the existing opensearch/elasticsearch and valkey/redis patterns. This is @damienwebdev's preferred approach from the issue thread (closing the alternate single-template fix from #366).

Why the obvious one-template fix doesn't work

The mariadb:11.4 image used for Magento 2.4.9 no longer ships mysqladmin, so the existing health command --health-cmd="mysqladmin ping" exits non-zero forever and GitHub Actions tears the job down at Initialize containers. The MariaDB-recommended replacement, healthcheck.sh --connect --innodb_initialized, ships in MariaDB images but not in mysql:8.4, which 2.4.6-p15 / 2.4.7-p10 / 2.4.8-p5 still use. A single template can't cover both engines, so each needs its own.

What changed — supported-version

Area Change
supported-version/src/matrix/matrix-type.ts Added mariadb: string to PackageMatrixVersion
supported-version/src/services/service-config.ts Added mariadbConfig template using healthcheck.sh --connect --innodb_initialized. mysqlConfig is unchanged.
supported-version/src/services/build-services.ts New getDatabaseChoice() helper (mariadb preferred over mysql), branches the emitted service key
supported-version/src/versions/**/*.json 22 entries that encoded MariaDB by stuffing the image into the mysql field now use a top-level mariadb key
supported-version/src/services/build-services.spec.ts 6 new database-selection tests
supported-version/src/nightly/amend-matrix-for-next.spec.ts Fixtures gain mariadb: "" to satisfy the new required field
.github/workflows/integration.yaml Port lookup falls back: job.services.mysql.ports['3306'] || job.services.mariadb.ports['3306']
supported-version/README.md include_services description mentions MariaDB
supported-version/dist/index.js Rebuilt

What changed — setup-install

The companion install action also needs to understand the new key, since matrix lanes whose database is MariaDB now emit services.mariadb:

Area Change
setup-install/src/build-command.ts Added mariadb? to the Services interface; new getDatabaseService() helper (mariadb preferred) feeds the --db-host / --db-name / --db-user / --db-password flags
setup-install/src/index.ts The pre-install SET GLOBAL log_bin_trust_function_creators = 1; prep call routes through the same helper (the SQL and mysql CLI both work against MariaDB)
setup-install/src/build-command.spec.ts New mariadb-only and mariadb-preferred-over-mysql cases
setup-install/dist/index.js Rebuilt

⚠️ Breaking change for matrix consumers

GitHub Actions exposes each service container under a DNS alias that equals the map key in the services: block. With this change, any matrix lane whose database is MariaDB now emits services.mariadb instead of services.mysql. That affects:

  • Magento Open Source: the >=2.4.7 <2.4.8 range, the >=2.4.9 <2.4.10 range, the bare default and :next aliases, plus the individual entries 2.4.7 through 2.4.7-p10 and 2.4.9.
  • Mage-OS: >=1.0 <1.1 range, plus the individual entries 1.0.2 through 1.0.6.

Downstream workflows that reference job.services.mysql.* or that connect to host mysql from a job container will not resolve on those lanes. Two fixes for consumers:

# Option A: fallback expression (one-line edit; same pattern used internally here)
--port ${{ job.services.mysql.ports['3306'] || job.services.mariadb.ports['3306'] }}

# Option B: read the engine choice from the matrix entry directly
${{ matrix.mariadb && 'mariadb' || 'mysql' }}

Internal consumers in this repo are covered:

  • setup-install now accepts either service key (this PR)
  • setup-magento and warden/setup-environment already connect through db / 127.0.0.1 rather than the service-key alias
  • integration.yaml line 77 uses Option A above

Local build & test results

supported-version

$ npx jest
Test Suites: 12 passed, 12 total
Tests:       117 passed, 117 total
Snapshots:   0 total
Time:        1.136 s

$ npm run build
> npx esbuild --outfile=dist/index.js --platform=node --bundle --minify src/index.ts
  dist/index.js  497.1kb
⚡ Done in 13ms

setup-install

$ npx jest
Test Suites: 1 passed, 1 total
Tests:       18 passed, 18 total
Snapshots:   0 total
Time:        0.504 s

$ npm run build
> npx esbuild --outfile=dist/index.js --platform=node --bundle --minify src/index.ts
  dist/index.js  447.9kb
⚡ Done in 13ms

Test plan (CI)

  • CI setup-install (magento/project-community-edition:2.4.9) lane reaches Initialize containers successfully
  • CI setup-install (magento/project-community-edition:2.4.8-p5) lane still passes (confirms mysqladmin ping template still works for mysql-image lanes)
  • Spot-check generated matrix JSON for one mariadb lane and one mysql lane to confirm the service key (mariadb vs mysql) and health command

Fixes #365

🤖 Generated with Claude Code

The `mariadb:11.4` image used by Magento 2.4.9 no longer ships
`mysqladmin`, so the existing single MySQL service template
(`--health-cmd="mysqladmin ping"`) fails its health check and the
`setup-install` lane is torn down at "Initialize containers". A simple
swap to `healthcheck.sh --connect --innodb_initialized` would break the
`mysql:8.4` lanes (the script is MariaDB-only), so a single template
cannot cover both engines.

Per @damienwebdev's direction on issue mage-os#365, model MariaDB as its own
first-class service, mirroring the existing opensearch/elasticsearch
and valkey/redis patterns:

- `matrix-type.ts`: add `mariadb: string` to `PackageMatrixVersion`
- `service-config.ts`: add `mariadbConfig` with the healthcheck.sh
  command; leave `mysqlConfig` with `mysqladmin ping`
- `build-services.ts`: add `getDatabaseChoice()` that prefers mariadb
  over mysql; emit either `services.mariadb` or `services.mysql`
- version JSON: 22 entries that encoded MariaDB by stuffing the image
  into the `mysql` field now use a top-level `mariadb` key instead
- `build-services.spec.ts`: add a database-selection describe block
- `amend-matrix-for-next.spec.ts`: fixtures gain `mariadb: ""` to
  satisfy the new required field
- `.github/workflows/integration.yaml`: port lookup falls back from
  `job.services.mysql.ports['3306']` to the mariadb key
- `supported-version/README.md`: include_services description mentions
  MariaDB alongside MySQL
- `dist/index.js`: rebuilt

Fixes mage-os#365

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@rhoerr rhoerr force-pushed the fix/mariadb-service branch from f7a7635 to 0b24b58 Compare May 16, 2026 04:04
@rhoerr rhoerr marked this pull request as ready for review May 16, 2026 04:04
@rhoerr rhoerr requested a review from a team as a code owner May 16, 2026 04:04
Mirrors the matrix schema change in `supported-version`: the install
action now treats `services.mariadb` as equivalent to `services.mysql`
for both the bin/magento setup:install DB flags and the pre-install
`SET GLOBAL log_bin_trust_function_creators = 1;` prep statement
(supported by both engines).

- `build-command.ts`: add `mariadb?` to the `Services` interface and a
  small `getDatabaseService()` helper that prefers mariadb when both
  are present
- `index.ts`: route the mysql-cli prep call through the same helper
- `build-command.spec.ts`: add mariadb-only and mariadb-preferred-over-
  mysql cases; rename the existing mysql describe block to "database"
- `dist/index.js`: rebuilt

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@rhoerr rhoerr marked this pull request as draft May 16, 2026 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI fails for Magento 2.4.9: mariadb:11.4 healthcheck uses removed mysqladmin binary

1 participant