Build/Test Tools: Migrate to Docker Compose V2.

Compose V2, which was first released in 2020, is included with all currently supported versions of Docker Desktop. Compose V1 stopped receiving updates in July 2023.

The biggest difference is that the command to interact with Compose changed from `docker-compose` to `docker compose`.

GitHub has now started removing V1 from Ubuntu & Windows images, which caused all Docker-based GitHub Actions workflows to fail.

This change migrates to the new `docker compose` command to address these failures.

Merges [57918] to the 6.5 branch.

Props swissspidy, thelovekesh.
See #60901.

git-svn-id: https://develop.svn.wordpress.org/branches/6.5@57927 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers 2024-04-04 18:10:44 +00:00
parent 02c16c49a6
commit 7a7180a0f5
7 changed files with 27 additions and 31 deletions

View File

@ -108,12 +108,11 @@ jobs:
- name: Docker debug information
run: |
docker -v
docker-compose -v
docker-compose run --rm mysql mysql --version
docker-compose run --rm php php --version
docker-compose run --rm php php -m
docker-compose run --rm php php -i
docker-compose run --rm php locale -a
docker compose run --rm mysql mysql --version
docker compose run --rm php php --version
docker compose run --rm php php -m
docker compose run --rm php php -i
docker compose run --rm php locale -a
- name: Install WordPress
env:

View File

@ -142,12 +142,11 @@ jobs:
- name: Docker debug information
run: |
docker -v
docker-compose -v
docker-compose run --rm mysql mysql --version
docker-compose run --rm php php --version
docker-compose run --rm php php -m
docker-compose run --rm php php -i
docker-compose run --rm php locale -a
docker compose run --rm mysql mysql --version
docker compose run --rm php php --version
docker compose run --rm php php -m
docker compose run --rm php php -i
docker compose run --rm php locale -a
- name: Install WordPress
run: npm run env:install

View File

@ -130,7 +130,6 @@ jobs:
- name: Docker debug information
run: |
docker -v
docker-compose -v
- name: Start Docker environment
run: |
@ -141,11 +140,11 @@ jobs:
- name: WordPress Docker container debug information
run: |
docker-compose run --rm 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
docker-compose run --rm php locale -a
docker compose run --rm 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
docker compose run --rm php locale -a
- name: Install WordPress
run: npm run env:install
@ -184,4 +183,4 @@ jobs:
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && inputs.report }}
env:
WPT_REPORT_API_KEY: "${{ secrets.WPT_REPORT_API_KEY }}"
run: docker-compose run --rm -e WPT_REPORT_API_KEY -e WPT_PREPARE_DIR=/var/www -e WPT_TEST_DIR=/var/www php php test-runner/report.php
run: docker compose run --rm -e WPT_REPORT_API_KEY -e WPT_PREPARE_DIR=/var/www -e WPT_TEST_DIR=/var/www php php test-runner/report.php

View File

@ -123,7 +123,6 @@ jobs:
- name: Docker debug information
run: |
docker -v
docker-compose -v
- name: Start Docker environment
run: |
@ -134,11 +133,11 @@ jobs:
- name: WordPress Docker container debug information
run: |
docker-compose run --rm mysql mysql --version
docker-compose run --rm php php --version
docker-compose run --rm php php -m
docker-compose run --rm php php -i
docker-compose run --rm php locale -a
docker compose run --rm mysql mysql --version
docker compose run --rm php php --version
docker compose run --rm php php -m
docker compose run --rm php php -i
docker compose run --rm php locale -a
- name: Install WordPress
run: npm run env:install

View File

@ -4,5 +4,5 @@ const { execSync } = require( 'child_process' );
dotenvExpand.expand( dotenv.config() );
// Execute any docker-compose command passed to this script.
execSync( 'docker-compose ' + process.argv.slice( 2 ).join( ' ' ), { stdio: 'inherit' } );
// Execute any docker compose command passed to this script.
execSync( 'docker compose ' + process.argv.slice( 2 ).join( ' ' ), { stdio: 'inherit' } );

View File

@ -46,7 +46,7 @@ wait_on( { resources: [ `tcp:localhost:${process.env.LOCAL_PORT}`] } )
* @param {string} cmd The WP-CLI command to run.
*/
function wp_cli( cmd ) {
execSync( `docker-compose run --rm cli ${cmd}`, { stdio: 'inherit' } );
execSync( `docker compose run --rm cli ${cmd}`, { stdio: 'inherit' } );
}
/**
@ -55,6 +55,6 @@ function wp_cli( cmd ) {
function install_wp_importer() {
const testPluginDirectory = 'tests/phpunit/data/plugins/wordpress-importer';
execSync( `docker-compose exec -T php rm -rf ${testPluginDirectory}`, { stdio: 'inherit' } );
execSync( `docker-compose exec -T php git clone https://github.com/WordPress/wordpress-importer.git ${testPluginDirectory} --depth=1`, { stdio: 'inherit' } );
execSync( `docker compose exec -T php rm -rf ${testPluginDirectory}`, { stdio: 'inherit' } );
execSync( `docker compose exec -T php git clone https://github.com/WordPress/wordpress-importer.git ${testPluginDirectory} --depth=1`, { stdio: 'inherit' } );
}

View File

@ -19,7 +19,7 @@ try {
const containers = ( process.env.LOCAL_PHP_MEMCACHED === 'true' )
? 'wordpress-develop memcached'
: 'wordpress-develop';
execSync( `docker-compose up -d ${containers}`, { stdio: 'inherit' } );
execSync( `docker compose up -d ${containers}`, { stdio: 'inherit' } );
// If Docker Toolbox is being used, we need to manually forward LOCAL_PORT to the Docker VM.
if ( process.env.DOCKER_TOOLBOX_INSTALL_PATH ) {