Skip to content

Commit c502d08

Browse files
authored
Merge pull request #1001 from Automattic/issue-1000-normalize-replay-php
Normalize replay export PHP versions
2 parents 26ddbd5 + 4ad7f56 commit c502d08

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

packages/runtime-playground/src/replayable-wordpress-site-bundle.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ export function buildReplayableWordPressSiteBlueprint(
228228
$schema: "https://playground.wordpress.net/blueprint-schema.json",
229229
preferredVersions: {
230230
wp: snapshot.compatibility.wordpressVersion,
231-
php: snapshot.compatibility.phpVersion,
231+
php: playgroundBlueprintPhpVersion(snapshot.compatibility.phpVersion),
232232
},
233233
landingPage: options.landingPage ?? "/",
234234
steps: [
@@ -249,7 +249,7 @@ export function buildReplayExportBlueprint(
249249
$schema: "https://playground.wordpress.net/blueprint-schema.json",
250250
preferredVersions: {
251251
wp: snapshot.compatibility.wordpressVersion,
252-
php: snapshot.compatibility.phpVersion,
252+
php: playgroundBlueprintPhpVersion(snapshot.compatibility.phpVersion),
253253
},
254254
landingPage: options.landingPage ?? "/",
255255
steps: [
@@ -319,6 +319,10 @@ function runtimeInfoForReplayableWordPressSite(
319319
}
320320
}
321321

322+
function playgroundBlueprintPhpVersion(version: string): string {
323+
return version.replace(/^(\d+\.\d+)\.\d+$/, "$1")
324+
}
325+
322326
async function writeJson(path: string, value: unknown): Promise<void> {
323327
await writeFile(path, `${JSON.stringify(value, null, 2)}\n`)
324328
}

scripts/replay-export-blueprint-smoke.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const snapshot: RuntimeSnapshotArtifact = {
1010
compatibility: {
1111
backend: "wordpress-playground",
1212
wordpressVersion: "latest",
13-
phpVersion: "8.3",
13+
phpVersion: "8.3.31",
1414
},
1515
metadata: {
1616
runtime: {
@@ -53,6 +53,11 @@ if (!validation.valid) {
5353
throw new Error(`Replay export blueprint is not schema-valid: ${JSON.stringify(validation.errors, null, 2)}`)
5454
}
5555

56+
const preferredVersions = blueprint.preferredVersions as Record<string, unknown> | undefined
57+
if (preferredVersions?.php !== "8.3") {
58+
throw new Error(`Replay export blueprint must normalize patch-level PHP versions, got ${JSON.stringify(preferredVersions?.php)}`)
59+
}
60+
5661
if ("x-wp-codebox" in blueprint) {
5762
throw new Error("Replay export blueprint must not include top-level x-wp-codebox metadata")
5863
}

0 commit comments

Comments
 (0)