Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true

# Two-space indent for config and data files.
[*.{yml,yaml,json,md}]
[*.{yml,yaml,md}]
indent_size = 2
indent_style = space

Expand Down
6 changes: 4 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ npm run wp-env start

## Before you open a PR

Run all four checks locally — all of them must exit `0`:
Run all five checks locally — all of them must exit `0`:

```bash
composer lint
composer analyse
npm run lint:js
npm run format:check
npm run test:php
```

Expand All @@ -37,6 +38,7 @@ composer lint # PHPCS against the rtCampWP standard (rtcamp/wp-phpcs)
composer lint:fix # auto-fix fixable violations
composer analyse # PHPStan static analysis
npm run lint:js # ESLint (@rtcamp/eslint-config) on bin/
npm run format
npm run test:php # PHPUnit in the wp-env test container
```

Expand All @@ -46,7 +48,7 @@ Follow TDD: add a failing test under `tests/phpunit/Integration/` (which mirrors

## Pull request checklist

- [ ] `composer lint`, `composer analyse`, `npm run lint:js`, and `npm run test:php` pass.
- [ ] `composer lint`, `composer analyse`, `npm run lint:js`, `npm run format:check`, and `npm run test:php` pass.
- [ ] New/changed behavior is covered by tests.
- [ ] Any change to `inc/Contracts/` is flagged as breaking in the PR description.
- [ ] Contract changes are reflected in `ai/primitives-php.instructions.md`.
Expand Down
108 changes: 17 additions & 91 deletions .github/workflows/test-measure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,108 +8,34 @@ on:
types:
- opened
- synchronize
- reopened
- ready_for_review

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
lint-php:
name: 'Lint PHP'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Setup PHP
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2.40.0
with:
php-version: '8.2'
coverage: none
tools: cs2pr

- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Configure Composer cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --prefer-dist --optimize-autoloader --no-progress --no-interaction

- name: Validate composer.json
run: composer --no-interaction validate --no-check-all

- name: Detect coding standard violations (PHPCS)
run: vendor/bin/phpcs -q --report=checkstyle --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 | cs2pr --graceful-warnings

analyse-php:
name: 'PHPStan Analysis'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Setup PHP
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2.40.0
with:
php-version: '8.2'
coverage: none

- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Configure Composer cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --prefer-dist --optimize-autoloader --no-progress --no-interaction

- name: Run PHPStan
run: composer analyse
name: Lint PHP
uses: rtCamp/wp-shared-workflows/.github/workflows/ci-lint-php.yml@6a4d945cc07377a6ce02ae4831a9817fe629d5b1 # v1.1.1
with:
php-version: '8.2'
enable-phpstan: true
phpstan-command: composer analyse

lint-js:
name: 'Lint JS'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Setup Node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Install Node dependencies
run: npm ci
env:
CI: true

- name: Run ESLint
run: npm run lint:js
name: Lint JS and check formatting
uses: rtCamp/wp-shared-workflows/.github/workflows/ci-lint-js.yml@6a4d945cc07377a6ce02ae4831a9817fe629d5b1 # v1.1.1
with:
lint-command: >-
status=0;
npm run lint:js || status=1;
npm run format:check || status=1;
exit $status

unit-test-php:
name: 'PHP ${{ matrix.php }} / WP ${{ matrix.wp }}'
Expand Down
3 changes: 2 additions & 1 deletion docs/maintainers.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Run these before opening a pull request:
composer lint
composer analyse
npm run lint:js
npm run format:check
npm run test:php
```

Expand Down Expand Up @@ -58,7 +59,7 @@ npm run wp-env stop
- Add reusable test-only classes under `tests/phpunit/Tests/Fixtures/`.
- Keep tests order-independent; PHPUnit runs them in random order.

CI runs PHPCS, PHPStan, ESLint, and a PHP × WordPress integration-test matrix. The local commands above are the closest single-environment equivalent.
CI runs PHPCS, PHPStan, ESLint, a Prettier formatting check, and a PHP × WordPress integration-test matrix. The local commands above are the closest single-environment equivalent.

## Changing the library

Expand Down
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"scripts": {
"format": "wp-scripts format . '**/*.md'",
"format:check": "prettier --check --ignore-path .prettierignore '**/*.{cjs,cts,js,json,jsx,mjs,mts,ts,tsx,yml,yaml,md}'",
"lint:js": "wp-scripts lint-js",
"lint:js:fix": "wp-scripts lint-js --fix",
"lint:php": "composer run-script lint",
Expand All @@ -23,7 +24,8 @@
"@rtcamp/eslint-config": "2.0.0",
"@wordpress/env": "12.2.0",
"@wordpress/prettier-config": "5.2.0",
"@wordpress/scripts": "37.2.0"
"@wordpress/scripts": "37.2.0",
"prettier": "npm:wp-prettier@3.9.6"
},
"overrides": {
"@wp-playground/storage": {
Expand All @@ -32,6 +34,6 @@
"express": {
"qs": "6.16.2"
},
"prettier": "npm:wp-prettier@^3"
"prettier": "$prettier"
}
}
Loading