Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b2ee325
Env: Add a MariaDB version validator
desrosj Sep 29, 2026
74e817f
Env: Parse the mariadbVersion option and WP_ENV_MARIADB_VERSION
desrosj Sep 29, 2026
2c66eb3
Env: Use the configured MariaDB version for the database image and he…
desrosj Sep 29, 2026
3c46564
Env: Document the mariadbVersion option and add it to the schema
desrosj Sep 29, 2026
ef273b3
Env: Detect healthcheck.sh in pinned MariaDB images instead of matchi…
desrosj Sep 29, 2026
964b1e2
Env: Link the MariaDB version changelog entry to its PR
desrosj Sep 29, 2026
ad38c10
Merge branch 'trunk' into add/database-version-control-to-wp-env
desrosj Sep 29, 2026
5cc17af
Merge branch 'trunk' into add/database-version-control-to-wp-env
desrosj Sep 29, 2026
706b900
Merge branch 'trunk' into add/database-version-control-to-wp-env
desrosj Oct 1, 2026
30874d3
Env: Fix the health check for older MariaDB images.
desrosj Oct 1, 2026
23f53b6
Env: Explain when a database was last used by a newer MariaDB.
desrosj Oct 2, 2026
80a1c59
Env: Use one MariaDB health check for every version.
desrosj Oct 2, 2026
7cc2a91
Env: Define the MariaDB image tags and default in one place.
desrosj Oct 2, 2026
91d3614
Env: Validate PHP and MariaDB versions with one anchored pattern.
desrosj Oct 2, 2026
e535c7c
Env: Test what the MariaDB health check does, not its text.
desrosj Oct 2, 2026
427f8ec
Env: Correct which MariaDB versions need emulation on ARM.
desrosj Oct 2, 2026
25a976c
Env: Name images that cannot be pulled or found locally.
desrosj Oct 2, 2026
1a602e5
Merge branch 'trunk' into add/database-version-control-to-wp-env
desrosj Oct 5, 2026
cbd1928
Env: Remove a health check test that can no longer fail.
desrosj Oct 5, 2026
8f7e27f
Env: Check the database versions in parallel.
desrosj Oct 5, 2026
17b285a
Env: Say what `wp-env cleanup` removes when suggesting it.
desrosj Oct 5, 2026
c687c83
Env: Only report a MariaDB downgrade when a database failed to start.
desrosj Oct 5, 2026
f400648
Env: Only run healthcheck.sh when the MariaDB image has it.
desrosj Oct 5, 2026
794ca55
Env: Skip the MariaDB health check shell tests on Windows.
desrosj Oct 5, 2026
478674e
Merge branch 'trunk' into add/database-version-control-to-wp-env
desrosj Oct 5, 2026
f6b0a70
Merge branch 'add/database-version-control-to-wp-env' of https://gith…
desrosj Oct 5, 2026
099afff
Env: Let `wp db` commands connect to MariaDB versions before 11.4.
desrosj Oct 5, 2026
bcbad4f
Merge branch 'trunk' into add/database-version-control-to-wp-env
desrosj Oct 6, 2026
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
Prev Previous commit
Next Next commit
Env: Detect healthcheck.sh in pinned MariaDB images instead of matchi…
…ng versions
  • Loading branch information
desrosj committed Sep 29, 2026
commit ef273b341625990d7b8e9291e3550f7eefc7b628
30 changes: 13 additions & 17 deletions packages/env/lib/runtime/docker/build-docker-compose-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,21 @@ function getMounts(
];
}

/**
* MariaDB versions whose images predate `healthcheck.sh` and `mariadb-admin`.
* A major-only "5" is included because the `mariadb:5` tag is 5.5.
*/
const LEGACY_MARIADB_VERSIONS = [ '5', '5.5', '10.0', '10.1', '10.2', '10.3' ];

