Skip to content
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
20 changes: 18 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,25 @@ jobs:
- name: Install Composer dependencies
run: composer install

- name: Set PHP version for wp-env
- name: Set PHP version and filter missing plugins for wp-env
run: |
echo "{\"config\": {\"phpVersion\": \"${{ matrix.php }}\"}}" > .wp-env.override.json
node -e "
const fs = require('fs');
const path = require('path');
const config = JSON.parse(fs.readFileSync('.wp-env.json', 'utf8'));
const override = { config: { phpVersion: '${{ matrix.php }}' }, env: {} };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

wp-env.override.json phpVersion schema documentation

💡 Result:

Where is the wp-env JSON schema documented?

WordPress publishes a JSON Schema for wp-env config files (.wp-env.json / .wp-env.override.json). You can reference it via $schema:

  • Trunk schema URL: https://schemas.wp.org/trunk/wp-env.json (note: tagged versions may not be available there). [2]
  • Pinned to a specific @wordpress/env version:
    https://raw.githubusercontent.com/WordPress/gutenberg/@wordpress/env@x.y.z/schemas/json/wp-env.json [2]
    Note: version 10.1.0 used a filename with a leading dot (.wp-env.json) in the schema name; later versions don’t. [2]

Example:

{
  "$schema": "https://schemas.wp.org/trunk/wp-env.json",
  "phpVersion": "8.2"
}

What’s the phpVersion field (including in .wp-env.override.json)?

  • phpVersion is supported in .wp-env.json with type string | null and sets the PHP version used by wp-env. If null, wp-env uses its default. [1]
  • .wp-env.override.json uses the same shape; any fields you set there take precedence over .wp-env.json (with only config and mappings being merged). [1]
  • Example value: "phpVersion": "8.2" is shown in WordPress’s wp-env docs/posts and is expected to work. [3]

Sources: [1] [2] [3]


phpVersion must be a top-level property, not nested under config.

In the wp-env override schema, phpVersion sets the actual PHP version used by the environment and belongs at the top level of the override object. The config key is reserved for wp-config.php constants. As currently written, this code would add a PHP constant instead of changing the runtime version.

Fix
-            const override = { config: { phpVersion: '${{ matrix.php }}' }, env: {} };
+            const override = { phpVersion: '${{ matrix.php }}', env: {} };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const override = { config: { phpVersion: '${{ matrix.php }}' }, env: {} };
const override = { phpVersion: '${{ matrix.php }}', env: {} };
🤖 Prompt for AI Agents
In @.github/workflows/e2e.yml at line 65, The override object currently nests
phpVersion under config which makes it a wp-config constant; instead set
phpVersion as a top-level property on the override object. Update the override
variable (named override) so it has phpVersion: '${{ matrix.php }}' alongside
env rather than inside config, and keep config only for wp-config constants;
ensure the resulting object shape matches the wp-env override schema (top-level
phpVersion, config, env).

for (const [envName, envConfig] of Object.entries(config.env || {})) {
if (envConfig.plugins) {
const existing = envConfig.plugins.filter(p => {
const resolved = path.resolve(p);
return fs.existsSync(resolved);
});
override.env[envName] = { plugins: existing };
}
}
fs.writeFileSync('.wp-env.override.json', JSON.stringify(override, null, 2));
console.log('Override:', JSON.stringify(override, null, 2));
"

- name: Start WordPress Test Environment
run: npm run env:start:test
Expand Down
Loading