Fix path to wp-env.json file in release-checks runs (#49397)
This commit is contained in:
parent
4d68cd486e
commit
e4aff57e56
|
@ -194,9 +194,9 @@ jobs:
|
|||
env:
|
||||
RELEASE_TAG: ${{ github.ref_name }}
|
||||
ARTIFACT_NAME: ${{ github.ref_name == 'nightly' && 'woocommerce-trunk-nightly.zip' || 'woocommerce.zip' }}
|
||||
WP_ENV_CONFIG_PATH: ${{ matrix.projectPath }}
|
||||
working-directory: ${{ matrix.projectPath }}
|
||||
run: node ./github/workflows/scripts/override-wp-env-plugins.js
|
||||
# band-aid to get the path to wp-env.json for blocks e2e tests, until they're migrated to plugins/woocommerce
|
||||
WP_ENV_CONFIG_PATH: ${{ github.workspace }}/${{ matrix.testEnv.start == 'env:start:blocks' && 'plugins/woocommerce-blocks' || matrix.projectPath }}
|
||||
run: node .github/workflows/scripts/override-wp-env-plugins.js
|
||||
|
||||
- name: 'Start Test Environment'
|
||||
id: 'prepare-test-environment'
|
||||
|
|
|
@ -20,24 +20,50 @@ if ( ! WP_ENV_CONFIG_PATH ) {
|
|||
|
||||
const artifactUrl = `https://github.com/woocommerce/woocommerce/releases/download/${ RELEASE_TAG }/${ ARTIFACT_NAME }`;
|
||||
|
||||
const testEnvPlugins = {
|
||||
env: {
|
||||
tests: {
|
||||
plugins: [],
|
||||
},
|
||||
},
|
||||
};
|
||||
const data = fs.readFileSync( `${ WP_ENV_CONFIG_PATH }/.wp-env.json`, 'utf8' );
|
||||
const configPath = `${ WP_ENV_CONFIG_PATH }/.wp-env.json`;
|
||||
console.log( `Reading ${ configPath }` );
|
||||
const data = fs.readFileSync( configPath, 'utf8' );
|
||||
const wpEnvConfig = JSON.parse( data );
|
||||
testEnvPlugins.env.tests.plugins = wpEnvConfig.env.tests.plugins;
|
||||
|
||||
const currentDirEntry = testEnvPlugins.env.tests.plugins.indexOf( '.' );
|
||||
const overrideConfig = {};
|
||||
|
||||
if ( currentDirEntry !== -1 ) {
|
||||
testEnvPlugins.env.tests.plugins[ currentDirEntry ] = artifactUrl;
|
||||
if ( wpEnvConfig.plugins ) {
|
||||
overrideConfig.plugins = wpEnvConfig.plugins;
|
||||
}
|
||||
|
||||
fs.writeFileSync(
|
||||
`${ WP_ENV_CONFIG_PATH }/.wp-env.override.json`,
|
||||
JSON.stringify( testEnvPlugins, null, 2 )
|
||||
if ( wpEnvConfig.env?.tests?.plugins ) {
|
||||
overrideConfig.env = {
|
||||
tests: {
|
||||
plugins: wpEnvConfig.env.tests.plugins,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const entriesToReplace = [ '.', '../woocommerce' ];
|
||||
|
||||
for ( const entry of entriesToReplace ) {
|
||||
// Search and replace in root plugins
|
||||
let found = overrideConfig.plugins.indexOf( entry );
|
||||
if ( found >= 0 ) {
|
||||
console.log(
|
||||
`Replacing ${ entry } with ${ artifactUrl } in root plugins`
|
||||
);
|
||||
overrideConfig.plugins[ found ] = artifactUrl;
|
||||
}
|
||||
|
||||
// Search and replace in test env plugins
|
||||
found = overrideConfig.env?.tests?.plugins?.indexOf( entry );
|
||||
if ( found >= 0 ) {
|
||||
console.log(
|
||||
`Replacing ${ entry } with ${ artifactUrl } in env.tests.plugins`
|
||||
);
|
||||
overrideConfig.env.tests.plugins[ found ] = artifactUrl;
|
||||
}
|
||||
}
|
||||
|
||||
const overrideConfigPath = `${ WP_ENV_CONFIG_PATH }/.wp-env.override.json`;
|
||||
console.log( `Saving ${ overrideConfigPath }` );
|
||||
fs.writeFileSync(
|
||||
overrideConfigPath,
|
||||
JSON.stringify( overrideConfig, null, 2 )
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue