Skip to content

Commit bfc88f7

Browse files
authored
Merge pull request #2410 from Automattic/fix/2409-bench-custom-drop-in
Bench: select custom drop-in setup for pre-install db.php mounts
2 parents 0d55244 + 50aa39d commit bfc88f7

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

‎packages/runtime-core/src/recipe-builders.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,21 @@ function normalizeRecipeSteps(steps: readonly WorkspaceRecipeStep[], label: stri
210210
export function buildWordPressBenchRecipe(options: WordPressBenchRecipeOptions): WorkspaceRecipe {
211211
const pluginSlug = requiredPluginSlug(options.pluginSlug, "buildWordPressBenchRecipe")
212212
const componentId = options.componentId?.trim() || pluginSlug
213+
const mounts = normalizeRecipeMounts(options.mounts, { defaultMode: "readonly" })
214+
const hasCustomDatabaseDropIn = mounts.some((mount) => mount.type === "file"
215+
&& mount.phase === "pre-install"
216+
&& mount.target === "/wordpress/wp-content/db.php")
213217

214218
return {
215219
schema: "wp-codebox/workspace-recipe/v1",
216220
runtime: {
217221
wp: options.wordpressVersion ?? DEFAULT_WORDPRESS_VERSION,
222+
...(hasCustomDatabaseDropIn ? { databaseSetup: "custom-drop-in" as const } : {}),
218223
blueprint: blueprintWithWpConfigDefines(options.blueprint ?? {}, options.wpConfigDefines ?? {}),
219224
},
220225
inputs: {
221226
extra_plugins: normalizeExtraPlugins(options.extra_plugins),
222-
mounts: normalizeRecipeMounts(options.mounts, { defaultMode: "readonly" }),
227+
mounts,
223228
},
224229
workflow: {
225230
...(options.prepareSteps && options.prepareSteps.length > 0 ? { before: normalizeRecipeSteps(options.prepareSteps, "prepareSteps") } : {}),

‎tests/recipe-builder-bench-steps.test.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,29 @@ assert.deepEqual(recipe.inputs.extra_plugins?.[0], {
3232
originalSource: "/tmp/monorepo/plugins/fixture-plugin",
3333
slug: "fixture-plugin",
3434
})
35+
assert.equal(recipe.runtime.databaseSetup, undefined)
36+
37+
const customDropInRecipe = buildWordPressBenchRecipe({
38+
pluginSlug: "fixture-plugin",
39+
mounts: [{
40+
type: "file",
41+
source: "/tmp/db.php",
42+
target: "//wordpress//wp-content//db.php",
43+
phase: "pre-install",
44+
}],
45+
})
46+
assert.equal(customDropInRecipe.runtime.databaseSetup, "custom-drop-in")
47+
assert.equal(customDropInRecipe.inputs.mounts?.[0]?.target, "/wordpress/wp-content/db.php")
48+
49+
const postInstallDropInRecipe = buildWordPressBenchRecipe({
50+
pluginSlug: "fixture-plugin",
51+
mounts: [{
52+
type: "file",
53+
source: "/tmp/db.php",
54+
target: "/wordpress/wp-content/db.php",
55+
phase: "post-install",
56+
}],
57+
})
58+
assert.equal(postInstallDropInRecipe.runtime.databaseSetup, undefined)
3559

3660
console.log("recipe builder bench steps ok")

0 commit comments

Comments
 (0)