/**
* Gets the database healthcheck for the given MariaDB version.
*
* Images from 10.4 onward ship MariaDB's `healthcheck.sh`:
* The default `lts` and `latest` images ship MariaDB's `healthcheck.sh`:
* --connect verifies a TCP connection and that the entrypoint has finished,
* and --innodb_initialized ensures InnoDB is fully initialized. The
* MARIADB_AUTO_UPGRADE env var ensures its healthcheck user exists for
* existing installations.
*
* Older images have neither `healthcheck.sh` nor `mariadb-admin`, so they are
* pinged with `mysqladmin` over TCP. Using 127.0.0.1 rather than localhost
* avoids the Unix socket, which the temporary server used to initialize a new
* volume answers before the real server is listening.
* Images for a pinned version may predate `healthcheck.sh` (it was added to
* the images in 2023, and older tags were never rebuilt), so for those the
* script is used when present and `mysqladmin` is pinged over TCP otherwise.
* Using 127.0.0.1 rather than localhost avoids the Unix socket, which the
* temporary server used to initialize a new volume answers before the real
* server is listening.
*
* Timing is generous to support slow CI environments.
*
Expand All @@ -99,15 +95,15 @@ const LEGACY_MARIADB_VERSIONS = [ '5', '5.5', '10.0', '10.1', '10.2', '10.3' ];
* @return {Object} A docker-compose healthcheck object.
*/
function getMariaDBHealthcheck( mariadbVersion ) {
const majorMinor = ( mariadbVersion ?? '' )
.split( '.' )
.slice( 0, 2 )
.join( '.' );
const isPinned =
Comment thread
desrosj marked this conversation as resolved.
Outdated
!! mariadbVersion &&
mariadbVersion !== 'lts' &&
mariadbVersion !== 'latest';

const test = LEGACY_MARIADB_VERSIONS.includes( majorMinor )
const test = isPinned
? [
'CMD-SHELL',
'mysqladmin ping -h 127.0.0.1 --protocol=tcp -uroot -p"$$MYSQL_ROOT_PASSWORD"',
'if command -v healthcheck.sh > /dev/null; then healthcheck.sh --connect --innodb_initialized; else mysqladmin ping -h 127.0.0.1 --protocol=tcp -uroot -p"$$MYSQL_ROOT_PASSWORD"; fi',
Comment thread
desrosj marked this conversation as resolved.
Outdated
]
: [ 'CMD', 'healthcheck.sh', '--connect', '--innodb_initialized' ];

Expand Down
28 changes: 20 additions & 8 deletions packages/env/lib/test/build-docker-compose-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ describe( 'buildDockerComposeConfig', () => {
start_period: '60s',
};

const LEGACY_HEALTHCHECK = {
const PINNED_HEALTHCHECK = {
test: [
'CMD-SHELL',
'mysqladmin ping -h 127.0.0.1 --protocol=tcp -uroot -p"$$MYSQL_ROOT_PASSWORD"',
'if command -v healthcheck.sh > /dev/null; then healthcheck.sh --connect --innodb_initialized; else mysqladmin ping -h 127.0.0.1 --protocol=tcp -uroot -p"$$MYSQL_ROOT_PASSWORD"; fi',
],
interval: '5s',
timeout: '10s',
Expand Down Expand Up @@ -257,7 +257,7 @@ describe( 'buildDockerComposeConfig', () => {

expect( config.services.mysql.image ).toBe( 'mariadb:10.3' );
expect( config.services.mysql.healthcheck ).toEqual(
LEGACY_HEALTHCHECK
PINNED_HEALTHCHECK
);
expect( config.services[ 'tests-mysql' ].image ).toBe(
'mariadb:latest'
Expand All @@ -267,24 +267,36 @@ describe( 'buildDockerComposeConfig', () => {
);
} );

it.each( [ '5', '5.5', '10.0', '10.1', '10.2', '10.3', '10.3.39' ] )(
'uses the legacy health check for %j',
it.each( [
'5',
'5.5',
'10.0',
'10.3',
'10.3.39',
'10.5.8',
'10.6.4',
'10',
'10.11',
'11',
'11.4.2',
] )(
Comment thread
desrosj marked this conversation as resolved.
Outdated
'uses the health check that detects healthcheck.sh for %j',
( version ) => {
const config = buildWithVersions( version, version );

expect( config.services.mysql.image ).toBe(
`mariadb:${ version }`
);
expect( config.services.mysql.healthcheck ).toEqual(
LEGACY_HEALTHCHECK
PINNED_HEALTHCHECK
);
expect( config.services[ 'tests-mysql' ].healthcheck ).toEqual(
LEGACY_HEALTHCHECK
PINNED_HEALTHCHECK
);
}
);

it.each( [ 'lts', 'latest', '10', '10.4', '10.11', '11', '11.4.2' ] )(
it.each( [ 'lts', 'latest' ] )(
'uses the current health check for %j',
( version ) => {
const config = buildWithVersions( version, version );
Expand Down
Loading