You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4a4639f
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: AGENTS.md
+23-2Lines changed: 23 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
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.
4
4
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
+
5
7
## Best Practices for Code Contributions
6
8
7
9
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:
13
15
14
16
### Building and running
15
17
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
+
```
17
37
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.
19
39
20
40
### Useful Composer Commands
21
41
@@ -24,6 +44,7 @@ The project uses Composer to manage dependencies and run scripts. The following
24
44
*`composer install`: Install dependencies.
25
45
*`composer test`: Run the full test suite, including linting, code style checks, static analysis, and unit/behavior tests.
26
46
*`composer lint`: Check for syntax errors.
47
+
*`composer lint-gherkin`: Check the Behat feature files for style violations.
27
48
*`composer phpcs`: Check for code style violations.
Runs `mysqldump` utility using `DB_HOST`, `DB_NAME`, `DB_USER` and
440
-
`DB_PASSWORD` database credentials specified in wp-config.php. Accepts any valid `mysqldump` flags.
447
+
`DB_PASSWORD` database credentials specified in wp-config.php. Accepts any valid [`mysqldump` flags](https://dev.mysql.com/doc/en/mysqldump.html#mysqldump-option-summary).
441
448
442
449
**OPTIONS**
443
450
@@ -523,7 +530,7 @@ Runs `mysqldump` utility using `DB_HOST`, `DB_NAME`, `DB_USER` and
523
530
Imports a database from a file or from STDIN.
524
531
525
532
~~~
526
-
wp db import [<file>] [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>] [--skip-optimization] [--defaults]
533
+
wp db import [<file>] [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>] [--skip-optimization] [--skip-sql-mode-compat] [--defaults]
527
534
~~~
528
535
529
536
Runs SQL queries using `DB_HOST`, `DB_NAME`, `DB_USER` and
@@ -546,7 +553,10 @@ defined in the SQL.
546
553
Extra arguments to pass to mysql. [Refer to mysql binary docs](https://dev.mysql.com/doc/refman/8.0/en/mysql-command-options.html).
547
554
548
555
[--skip-optimization]
549
-
When using an SQL file, do not include speed optimization such as disabling auto-commit and key checks.
556
+
Do not disable unique checks and foreign key checks during import.
557
+
558
+
[--skip-sql-mode-compat]
559
+
Do not adapt the session SQL mode for WordPress compatibility. By default, `wp db import` strips the SQL modes that WordPress Core disables (such as `STRICT_TRANS_TABLES` and `NO_ZERO_DATE`) so that dumps containing legacy values like `0000-00-00` import cleanly. Pass this flag to import under the server's own SQL modes instead.
550
560
551
561
[--defaults]
552
562
Loads the environment's MySQL option files. Default behavior is to skip loading them to avoid failures due to misconfiguration.
@@ -1038,7 +1048,7 @@ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file
1038
1048
1039
1049
## Support
1040
1050
1041
-
GitHub issues aren't for general support questions, but there are other venues you can try: https://wp-cli.org/#support
1051
+
GitHub issues aren't for general support questions. For support resources and next steps, see the WP-CLI Support page: https://make.wordpress.org/cli/handbook/support/
1042
1052
1043
1053
1044
1054
*This README.md is generated dynamically from the project's codebase using `wp scaffold package-readme` ([doc](https://github.com/wp-cli/scaffold-package-command#wp-scaffold-package-readme)). To suggest changes, please submit a pull request against the corresponding part of the codebase.*
0 commit comments