Skip to content

Commit fdfae59

Browse files
swissspidyclaude
andcommitted
Merge branch 'main' into exclude_revisions
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UWTd5pwpi2xQfDA6mUYkkx
2 parents 0ff712a + 89547e0 commit fdfae59

22 files changed

Lines changed: 1492 additions & 610 deletions

‎.github/actionlint.yml‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Configuration for actionlint, run by the `actionlint` job in
2+
# `.github/workflows/reusable-code-quality.yml`.
3+
paths:
4+
.github/workflows/**/*.{yml,yaml}:
5+
ignore:
6+
# `copilot-requests` is a real permission scope - it is what lets a
7+
# workflow authenticate the Copilot CLI with the built-in `GITHUB_TOKEN`
8+
# instead of a personal access token - but actionlint's hard-coded scope
9+
# list has not caught up with it yet, so it reports every use as unknown.
10+
# Drop this entry once actionlint ships the scope, and it will go back to
11+
# catching genuine typos in permission names.
12+
# See https://docs.github.com/en/copilot/how-tos/copilot-cli/use-copilot-cli-in-actions
13+
- '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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,29 @@ updates:
77
open-pull-requests-limit: 10
88
labels:
99
- 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
18+
directory: "/"
19+
schedule:
20+
interval: daily
21+
open-pull-requests-limit: 10
22+
labels:
23+
- scope:distribution
24+
cooldown:
25+
default-days: 7
1026
- package-ecosystem: github-actions
1127
directory: "/"
1228
schedule:
1329
interval: daily
1430
open-pull-requests-limit: 10
1531
labels:
1632
- scope:distribution
33+
cooldown:
34+
default-days: 7
1735

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

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,60 @@ on:
99
paths:
1010
- .github/workflows/copilot-setup-steps.yml
1111

12+
permissions:
13+
contents: read
14+
1215
jobs:
1316
copilot-setup-steps:
17+
name: Setup environment
1418
runs-on: ubuntu-latest
1519
permissions:
1620
contents: read
1721

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+
1832
steps:
1933
- name: Checkout code
20-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
34+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
35+
with:
36+
persist-credentials: false
2137

2238
- name: Check existence of composer.json file
2339
id: check_composer_file
2440
run: echo "files_exists=$(test -f composer.json && echo true || echo false)" >> "$GITHUB_OUTPUT"
2541

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+
2663
- name: Set up PHP environment
2764
if: steps.check_composer_file.outputs.files_exists == 'true'
28-
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
65+
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2
2966
with:
3067
php-version: 'latest'
3168
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
@@ -36,9 +73,14 @@ jobs:
3673

3774
- name: Install Composer dependencies & cache dependencies
3875
if: steps.check_composer_file.outputs.files_exists == 'true'
39-
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # v3
76+
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
4077
env:
4178
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
42-
with:
43-
# Bust the cache at least once a month - output format: YYYY-MM.
44-
custom-cache-suffix: $(date -u "+%Y-%m")
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

‎.github/workflows/issue-triage.yml‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,17 @@ name: Issue and PR Triage
1616
permissions:
1717
issues: write
1818
pull-requests: write
19-
actions: write
2019
contents: read
21-
models: read
20+
# A caller can only cap a reusable workflow's permissions, so the scope the
21+
# Copilot CLI needs has to be granted here too. `models: read` was for the
22+
# GitHub Models provider, which `actions/ai-inference` v3 removed.
23+
copilot-requests: write
24+
# A caller can only cap a reusable workflow's permissions, never raise them,
25+
# so `actions: write` has to be granted here for the dispatch job downstream
26+
# to work at all. The reusable workflow narrows it to that single job, so the
27+
# `pull_request_target` job does not receive it. Removing it here breaks
28+
# dispatching (see #271/#272); narrow it there instead.
29+
actions: write
2230

2331
jobs:
2432
issue-triage:
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.

0 commit comments

Comments
 (0)