Skip to content

Commit bf6157a

Browse files
authored
Merge branch 'main' into claude/wp-cli-package-composer-guidance-rve6ct
2 parents 80f8b69 + cd6a6ed commit bf6157a

13 files changed

Lines changed: 630 additions & 327 deletions

.github/actionlint.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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"'

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ updates:
99
- scope:distribution
1010
cooldown:
1111
default-days: 7
12+
# Only wp-cli-tests carries a package.json, holding the pinned version of the
13+
# Gherkin linter. This is a no-op in every other repository.
14+
- package-ecosystem: npm
15+
directory: "/"
16+
schedule:
17+
interval: daily
18+
open-pull-requests-limit: 10
19+
labels:
20+
- scope:distribution
21+
cooldown:
22+
default-days: 7
1223
- package-ecosystem: github-actions
1324
directory: "/"
1425
schedule:

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

Lines changed: 35 additions & 0 deletions
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
@@ -45,3 +55,28 @@ jobs:
4555
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
4656
env:
4757
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
58+
59+
# Without a database the Behat runner silently falls back to SQLite, so the
60+
# agent's test runs are not the ones CI will do. Mirrors the setup in
61+
# reusable-functional.yml.
62+
- name: Check existence of behat.yml file
63+
id: check_behat_file
64+
run: echo "files_exists=$(test -f behat.yml && echo true || echo false)" >> "$GITHUB_OUTPUT"
65+
66+
- name: Setup MySQL Server
67+
if: steps.check_behat_file.outputs.files_exists == 'true'
68+
uses: shogo82148/actions-setup-mysql@62da9377d83991fce27b6ed2a397d3306121e41d # v1
69+
with:
70+
mysql-version: '8.0' # Standard MySQL version for these tests
71+
auto-start: true
72+
root-password: ${{ env.WP_CLI_TEST_DBROOTPASS }}
73+
user: ${{ env.WP_CLI_TEST_DBUSER }}
74+
password: ${{ env.WP_CLI_TEST_DBPASS }}
75+
76+
- name: Remove system MySQL binary
77+
if: steps.check_behat_file.outputs.files_exists == 'true'
78+
run: sudo rm -f /usr/bin/mysql /usr/bin/mysqldump
79+
80+
- name: Prepare test database
81+
if: steps.check_behat_file.outputs.files_exists == 'true'
82+
run: composer prepare-tests

.github/workflows/deployment.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ jobs:
113113
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
114114

115115
- name: Install Ghostscript
116+
timeout-minutes: 10
116117
run: |
117118
sudo apt-get update
118119
sudo apt-get install ghostscript -y
@@ -152,7 +153,7 @@ jobs:
152153
153154
- name: Setup MySQL Server
154155
id: setup-mysql
155-
uses: shogo82148/actions-setup-mysql@3dcedf762c5e82d781a9e414462785b30208e79c # v1
156+
uses: shogo82148/actions-setup-mysql@62da9377d83991fce27b6ed2a397d3306121e41d # v1
156157
with:
157158
mysql-version: ${{ matrix.mysql }}
158159
auto-start: true

.github/workflows/issue-triage.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ permissions:
1717
issues: write
1818
pull-requests: write
1919
contents: read
20-
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
2124
# A caller can only cap a reusable workflow's permissions, never raise them,
2225
# so `actions: write` has to be granted here for the dispatch job downstream
2326
# to work at all. The reusable workflow narrows it to that single job, so the

AGENTS.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,27 @@ When contributing to this package, please adhere to the following guidelines:
1313

1414
### Building and running
1515

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`.
16+
Run the narrowest check that covers your change:
1717

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.
18+
| You changed | Run |
19+
| --- | --- |
20+
| Any PHP file | `composer phpcs -- <file>` and `composer phpstan` |
21+
| Logic with unit test coverage | `composer phpunit -- --filter <TestName>` |
22+
| One feature file | `composer behat -- features/<name>.feature` |
23+
| One scenario | `composer behat -- features/<name>.feature:<line>` |
24+
25+
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.
26+
27+
`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.
28+
29+
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:
30+
31+
```bash
32+
export NO_COLOR=1
33+
export WP_CLI_TEST_QUIET=1
34+
```
35+
36+
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.
1937

2038
### Useful Composer Commands
2139

@@ -24,6 +42,7 @@ The project uses Composer to manage dependencies and run scripts. The following
2442
* `composer install`: Install dependencies.
2543
* `composer test`: Run the full test suite, including linting, code style checks, static analysis, and unit/behavior tests.
2644
* `composer lint`: Check for syntax errors.
45+
* `composer lint-gherkin`: Check the Behat feature files for style violations.
2746
* `composer phpcs`: Check for code style violations.
2847
* `composer phpcbf`: Automatically fix code style violations.
2948
* `composer phpstan`: Run static analysis.

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
"behat": "run-behat-tests",
8181
"behat-rerun": "rerun-behat-tests",
8282
"lint": "run-linter-tests",
83+
"lint-gherkin": "run-gherkin-lint-tests",
8384
"phpcs": "run-phpcs-tests",
8485
"phpstan": "run-phpstan-tests",
8586
"phpunit": "run-php-unit-tests",
@@ -88,6 +89,7 @@
8889
"prepare-tests": "install-package-tests",
8990
"test": [
9091
"@lint",
92+
"@lint-gherkin",
9193
"@phpcs",
9294
"@phpstan",
9395
"@phpunit",

0 commit comments

Comments
 (0)