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
This commit is contained in:
John Blackbourn 2021-08-28 21:16:22 +00:00
parent b29e32c28f
commit 29531de768
2 changed files with 11 additions and 2 deletions

View File

@ -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"
}

View File

@ -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' } );
}