Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
e813f1f
Add phpstan
kasparsd Dec 13, 2025
0453a68
Add CI for linting
kasparsd Dec 13, 2025
973dad1
We actually need the lock file for proper versioning of dev tooling
kasparsd Dec 13, 2025
4434d81
Per linter
kasparsd Dec 13, 2025
84bae2c
Define known versions for min supported PHP 7.4
kasparsd Dec 13, 2025
7d71a4c
This already happens
kasparsd Dec 13, 2025
ea39b52
Sync min required
kasparsd Dec 13, 2025
56c4257
Use the existing file
kasparsd Dec 13, 2025
f9a63e6
Keep the name
kasparsd Dec 13, 2025
17be316
Relax for Composer
kasparsd Dec 13, 2025
73ff5f2
Lock at versions supported by min supported PHP
kasparsd Dec 13, 2025
659b45c
Add the vendor
kasparsd Dec 13, 2025
0e6e99b
Make it work with 7.4 by default
kasparsd Dec 13, 2025
1df217a
Use wp-env for tests across the board
kasparsd Dec 13, 2025
86188e0
Use the same shared dev env for running PHP stuff
kasparsd Dec 13, 2025
a89ad87
Add a reusable npm run cli command to avoid repetition
kasparsd Dec 13, 2025
018fa64
Test against latest versions of WP core
kasparsd Dec 13, 2025
e77ce8c
Add coverage reporting too
kasparsd Dec 13, 2025
bfc7cbb
Install deps
kasparsd Dec 13, 2025
8972210
Ignore the warning for now
kasparsd Dec 13, 2025
c7ea8aa
Use the correct reporting script
kasparsd Dec 13, 2025
3d9ed6f
Use a reliable helper instead of constants
kasparsd Dec 13, 2025
74ab311
Always return a string
kasparsd Dec 13, 2025
5428afd
Bump limits
kasparsd Dec 13, 2025
7dfef25
To ensure we have all symbols for phpstan
kasparsd Dec 13, 2025
9c79f61
This already happens during add_key_rewrite_rule()
kasparsd Dec 13, 2025
0ca9906
Doesn’t accept any arguments
kasparsd Dec 13, 2025
14dfea2
Shoudn’t return during an action
kasparsd Dec 13, 2025
27b0527
Exclude phpunit caches
kasparsd Dec 13, 2025
0ba67d0
Per linter
kasparsd Dec 13, 2025
a3d8e04
Per linter
kasparsd Dec 13, 2025
86c753e
Colocate all phpunit configs
kasparsd Dec 13, 2025
b37e49d
Cache between runs
kasparsd Dec 13, 2025
820ae51
Also during phpcs and phpstan checks
kasparsd Dec 13, 2025
c4503f0
Cache in a known location
kasparsd Dec 13, 2025
095f1d2
Lock to known PHP 7.4 versions
kasparsd Dec 13, 2025
95958bc
Add baseline generation
kasparsd Dec 13, 2025
f374948
Use matrix generator for easier management
kasparsd Dec 13, 2025
6bb8820
Use a name
kasparsd Dec 13, 2025
b1202cf
Install phpunit matching PHP and WP combo
kasparsd Dec 13, 2025
0991f81
Redundant spaces
kasparsd Dec 13, 2025
5a78246
Better formatting
kasparsd Dec 13, 2025
d9e7602
Not used
kasparsd Dec 13, 2025
5f6fb22
No need to escape it
kasparsd Dec 13, 2025
747b831
Exclude caches too
kasparsd Dec 13, 2025
ed2fdfa
Skip installing optional plugins during phpunit runs
kasparsd Dec 13, 2025
a121561
Document development tooling
kasparsd Dec 13, 2025
6af73c3
Add schema
kasparsd Dec 13, 2025
07c3560
Ignore the wp-env override
kasparsd Dec 13, 2025
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
1 change: 1 addition & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ tests/
phpunit.xml.dist
wp-tests-config-sample.php
phpcs.xml.dist
phpstan.dist.neon
composer.json
composer.lock
package.json
Expand Down
71 changes: 30 additions & 41 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,59 +5,48 @@ on:
branches:
- main
pull_request:

branches:
- main
workflow_dispatch:

# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

# Disable permissions for all available scopes by default.
# Any needed permissions should be configured at the job level.
permissions: {}
permissions:
contents: read

jobs:
# Runs the PHP coding standards checks.
#
# Violations are reported inline with annotations.
#
# Performs the following steps:
# - Checks out the repository.
# - Sets up PHP.
# - Installs Composer dependencies.
# - Make Composer packages available globally.
# - Runs PHPCS on the full codebase (warnings excluded).
# - Ensures version-controlled files are not modified or deleted.
phpcs:
name: Run coding standards checks
lint:
name: Lint PHP
runs-on: ubuntu-latest
permissions:
contents: read
timeout-minutes: 20

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v6

