Skip to content

Commit a5e7e5b

Browse files
swissspidyclaude
andcommitted
Merge branch 'main' into claude/wordpress-7-1-test-failures-u577i4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UWTd5pwpi2xQfDA6mUYkkx
2 parents b890ae0 + 9a5eaf6 commit a5e7e5b

15 files changed

Lines changed: 437 additions & 91 deletions

‎.github/actionlint.yml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,12 @@ paths:
1111
# catching genuine typos in permission names.
1212
# See https://docs.github.com/en/copilot/how-tos/copilot-cli/use-copilot-cli-in-actions
1313
- 'unknown permission scope "copilot-requests"'
14+
# Steps can run in parallel through the `background`, `wait`, `wait-all`,
15+
# `cancel` and `parallel` keywords, but actionlint does not know them yet:
16+
# it rejects `background` as an unexpected key, and a `wait-all` or
17+
# `parallel` step as one that has neither `run` nor `uses`. Drop these
18+
# entries once actionlint supports the keywords. Until then, a step that is
19+
# genuinely missing both `run` and `uses` is no longer reported.
20+
# See https://docs.github.com/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsparallel
21+
- 'unexpected key "background" for step'
22+
- 'step must run script with "run" section or run action with "uses" section'

‎.github/dependabot.yml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
version: 2
22
updates:
33
- package-ecosystem: composer
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
open-pull-requests-limit: 10
8+
labels:
9+
- scope:distribution
10+
cooldown:
11+
default-days: 7
12+
# Packages from our own org are trusted, so they are updated immediately.
13+
exclude:
14+
- "wp-cli/*"
15+
# Only wp-cli-tests carries a package.json, holding the pinned version of the
16+
# Gherkin linter. This is a no-op in every other repository.
17+
- package-ecosystem: npm
418
directory: "/"
519
schedule:
620
interval: daily

‎.github/workflows/copilot-setup-steps.yml‎

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ jobs:
1919
permissions:
2020
contents: read
2121

22+
env:
23+
MYSQL_HOST: 127.0.0.1
24+
MYSQL_TCP_PORT: 3306
25+
WP_CLI_TEST_DBROOTUSER: root
26+
WP_CLI_TEST_DBROOTPASS: root
27+
WP_CLI_TEST_DBNAME: wp_cli_test
28+
WP_CLI_TEST_DBUSER: wp_cli_test
29+
WP_CLI_TEST_DBPASS: password1
30+
WP_CLI_TEST_DBHOST: 127.0.0.1:3306
31+
2232
steps:
2333
- name: Checkout code
2434
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -29,9 +39,30 @@ jobs:
2939
id: check_composer_file
3040
run: echo "files_exists=$(test -f composer.json && echo true || echo false)" >> "$GITHUB_OUTPUT"
3141

42+
# Without a database the Behat runner silently falls back to SQLite, so the
43+
# agent's test runs are not the ones CI will do. Mirrors the setup in
44+
# reusable-functional.yml.
45+
- name: Check existence of behat.yml file
46+
id: check_behat_file
47+
run: echo "files_exists=$(test -f behat.yml && echo true || echo false)" >> "$GITHUB_OUTPUT"
48+
49+
# Not run in the background: Copilot code review builds its workflow from
50+
# these steps and failed validation while they used `background` and
51+
# `wait-all`. Also, the action unpacks its binaries with the system `tar`,
52+
# which fails to load libpcre2 while setup-php upgrades it with apt.
53+
- name: Setup MySQL Server
54+
if: steps.check_behat_file.outputs.files_exists == 'true'
55+
uses: shogo82148/actions-setup-mysql@13a38f2af408e58a0c80168fc620a63a15357339 # v1
56+
with:
57+
mysql-version: '8.0' # Standard MySQL version for these tests
58+
auto-start: true
59+
root-password: ${{ env.WP_CLI_TEST_DBROOTPASS }}
60+
user: ${{ env.WP_CLI_TEST_DBUSER }}
61+
password: ${{ env.WP_CLI_TEST_DBPASS }}
62+
3263
- name: Set up PHP environment
3364
if: steps.check_composer_file.outputs.files_exists == 'true'
34-
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
65+
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2
3566
with:
3667
php-version: 'latest'
3768
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
@@ -45,3 +76,11 @@ jobs:
4576
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
4677
env:
4778
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
79+
80+
- name: Remove system MySQL binary
81+
if: steps.check_behat_file.outputs.files_exists == 'true'
82+
run: sudo rm -f /usr/bin/mysql /usr/bin/mysqldump
83+
84+
- name: Prepare test database
85+
if: steps.check_behat_file.outputs.files_exists == 'true'
86+
run: composer prepare-tests
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Milestone Merged Pull Requests
3+
4+
'on':
5+
pull_request_target:
6+
types: [closed]
7+
branches:
8+
- main
9+
- master
10+
11+
permissions:
12+
issues: write
13+
pull-requests: write
14+
15+
jobs:
16+
milestone:
17+
uses: wp-cli/.github/.github/workflows/reusable-milestone-merged-prs.yml@main

