From 29531de7685a8d166707a0f2409ab8517b1b2dff Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Sat, 28 Aug 2021 21:16:22 +0000 Subject: [PATCH] Build/Test Tools: Install the Composer package dependencies within the Docker environment as part of the local development environment installation and testing processes. This makes the use of Composer on the host machine optional when using the Docker environment, which means there is no change to the process for installing, updating, and running the tests since [51559]. Props hellofromTonya, azaozz, netweb, desrosj, jrf, johnbillion Fixes #53945 git-svn-id: https://develop.svn.wordpress.org/trunk@51685 602fd350-edb4-49c9-b593-d223f7449a82 --- package.json | 4 ++-- tools/local-env/scripts/install.js | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d680c53851..ce21d01bc7 100644 --- a/package.json +++ b/package.json @@ -170,8 +170,8 @@ "env:cli": "node ./tools/local-env/scripts/docker.js run cli", "env:logs": "node ./tools/local-env/scripts/docker.js logs", "env:pull": "node ./tools/local-env/scripts/docker.js pull", - "test:php": "node ./tools/local-env/scripts/docker.js run --rm phpunit phpunit", - "test:php-composer": "node ./tools/local-env/scripts/docker.js run --rm phpunit php ./vendor/bin/phpunit", + "test:php": "node ./tools/local-env/scripts/docker.js run -T php composer update -W && node ./tools/local-env/scripts/docker.js run --rm phpunit phpunit", + "test:php-composer": "node ./tools/local-env/scripts/docker.js run -T php composer update -W && node ./tools/local-env/scripts/docker.js run --rm phpunit php ./vendor/bin/phpunit", "test:e2e": "node ./tests/e2e/run-tests.js", "wp-packages-update": "wp-scripts packages-update" } diff --git a/tools/local-env/scripts/install.js b/tools/local-env/scripts/install.js index 4a21b99953..762273598e 100644 --- a/tools/local-env/scripts/install.js +++ b/tools/local-env/scripts/install.js @@ -22,6 +22,8 @@ renameSync( 'src/wp-config.php', 'wp-config.php' ); install_wp_importer(); +install_composer_dependencies(); + // Read in wp-tests-config-sample.php, edit it to work with our config, then write it to wp-tests-config.php. const testConfig = readFileSync( 'wp-tests-config-sample.php', 'utf8' ) .replace( 'youremptytestdbnamehere', 'wordpress_develop_tests' ) @@ -57,3 +59,10 @@ function install_wp_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' } ); } + +/** + * Installs the Composer package dependencies within the Docker environment. + */ +function install_composer_dependencies() { + execSync( `docker-compose run -T php composer update -W`, { stdio: 'inherit' } ); +}