- name: Setup cache
uses: actions/cache@v5
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
key: ${{ runner.os }}-${{ hashFiles('composer.json') }} # Note that lock file will change between runs.
path: |
.cache

- name: Set up PHP
uses: shivammathur/setup-php@cf4cade2721270509d5b1c766ab3549210a39a2a # v2.33.0
- name: Setup Node
uses: actions/setup-node@v4
with:
coverage: none
cache: 'npm'
node-version: '18'

- name: Install dependencies
run: npm install

- name: Start the development environment
run: npm run env start

- name: Install Composer dependencies
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # v3.1.1
run: npm run test:php:install-deps

- name: Make Composer packages available globally
run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH
- name: Lint PHPCS
# TODO: Remove the flag once all warnings are fixed.
run: npm run lint:php:phpcs -- -- -- --warning-severity=0

- name: Run PHPCS on all files
id: phpcs-files
run: phpcs . -n --report-full
- name: Run PHPStan
run: npm run lint:php:phpstan

- name: Ensure version-controlled files are not modified during the checks
run: git diff --exit-code
221 changes: 86 additions & 135 deletions .github/workflows/phpunit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,155 +20,106 @@ permissions:
contents: read

jobs:
# Runs the PHPUnit tests for FAIR.
#
# Performs the following steps:
# - Checks out the repository.
# - Sets up PHP.
# - Installs Composer dependencies.
# - Installs SVN.
# - Installs the test suite.
# - Runs the PHPUnit tests.
# - Ensures version-controlled files are not modified.
generate-matrix:
name: Generate PHP and WP version testing matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
steps:
- uses: actions/checkout@v6
- name: Generate PHP and WP testing matrix
id: generate
run: echo "matrix=$(node ./bin/github-actions-matrix.js)" >> "$GITHUB_OUTPUT"

