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
4 changes: 3 additions & 1 deletion .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
bin/
node_modules/
tests/
RELEASE.md
phpunit.xml.dist
wp-tests-config-sample.php
phpunit-*.xml.dist
phpcs.xml.dist
phpstan.dist.neon
composer.json
Expand All @@ -18,3 +19,4 @@ package-lock.json
.gitattributes
.distignore
.editorconfig
.nvmrc
7 changes: 4 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
/.cache export-ignore
/node_modules export-ignore
/tests export-ignore
RELEASE.md export-ignore
phpunit.xml.dist export-ignore
wp-tests-config-sample.php export-ignore
phpunit-multisite.xml.dist export-ignore
phpcs.xml.dist export-ignore
composer.json export-ignore
composer.lock export-ignore
phpstan.neon.dist export-ignore
package.json export-ignore
package-lock.json export-ignore
.wp-env.json export-ignore
.gitignore export-ignore
.gitattributes export-ignore
.distignore export-ignore
.editorconfig export-ignore
.nvmrc export-ignore
11 changes: 9 additions & 2 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ on:
jobs:
log-the-inputs:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Check out source code
uses: actions/checkout@v4
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
persist-credentials: false

- name: Bump version
run: |
Expand All @@ -27,8 +33,9 @@ jobs:
env:
VERSION: ${{ inputs.version }}

# TODO: use `gh pr new` instead
- name: Create pull request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
branch: bump-version
commit-message: "Bump version to ${{ inputs.version }}"
Expand Down
37 changes: 28 additions & 9 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,41 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
env:
WP_ENV_HOME: .cache/wp-env

steps:
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
persist-credentials: false

- name: Setup cache
uses: actions/cache@v5
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: ${{ runner.os }}-${{ hashFiles('composer.json') }} # Note that lock file will change between runs.
path: .cache
key: ${{ runner.os }}-${{ hashFiles('composer.json', 'package.json') }}
path: |
.cache

- name: Set up PHP
uses: shivammathur/setup-php@cf4cade2721270509d5b1c766ab3549210a39a2a # v2.33.0
- name: Setup Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
cache: 'npm'
node-version-file: '.nvmrc'

- name: Install dependencies
run: composer install
run: npm install

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

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

- name: Lint PHPCS
# TODO: Remove the flag once all warnings are fixed.
run: npm run lint:php:phpcs -- -- -- --warning-severity=0

- name: Run PHPStan
run: npm run lint:php:phpstan

- name: Lint PHP
run: composer run lint
11 changes: 7 additions & 4 deletions .github/workflows/generate-missing-i18n-files-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
generate-missing-i18n-files:
name: Generate missing i18n files PR
if: github.repository == ${{ github.event.repository.full_name }}
if: github.repository == github.event.repository.full_name
permissions:
contents: write
pull-requests: write
Expand All @@ -20,15 +20,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v4
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
persist-credentials: true # git cli needs this

- name: Set up PHP environment
uses: shivammathur/setup-php@v2
uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # 2.37.1
with:
php-version: "7.4"

- name: Setup WP-CLI
uses: godaddy-wordpress/setup-wp-cli@1
uses: godaddy-wordpress/setup-wp-cli@1 # using tag, sha hash will not resolve
# uses: godaddy-wordpress/setup-wp-cli@7dee90ee27eb3510c0997111eb5c01de856c7a98 # 1.0.0

- name: Configure git user
run: |
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/generate-pot-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
generate-pot:
name: Generate POT PR
if: github.repository == ${{ github.event.repository.full_name }}
if: github.repository == github.event.repository.full_name
permissions:
contents: write
pull-requests: write
Expand All @@ -18,15 +18,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v4
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
persist-credentials: true # git cli needs this

- name: Set up PHP environment
uses: shivammathur/setup-php@v2
uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # 2.37.1
with:
php-version: "7.4"

- name: Setup WP-CLI
uses: godaddy-wordpress/setup-wp-cli@1
uses: godaddy-wordpress/setup-wp-cli@1 # using tag, sha hash will not resolve
# uses: godaddy-wordpress/setup-wp-cli@7dee90ee27eb3510c0997111eb5c01de856c7a98 # 1.0.0

- name: Configure git user
run: |
Expand Down
179 changes: 98 additions & 81 deletions .github/workflows/phpunit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

# Cancels all previous workflow runs for pull requests that have not completed.
Expand All @@ -16,100 +14,119 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

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

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
permissions:
contents: read
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
- 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
continue-on-error: ${{ matrix.wp-version == 'trunk' }} # Allow tests to fail for trunk.
permissions:
contents: read
needs: generate-matrix
env:
WP_ENV_HOME: .cache/wp-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: [ '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ]
wp-version: [ '6.2', '6.3', '6.4', '6.5', '6.6', '6.7', '6.8', '6.9' ]
exclude:
# PHP 8.5 exclusions
- wp-version: '6.8'
php-version: '8.5'
- wp-version: '6.7'
php-version: '8.5'
- wp-version: '6.6'
php-version: '8.5'
- wp-version: '6.5'
php-version: '8.5'
- wp-version: '6.4'
php-version: '8.5'
- wp-version: '6.3'
php-version: '8.5'
- wp-version: '6.2'
php-version: '8.5'

# 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'

# PHP 8.3 exclusions
- wp-version: '6.3'
php-version: '8.3'
- wp-version: '6.2'
php-version: '8.3'
fail-fast: false
matrix: ${{ fromJSON( needs.generate-matrix.outputs.matrix ) }}

steps:
- name: Checkout
uses: actions/checkout@master
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2

- name: Setup MySQL with mysql_native_password
uses: shogo82148/actions-setup-mysql@v1
- name: Setup Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
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-file: '.nvmrc'

- name: Install dependencies
run: npm install

- name: Setup cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
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', 'package.json') }}
path: |
.cache
tests/phpunit/cache

- name: Install Composer dependencies
run: composer update --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 cli -- php -v
npm run cli -- wp core version

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

- 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
permissions:
contents: read
env:
WP_ENV_HOME: .cache/wp-env
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2

- name: Setup cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: ${{ runner.os }}-${{ hashFiles('composer.json', 'package.json') }}
path: |
.cache
tests/phpunit/cache

- name: Setup Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
cache: 'npm'
node-version-file: '.nvmrc'

- name: Install dependencies
run: npm install

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

- name: Run PHPUnit tests
- 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 cli -- php -v
npm run cli -- php -i | grep xdebug
npm run cli -- wp core version

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

- name: Generate coverage report
run: npm run coverage:php:full
Loading