‎AGENTS.md‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
This package is part of WP-CLI, the official command line interface for WordPress. For a detailed explanation of the project structure and development workflow, please refer to the main @README.md file.
44

5+
If the repository contains an @AGENTS.local.md file, read it as well. It holds instructions specific to this repository and takes precedence over this file where the two disagree.
6+
57
## Best Practices for Code Contributions
68

79
When contributing to this package, please adhere to the following guidelines:
@@ -13,9 +15,27 @@ When contributing to this package, please adhere to the following guidelines:
1315

1416
### Building and running
1517

16-
Before submitting any changes, it is crucial to validate them by running the full suite of static code analysis and tests. To run the full suite of checks, execute the following command: `composer test`.
18+
Run the narrowest check that covers your change:
19+
20+
| You changed | Run |
21+
| --- | --- |
22+
| Any PHP file | `composer phpcs -- <file>` and `composer phpstan` |
23+
| Logic with unit test coverage | `composer phpunit -- --filter <TestName>` |
24+
| One feature file | `composer behat -- features/<name>.feature` |
25+
| One scenario | `composer behat -- features/<name>.feature:<line>` |
26+
27+
After a failure, `composer behat-rerun` re-runs only the scenarios that failed, and `composer behat -- --stop-on-failure` bails out at the first one instead of working through the rest.
28+
29+
`composer test` runs every suite, the whole Behat suite included. In most packages that means installing WordPress from scratch once per scenario, which takes tens of minutes and needs `jq`, a MySQL or MariaDB client with a prepared test database, and network access to WordPress.org. Run it before opening a pull request when you have touched something cross-cutting. Do not run it to check a two-line change.
30+
31+
Set these first, so the tools report problems compactly instead of drawing progress bars and ANSI color into output you are going to read back:
32+
33+
```bash
34+
export NO_COLOR=1
35+
export WP_CLI_TEST_QUIET=1
36+
```
1737

18-
This single command ensures that your changes meet all the quality gates of the project. While you can run the individual steps separately, it is highly recommended to use this single command to ensure a comprehensive validation.
38+
Note that a green `composer test` is not the same as a green CI. `actionlint` and `typos` also run on every pull request and are not part of it.
1939

2040
### Useful Composer Commands
2141

@@ -24,6 +44,7 @@ The project uses Composer to manage dependencies and run scripts. The following
2444
* `composer install`: Install dependencies.
2545
* `composer test`: Run the full test suite, including linting, code style checks, static analysis, and unit/behavior tests.
2646
* `composer lint`: Check for syntax errors.
47+
* `composer lint-gherkin`: Check the Behat feature files for style violations.
2748
* `composer phpcs`: Check for code style violations.
2849
* `composer phpcbf`: Automatically fix code style violations.
2950
* `composer phpstan`: Run static analysis.

