Skip to content

Commit 57736ea

Browse files
committed
Update file(s) from wp-cli/.github
1 parent 36353d0 commit 57736ea

2 files changed

Lines changed: 56 additions & 2 deletions

File tree

.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

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.

0 commit comments

Comments
 (0)