phpunit:
name: Run tests (WP ${{ matrix.wp-version }}, PHP ${{ matrix.php-version }})
runs-on: ubuntu-latest
needs: generate-matrix
env:
WP_ENV_PHP_VERSION: ${{ matrix.php-version }}
WP_ENV_CORE: ${{ matrix.wp-version == 'trunk' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', matrix.wp-version ) }}
strategy:
matrix:
php-version: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]
wp-version: [ '5.4', '5.5', '5.6', '5.7', '5.8', '5.9', '6.0', '6.1', '6.2', '6.3', '6.4', '6.5', '6.6', '6.7' ]
exclude:
# PHP 8.4 exclusions
- wp-version: '6.6'
php-version: '8.4'
- wp-version: '6.5'
php-version: '8.4'
- wp-version: '6.4'
php-version: '8.4'
- wp-version: '6.3'
php-version: '8.4'
- wp-version: '6.2'
php-version: '8.4'
- wp-version: '6.1'
php-version: '8.4'
- wp-version: '6.0'
php-version: '8.4'
- wp-version: '5.9'
php-version: '8.4'
- wp-version: '5.8'
php-version: '8.4'
- wp-version: '5.7'
php-version: '8.4'
- wp-version: '5.6'
php-version: '8.4'
- wp-version: '5.5'
php-version: '8.4'
- wp-version: '5.4'
php-version: '8.4'

# PHP 8.3 exclusions
- wp-version: '6.3'
php-version: '8.3'
- wp-version: '6.2'
php-version: '8.3'
- wp-version: '6.1'
php-version: '8.3'
- wp-version: '6.0'
php-version: '8.3'
- wp-version: '5.9'
php-version: '8.3'
- wp-version: '5.8'
php-version: '8.3'
- wp-version: '5.7'
php-version: '8.3'
- wp-version: '5.6'
php-version: '8.3'
- wp-version: '5.5'
php-version: '8.3'
- wp-version: '5.4'
php-version: '8.3'

# PHP 8.2 exclusions
- wp-version: '6.0'
php-version: '8.2'
- wp-version: '5.9'
php-version: '8.2'
- wp-version: '5.8'
php-version: '8.2'
- wp-version: '5.7'
php-version: '8.2'
- wp-version: '5.6'
php-version: '8.2'
- wp-version: '5.5'
php-version: '8.2'
- wp-version: '5.4'
php-version: '8.2'

# PHP 8.1 exclusions
- wp-version: '5.8'
php-version: '8.1'
- wp-version: '5.7'
php-version: '8.1'
- wp-version: '5.6'
php-version: '8.1'
- wp-version: '5.5'
php-version: '8.1'
- wp-version: '5.4'
php-version: '8.1'

# PHP 8 exclusions
- wp-version: '5.8' # Should work, currently doesn't.
php-version: '8.0'
- wp-version: '5.7' # Should work, currently doesn't.
php-version: '8.0'
- wp-version: '5.6' # Introduced PHP 8 beta support. Should work, currently doesn't.
php-version: '8.0'
- wp-version: '5.5'
php-version: '8.0'
- wp-version: '5.4'
php-version: '8.0'
matrix: ${{ fromJSON( needs.generate-matrix.outputs.matrix ) }}

steps:
- name: Checkout
uses: actions/checkout@master
uses: actions/checkout@v6

- name: Setup MySQL with mysql_native_password
uses: shogo82148/actions-setup-mysql@v1
- name: Setup Node
uses: actions/setup-node@v4
with:
mysql-version: ${{ matrix.wp-version >= '5.0' && '8.0' || '5.6' }}
my-cnf: |
bind_address=127.0.0.1
default-authentication-plugin=mysql_native_password
root-password: root

- name: Set up PHP
uses: shivammathur/setup-php@v2
cache: 'npm'
node-version: '18'

- name: Install dependencies
run: npm install

- name: Setup cache
uses: actions/cache@v5
with:
php-version: ${{ matrix.php-version }}
coverage: none
extensions: mysql, mysqli
tools: composer, wp-cli, phpunit:${{ matrix.wp-version < '5.1' && '6' || ( matrix.wp-version < '5.9' || matrix.php-version < '8.0' ) && '7' || '9' }}, phpunit-polyfills:^1.1.0
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
key: ${{ runner.os }}-${{ hashFiles('composer.json') }} # Note that lock file will change between runs.
path: |
.cache
tests/phpunit/cache

- name: Install Composer dependencies
run: composer install --optimize-autoloader --prefer-dist
- name: Skip development plugins
run: echo '{"plugins":[]}' > .wp-env.override.json

- name: Install SVN
run: sudo apt-get update && sudo apt-get install -y subversion
- name: Start the development environment
run: npm run env start

- name: Install test suite
- name: Report Versions
run: |
echo "WP_VERSION=${{ matrix.wp-version }}" >> $GITHUB_ENV
echo "TMPDIR=${{ runner.temp }}" >> $GITHUB_ENV
echo "WP_TESTS_DIR=${{ runner.temp }}/wordpress-tests-lib" >> $GITHUB_ENV
echo "WP_CORE_DIR=${{ runner.temp }}/wordpress" >> $GITHUB_ENV
TMPDIR=${{ runner.temp }} bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 ${{ matrix.wp-version }}
npm run env run cli -- php -v
npm run env run cli -- wp core version

- name: Install fresh dependencies for PHP ${{ matrix.php-version }}
run: rm composer.lock

- name: Install dependencies
run: npm run cli -- composer require --dev phpunit/phpunit:^${{ matrix.wp-version < '5.1' && '6' || ( matrix.wp-version < '5.9' || matrix.php-version < '8.0' ) && '7' || '9' }}

- name: Run PHPUnit tests (single site)
run: npm run test:php

- name: Run PHPUnit tests (multisite)
run: npm run test:php:multisite

phpunit-coverage:
name: PHPUnit Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Run PHPUnit tests
- name: Setup cache
uses: actions/cache@v5
with:
key: ${{ runner.os }}-${{ hashFiles('composer.json') }} # Note that lock file will change between runs.
path: |
.cache
tests/phpunit/cache

- name: Setup Node
uses: actions/setup-node@v4
with:
cache: 'npm'
node-version: '18'

- name: Install dependencies
run: npm install

- name: Start the development environment
run: npm run env -- start --xdebug=coverage

- name: Report Versions
run: |
echo "define('WP_TESTS_PHPUNIT_POLYFILLS_PATH', '$HOME/.composer/vendor/yoast/phpunit-polyfills');" >> ${{ runner.temp }}/wordpress-tests-lib/wp-tests-config.php
phpunit
npm run env run cli -- php -v
npm run env run cli -- php -i | grep xdebug
npm run env run cli -- wp core version

- name: Install Composer dependencies
run: npm run test:php:install-deps

- name: Ensure version-controlled files are not modified or deleted
run: git diff --exit-code
- name: Generate coverage report
run: npm run coverage:php:full
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
.phpunit.result.cache
phpunit.xml
phpcs.xml
phpstan.neon
.wp-env.override.json
/tests/phpunit/cache
/tests/phpunit/coverage
wp-tests-config.php

# Track placeholders so that empty directories stay in the repo.
!.gitkeep
1 change: 1 addition & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://schemas.wp.org/trunk/wp-env.json",
"phpVersion": "7.4",
"plugins": [
"norcross/airplane-mode",
Expand Down
Loading