Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Env: Bind "core" files to tests environment #21195

Merged
merged 2 commits into from
Mar 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 50 additions & 7 deletions packages/env/lib/build-docker-compose-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,56 @@ module.exports = function buildDockerComposeConfig( config ) {
...themeMounts,
];

const testsMounts = [
`${
config.coreSource ? config.coreSource.testsPath : 'tests-wordpress'
}:/var/www/html`,
...pluginMounts,
...themeMounts,
];
let testsMounts;
if ( config.coreSource ) {
noisysocks marked this conversation as resolved.
Show resolved Hide resolved
testsMounts = [
`${ config.coreSource.testsPath }:/var/www/html`,

// When using a local source for "core" we want to ensure two things:
//
// 1. That changes the user makes within the "core" directory are
// served in both the development and tests environments.
// 2. That the development and tests environment use separate
// databases and `wp-content/uploads`.
//
// To do this we copy the local "core" files ($wordpress) to a tests
// directory ($tests-wordpress) and instruct the tests environment
// to source its files like so:
//
// - wp-config.php <- $tests-wordpress/wp-config.php
// - wp-config-sample.php <- $tests-wordpress/wp-config.php
// - wp-content <- $tests-wordpress/wp-content
// - * <- $wordpress/*
//
// https://github.com/WordPress/gutenberg/issues/21164
...( config.coreSource.type === 'local'
? fs
.readdirSync( config.coreSource.path )
.filter(
( filename ) =>
filename !== 'wp-config.php' &&
filename !== 'wp-config-sample.php' &&
filename !== 'wp-content'
)
.map(
( filename ) =>
`${ path.join(
config.coreSource.path,
filename
) }:/var/www/html/${ filename }`
)
: [] ),

...pluginMounts,
...themeMounts,
];
} else {
testsMounts = [
'tests-wordpress:/var/www/html',
...pluginMounts,
...themeMounts,
];
}

// Set the default ports based on the config values.
const developmentPorts = `\${WP_ENV_PORT:-${ config.port }}:80`;
Expand Down