Skip to content

Commit

Permalink
Build/Test Tools: Migrate to Docker Compose V2.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
swissspidy committed Apr 3, 2024
1 parent 6fda95a commit f158f6d
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 31 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/end-to-end-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/phpunit-tests-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ jobs:
- name: Docker debug information
run: |
docker -v
docker-compose -v
- name: Start Docker environment
run: |
Expand All @@ -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
Expand Down Expand Up @@ -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
11 changes: 5 additions & 6 deletions .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ jobs:
- name: Docker debug information
run: |
docker -v
docker-compose -v
- name: Start Docker environment
run: |
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tools/local-env/scripts/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' } );
6 changes: 3 additions & 3 deletions tools/local-env/scripts/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' } );
}

/**
Expand All @@ -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' } );
}
2 changes: 1 addition & 1 deletion tools/local-env/scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down

0 comments on commit f158f6d

Please sign in to comment.