From ea80ac8082ab983b91324836f466a8b585fe8590 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Wed, 4 Dec 2024 15:16:02 +0000 Subject: [PATCH] Build/Test Tools: Support older MariaDB versions in local Docker environment. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Older versions of MariaDB did not contain the `mariadb-admin` command. This command is configured as the `healthcheck` used by the local Docker environment to confirm that the database container has successfully started and is reporting as “healthy”. The current result is a failure when starting the environment while using one of the affected older versions. For MariaDB versions 10.3 and earlier, the `mysqladmin` command was used instead. Since WordPress still technically supports back to MariaDB 5.5, the local environment should support running these versions. This updates the environment configuration to take this into account when performing a `healthcheck` test. The README file is also updated to reflect that the same workaround added in [57568] for MySQL <= 5.7 is required when using MariaDB 5.5 on an Apple silicon machine. Props johnbillion. See #62221. git-svn-id: https://develop.svn.wordpress.org/trunk@59484 602fd350-edb4-49c9-b593-d223f7449a82 --- .github/workflows/reusable-phpunit-tests-v3.yml | 2 +- README.md | 9 ++++++--- docker-compose.yml | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/reusable-phpunit-tests-v3.yml b/.github/workflows/reusable-phpunit-tests-v3.yml index 56e40e762cd27..fd21b3a9b48f5 100644 --- a/.github/workflows/reusable-phpunit-tests-v3.yml +++ b/.github/workflows/reusable-phpunit-tests-v3.yml @@ -171,7 +171,7 @@ jobs: - name: WordPress Docker container debug information run: | - docker compose run --rm mysql ${{ env.LOCAL_DB_TYPE }} --version + docker compose run --rm mysql ${{ env.LOCAL_DB_TYPE == 'mariadb' && contains( fromJSON('["5.5", "10.0", "10.1", "10.2", "10.3"]'), env.LOCAL_DB_VERSION ) && 'mysql' || env.LOCAL_DB_TYPE }} --version docker compose run --rm php php --version docker compose run --rm php php -m docker compose run --rm php php -i diff --git a/README.md b/README.md index adb4fc946d9a8..fc8c00f6821af 100644 --- a/README.md +++ b/README.md @@ -139,11 +139,14 @@ The development environment can be reset. This will destroy the database and att npm run env:reset ``` -### Apple Silicon machines and old MySQL versions +### Apple Silicon machines and old MySQL/MariaDB versions -The MySQL Docker images do not support Apple Silicon processors (M1, M2, etc.) for MySQL versions 5.7 and earlier. +Older MySQL and MariaDB Docker images do not support Apple Silicon processors (M1, M2, etc.). This is true for: -When using MySQL <= 5.7 on an Apple Silicon machine, you must create a `docker-compose.override.yml` file with the following contents: +- MySQL versions 5.7 and earlier +- MariaDB 5.5 + +When using these versions on an Apple Silicon machine, you must create a `docker-compose.override.yml` file with the following contents: ``` services: diff --git a/docker-compose.yml b/docker-compose.yml index 8b90b678a00a2..a95735fdd35a0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -82,7 +82,7 @@ services: command: ${LOCAL_DB_AUTH_OPTION-} healthcheck: - test: [ "CMD-SHELL", "if [ \"$LOCAL_DB_TYPE\" = \"mariadb\" ]; then mariadb-admin ping -h localhost; else mysqladmin ping -h localhost; fi" ] + test: [ "CMD-SHELL", "if [ \"$LOCAL_DB_TYPE\" = \"mariadb\" ]; then case \"$LOCAL_DB_VERSION\" in 5.5|10.0|10.1|10.2|10.3) mysqladmin ping -h localhost || exit $?;; *) mariadb-admin ping -h localhost || exit $?;; esac; else mysqladmin ping -h localhost || exit $?; fi" ] timeout: 5s interval: 5s retries: 10