From f158f6d3f22abbc9dd7fa7d23041a3c6ffdcac44 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 3 Apr 2024 11:31:43 +0000 Subject: [PATCH] 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. Props swissspidy, thelovekesh. Fixes #60901. git-svn-id: https://develop.svn.wordpress.org/trunk@57918 602fd350-edb4-49c9-b593-d223f7449a82 --- .github/workflows/end-to-end-tests.yml | 11 +++++------ .github/workflows/performance.yml | 11 +++++------ .github/workflows/phpunit-tests-run.yml | 13 ++++++------- .github/workflows/test-coverage.yml | 11 +++++------ tools/local-env/scripts/docker.js | 4 ++-- tools/local-env/scripts/install.js | 6 +++--- tools/local-env/scripts/start.js | 2 +- 7 files changed, 27 insertions(+), 31 deletions(-) diff --git a/.github/workflows/end-to-end-tests.yml b/.github/workflows/end-to-end-tests.yml index ec473f161c..757de1f9a4 100644 --- a/.github/workflows/end-to-end-tests.yml +++ b/.github/workflows/end-to-end-tests.yml @@ -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: diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index ae4f205f09..62663c730b 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -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 diff --git a/.github/workflows/phpunit-tests-run.yml b/.github/workflows/phpunit-tests-run.yml index 5cf360dab0..68f9d003a4 100644 --- a/.github/workflows/phpunit-tests-run.yml +++ b/.github/workflows/phpunit-tests-run.yml @@ -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 diff --git a/.github/workflows/test-coverage.yml b/.github/workflows/test-coverage.yml index 97c3b42740..e109a20a7c 100644 --- a/.github/workflows/test-coverage.yml +++ b/.github/workflows/test-coverage.yml @@ -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 diff --git a/tools/local-env/scripts/docker.js b/tools/local-env/scripts/docker.js index fed70aeb59..b33fc2b3ed 100644 --- a/tools/local-env/scripts/docker.js +++ b/tools/local-env/scripts/docker.js @@ -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' } ); diff --git a/tools/local-env/scripts/install.js b/tools/local-env/scripts/install.js index e8a448c8c9..891d43cc42 100644 --- a/tools/local-env/scripts/install.js +++ b/tools/local-env/scripts/install.js @@ -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' } ); } diff --git a/tools/local-env/scripts/start.js b/tools/local-env/scripts/start.js index df27a67a62..b929dce0b6 100644 --- a/tools/local-env/scripts/start.js +++ b/tools/local-env/scripts/start.js @@ -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 ) {