‎composer.json‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"wp-cli/db-command": "^1.3 || ^2 || ^3",
2121
"wp-cli/entity-command": "^1.3 || ^2 || ^3",
2222
"wp-cli/extension-command": "^1.2 || ^2 || ^3",
23-
"wp-cli/wp-cli-tests": "^5"
23+
"wp-cli/wp-cli-tests": "^5.4.0"
2424
},
2525
"config": {
2626
"process-timeout": 7200,
@@ -65,15 +65,17 @@
6565
"behat": "run-behat-tests",
6666
"behat-rerun": "rerun-behat-tests",
6767
"lint": "run-linter-tests",
68+
"lint-gherkin": "run-gherkin-lint-tests",
6869
"phpcs": "run-phpcs-tests",
6970
"phpstan": "run-phpstan-tests",
7071
"phpcbf": "run-phpcbf-cleanup",
7172
"phpunit": "run-php-unit-tests",
7273
"prepare-tests": "install-package-tests",
7374
"test": [
7475
"@lint",
76+
"@lint-gherkin",
7577
"@phpcs",
76-
"@phstan",
78+
"@phpstan",
7779
"@phpunit",
7880
"@behat"
7981
]

‎features/core-check-update-db.feature‎

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@ Feature: Check if WordPress database update is needed
77
And a disable_sidebar_check.php file:
88
"""
99
<?php
10-
WP_CLI::add_wp_hook( 'init', static function () {
11-
remove_action( 'after_switch_theme', '_wp_sidebars_changed' );
12-
} );
10+
WP_CLI::add_wp_hook(
11+
'init',
12+
static function () {
13+
remove_action( 'after_switch_theme', '_wp_sidebars_changed' );
14+
}
15+
);
16+
"""
17+
And these installed and active themes:
18+
"""
19+
twentytwenty
1320
"""
14-
And I try `wp theme install twentytwenty --activate`
1521
And I run `wp core download --version=5.4 --force`
1622
And I run `wp option update db_version 45805 --require=disable_sidebar_check.php`
1723

@@ -49,11 +55,17 @@ Feature: Check if WordPress database update is needed
4955
And a disable_sidebar_check.php file:
5056
"""
5157
<?php
52-
WP_CLI::add_wp_hook( 'init', static function () {
53-
remove_action( 'after_switch_theme', '_wp_sidebars_changed' );
54-
} );
58+
WP_CLI::add_wp_hook(
59+
'init',
60+
static function () {
61+
remove_action( 'after_switch_theme', '_wp_sidebars_changed' );
62+
}
63+
);
64+
"""
65+
And these installed and active themes:
66+
"""
67+
twentytwenty
5568
"""
56-
And I try `wp theme install twentytwenty --activate`
5769
And I run `wp core download --version=6.6 --force`
5870
And I run `wp option update db_version 57155 --require=disable_sidebar_check.php`
5971
And I run `wp site option update wpmu_upgrade_site 57155`

‎features/core-check-update.feature‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ Feature: Check for more recent versions
44
@require-mysql
55
Scenario: Check for update via Version Check API
66
Given a WP install
7-
And I try `wp theme install twentytwenty --activate`
7+
And these installed and active themes:
8+
"""
9+
twentytwenty
10+
"""
811
# The Version Check API only offers in-branch (minor) updates to a subset of
912
# sites, bucketed by the site URL, so the response is mocked to stay stable.
1013
And that HTTP requests to https://api.wordpress.org/core/version-check/1.7/ will respond with:
@@ -65,7 +68,7 @@ Feature: Check for more recent versions
6568
<?php
6669
global $wp_version;
6770
68-
$obj = new stdClass;
71+
$obj = new stdClass();
6972
$obj->updates = [];
7073
$obj->last_checked = strtotime( '1 January 2099' );
7174
$obj->version_checked = $wp_version;

‎features/core-download.feature‎

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,11 +523,111 @@ Feature: Download WordPress
523523

524524
Scenario: Core download with no-extract should not unzip the download file
525525
Given an empty directory
526+
And an empty cache
526527

527528
When I run `wp core download --version=4.5 --locale=de_DE --no-extract`
528529
Then the wp-content directory should not exist
529530
And the wordpress-4.5-de_DE.zip file should exist
530531

532+
Scenario: Core download with no-extract reports when the archive cannot be saved
533+
Given an empty directory
534+
And an empty cache
535+
And a wordpress-4.5-de_DE.zip/placeholder.txt file:
536+
"""
537+
A directory in the way of the archive.
538+
"""
539+
540+
When I try `wp core download --version=4.5 --locale=de_DE --no-extract`
541+
Then STDERR should contain:
542+
"""
543+
Error: Couldn't copy WordPress archive to
544+
"""
545+
And the return code should be 1
546+
547+
When I run `wp core download --version=4.5 --locale=de_DE --no-extract --path=other`
548+
And I try `wp core download --version=4.5 --locale=de_DE --no-extract`
549+
Then STDERR should contain:
550+
"""
551+
Error: Couldn't copy WordPress archive to
552+
"""
553+
And the return code should be 1
554+
555+
Scenario: Core download with no-extract does not name an archive after its URL
556+
Given an empty directory
557+
And that HTTP requests to http://example.com/payload.php.md5 will respond with:
558+
"""
559+
HTTP/1.1 200 OK
560+
Content-Type: text/plain
561+
562+
3c58c7ed6e95bcf8fadbadc3cc2ca52b
563+
"""
564+
And that HTTP requests to http://example.com/payload.php will respond with:
565+
"""
566+
HTTP/1.1 200 OK
567+
Content-Type: application/octet-stream
568+
569+
PK This only needs to look like a zip archive.
570+
"""
571+
572+
# The mocked responses make the HTTP library emit warnings, so STDERR is not checked.
573+
When I try `wp core download http://example.com/payload.php --no-extract`
574+
Then STDOUT should contain:
575+
"""
576+
Success: WordPress downloaded.
577+
"""
578+
And the return code should be 0
579+
And the payload.php file should not exist
580+
And the {RUN_DIR} directory should contain:
581+
"""
582+
.zip
583+
"""
584+
585+
@skip-windows
586+
Scenario: Core download with no-extract replaces a symlink at the archive path instead of writing through it
587+
Given an empty directory
588+
And an empty cache
589+
And a victim.txt file:
590+
"""
591+
Not an archive.
592+
"""
593+
594+
When I run `ln -s victim.txt wordpress-4.5-de_DE.zip`
595+
And I run `wp core download --version=4.5 --locale=de_DE --no-extract`
596+
Then the victim.txt file should be:
597+
"""
598+
Not an archive.
599+
"""
600+
And the wordpress-4.5-de_DE.zip file should exist
601+
602+
When I run `rm wordpress-4.5-de_DE.zip`
603+
And I run `ln -s victim.txt wordpress-4.5-de_DE.zip`
604+
And I run `wp core download --version=4.5 --locale=de_DE --no-extract`
605+
Then STDOUT should contain:
606+
"""
607+
Using cached file
608+
"""
609+
And the victim.txt file should be:
610+
"""
611+
Not an archive.
612+
"""
613+
614+
@skip-windows
615+
Scenario: Core download with no-extract keeps the permissions of an archive it replaces
616+
Given an empty directory
617+
And an empty cache
618+
And a wordpress-4.5-de_DE.zip file:
619+
"""
620+
An older copy of the archive.
621+
"""
622+
623+
When I run `chmod 600 wordpress-4.5-de_DE.zip`
624+
And I run `wp core download --version=4.5 --locale=de_DE --no-extract`
625+
And I run `php -r 'printf( "%o", fileperms( "wordpress-4.5-de_DE.zip" ) & 0777 );'`
626+
Then STDOUT should be:
627+
"""
628+
600
629+
"""
630+
531631
Scenario: Core download with no-extract should not unzip the download file (already cached)
532632
Given an empty directory
533633

0 commit comments

Comments
 (0)