Build/Test Tools: Install WordPress Importer plugin when installing the Docker-based local environment.

The WordPress Importer plugin is now downloaded to the `tests/phpunit/data/plugins` directory when running `npm run env:install`.

This ensures that the PHPUnit test suite will not fail when the plugin is missing.

This also introduces a new `WP_IMPORTER_REVISION` variable to the `.env` file, to control the SVN revision that is checked out.

Props johnbillion.
Fixes #49720.

git-svn-id: https://develop.svn.wordpress.org/trunk@50285 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers 2021-02-10 16:52:13 +00:00
parent 3d259c2b22
commit 6e49ac2e96
3 changed files with 22 additions and 4 deletions

11
.env
View File

@ -45,17 +45,21 @@ LOCAL_PHP_XDEBUG=false
# Whether or not to enable Memcached.
LOCAL_PHP_MEMCACHED=false
##
# The database software to use.
#
# Supported values are `mysql` and `mariadb`.
##
LOCAL_DB_TYPE=mysql
##
# The database version to use.
#
# Defaults to 5.7 with the assumption that LOCAL_DB_TYPE is set to `mysql` above.
#
# When using `mysql`, see https://hub.docker.com/_/mysql/ for valid versions.
# When using `mariadb`, see https://hub.docker.com/_/mariadb for valid versions.
##
LOCAL_DB_VERSION=5.7
# The debug settings to add to `wp-config.php`.
@ -67,3 +71,10 @@ LOCAL_WP_ENVIRONMENT_TYPE=local
# The URL to use when running e2e tests.
WP_BASE_URL=http://localhost:${LOCAL_PORT}
##
# The revision number of the WordPress Importer plugin to use when running unit tests.
#
# This should be an SVN revision number from the official plugin repository on wordpress.org.
##
WP_IMPORTER_REVISION=2387243

View File

@ -24,7 +24,6 @@ jobs:
# Performs the following steps:
# - Cancels all previous workflow runs for pull requests that have not completed.
# - Checks out the repository.
# - Checks out the WordPress Importer plugin (needed for the Core PHPUnit tests).
# - Logs debug information about the runner container.
# - Installs NodeJS 14.
# - Sets up caching for NPM.
@ -47,9 +46,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2
- name: Checkout the WordPress Importer plugin
run: svn checkout -r 2387243 https://plugins.svn.wordpress.org/wordpress-importer/trunk/ tests/phpunit/data/plugins/wordpress-importer
- name: Log debug information
run: |
echo "$GITHUB_REF"

View File

@ -20,6 +20,8 @@ wp_cli( `config set WP_ENVIRONMENT_TYPE ${process.env.LOCAL_WP_ENVIRONMENT_TYPE}
// Move wp-config.php to the base directory, so it doesn't get mixed up in the src or build directories.
renameSync( 'src/wp-config.php', 'wp-config.php' );
install_wp_importer();
// 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' )
@ -45,3 +47,12 @@ wait_on( { resources: [ `tcp:localhost:${process.env.LOCAL_PORT}`] } )
function wp_cli( cmd ) {
execSync( `docker-compose run --rm cli ${cmd}`, { stdio: 'inherit' } );
}
/**
* Downloads the WordPress Importer plugin for use in tests.
*/
function install_wp_importer() {
const test_plugin_directory = 'tests/phpunit/data/plugins/wordpress-importer';
execSync( `docker-compose exec -T php rm -rf ${test_plugin_directory} && svn checkout -r ${process.env.WP_IMPORTER_REVISION} https://plugins.svn.wordpress.org/wordpress-importer/trunk/ ${test_plugin_directory}`, { stdio: 'inherit' } );
}