From 0f9fb1e9e9ca3b057249bf7ca30a2727ade0090e Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Wed, 20 May 2026 03:41:10 +0000 Subject: [PATCH 01/10] Build: migrate CI from Travis to GitHub Actions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add PHPUnit matrix (PHP 7.4–8.5 against WordPress trunk, MariaDB 11 service) and a lint workflow covering PHPCS, ESLint, and checktextdomain. PHP 8.5 is flagged experimental and allowed to fail. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/lint.yml | 66 +++++++++++++++++++ .github/workflows/test.yml | 126 +++++++++++++++++++++++++++++++++++++ .travis.yml | 115 --------------------------------- Gruntfile.js | 2 +- 4 files changed, 193 insertions(+), 116 deletions(-) create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..16e6d2411 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,66 @@ +name: Lint + +on: + push: + branches: + - trunk + pull_request: + +jobs: + phpcs: + name: PHPCS (WordPress Coding Standards) + runs-on: ubuntu-latest + timeout-minutes: 15 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + tools: composer:v2, cs2pr + coverage: none + + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" + + - name: Cache composer dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: composer-${{ runner.os }}-phpcs-${{ hashFiles('**/composer.json') }} + restore-keys: | + composer-${{ runner.os }}-phpcs- + + - name: Install composer dependencies + run: composer install --prefer-dist --no-progress --no-interaction + + - name: Run PHPCS + run: composer lint -- -q --report=checkstyle | cs2pr + + js-lint: + name: ESLint & checktextdomain + runs-on: ubuntu-latest + timeout-minutes: 15 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Install npm dependencies + run: npm ci + + - name: Run ESLint + run: npx grunt eslint:grunt eslint:core + + - name: Run checktextdomain + run: npx grunt checktextdomain diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..e92949103 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,126 @@ +name: PHPUnit Tests + +on: + push: + branches: + - trunk + pull_request: + +jobs: + phpunit: + name: PHP ${{ matrix.php }} / WP ${{ matrix.wp }} + runs-on: ubuntu-latest + timeout-minutes: 30 + + services: + mariadb: + image: mariadb:11 + env: + MARIADB_ROOT_PASSWORD: root + MARIADB_DATABASE: wordpress_test + ports: + - 3306:3306 + options: >- + --health-cmd="healthcheck.sh --connect --innodb_initialized" + --health-interval=10s + --health-timeout=5s + --health-retries=10 + + strategy: + fail-fast: false + matrix: + php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ] + wp: [ 'trunk' ] + experimental: [ false ] + include: + # PHP 8.5 is bleeding-edge: allow failures while still surfacing results. + - php: '8.5' + wp: 'trunk' + experimental: true + exclude: + - php: '8.5' + wp: 'trunk' + experimental: false + + continue-on-error: ${{ matrix.experimental }} + + env: + WP_DEVELOP_DIR: ${{ github.workspace }}/wordpress-develop + PLUGIN_SLUG: bbpress + + steps: + - name: Checkout bbPress + uses: actions/checkout@v4 + with: + path: plugin-src + + - name: Checkout WordPress (${{ matrix.wp }}) + uses: actions/checkout@v4 + with: + repository: WordPress/wordpress-develop + ref: ${{ matrix.wp }} + path: wordpress-develop + + - name: Move plugin into WordPress develop tree + run: | + mkdir -p "${WP_DEVELOP_DIR}/src/wp-content/plugins" + mv plugin-src "${WP_DEVELOP_DIR}/src/wp-content/plugins/${PLUGIN_SLUG}" + + - name: Set up PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer:v2 + coverage: none + extensions: mysqli, mbstring, intl, curl, dom, json, libxml, xml, zip + ini-values: error_reporting=E_ALL, display_errors=On + + - name: Get composer cache directory + id: composer-cache + working-directory: ${{ env.WP_DEVELOP_DIR }}/src/wp-content/plugins/${{ env.PLUGIN_SLUG }} + run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" + + - name: Cache composer dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: composer-${{ runner.os }}-php${{ matrix.php }}-${{ hashFiles('**/composer.json') }} + restore-keys: | + composer-${{ runner.os }}-php${{ matrix.php }}- + + - name: Install composer dependencies + working-directory: ${{ env.WP_DEVELOP_DIR }}/src/wp-content/plugins/${{ env.PLUGIN_SLUG }} + run: composer install --prefer-dist --no-progress --no-interaction + + - name: Configure WordPress tests + working-directory: ${{ env.WP_DEVELOP_DIR }} + run: | + cp wp-tests-config-sample.php wp-tests-config.php + sed -i "s/youremptytestdbnamehere/wordpress_test/" wp-tests-config.php + sed -i "s/yourusernamehere/root/" wp-tests-config.php + sed -i "s/yourpasswordhere/root/" wp-tests-config.php + sed -i "s|localhost|127.0.0.1|" wp-tests-config.php + + - name: Wait for MariaDB to be ready + run: | + for i in {1..30}; do + if mysqladmin ping -h 127.0.0.1 -P 3306 -uroot -proot --silent; then + echo "MariaDB is up" + exit 0 + fi + sleep 2 + done + echo "MariaDB did not become ready in time" >&2 + exit 1 + + - name: Show tool versions + working-directory: ${{ env.WP_DEVELOP_DIR }}/src/wp-content/plugins/${{ env.PLUGIN_SLUG }} + run: | + php --version + composer --version + vendor/bin/phpunit --version + mysql --version + + - name: Run PHPUnit + working-directory: ${{ env.WP_DEVELOP_DIR }}/src/wp-content/plugins/${{ env.PLUGIN_SLUG }} + run: composer test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 340db01ad..000000000 --- a/.travis.yml +++ /dev/null @@ -1,115 +0,0 @@ -# Travis CI Configuration File - -# Tell Travis CI we're using PHP -language: php - -# Tell Travis CI which operating system to use -os: linux - -# Ensure MySQL is available -services: - - mysql - -# Configure caches -cache: - directories: - - vendor - - $HOME/.composer/cache - - node_modules - -# PHP version used in first build configuration. -php: - - 7.4 - - 7.3 - - 7.2 - - 7.1 - - 7.0 - - 5.6 - -# WordPress comes from the Git mirror, where 'master' mirrors svn 'trunk' and -# x.y mirrors the latest from the x.y branch -env: - - WP_VERSION=master - - WP_VERSION=5.3 - - WP_VERSION=5.2 - -# Build matrix options -jobs: - include: - - php: nightly - env: WP_VERSION=master - exclude: - - php: 7.4 - env: WP_VERSION=5.2 - allow_failures: - - php: nightly -# fast_finish: true - -# before_install: Failures in this section will result in build status 'errored' -before_install: - # setup WP_DEVELOP_DIR (needed for bbPress to bootstrap WP PHPUnit tests) - - export WP_DEVELOP_DIR=/tmp/wordpress/ - - mkdir -p $WP_DEVELOP_DIR - # clone the WordPress develop repo - - git clone --depth=1 --branch="$WP_VERSION" git://develop.git.wordpress.org/ $WP_DEVELOP_DIR - # clone the BuddyPress develop repo - - git clone --depth=1 git://buddypress.git.wordpress.org/ $WP_DEVELOP_DIR/src/wp-content/plugins/buddypress - - plugin_slug=$(basename $(pwd)) - - plugin_dir=$WP_DEVELOP_DIR/src/wp-content/plugins/$plugin_slug - - cd .. - - mv $plugin_slug $plugin_dir - # set up tests config - - cd $WP_DEVELOP_DIR - - echo $WP_DEVELOP_DIR - - cp wp-tests-config-sample.php wp-tests-config.php - - sed -i "s/youremptytestdbnamehere/wordpress_test/" wp-tests-config.php - - sed -i "s/yourusernamehere/root/" wp-tests-config.php - - sed -i "s/yourpasswordhere//" wp-tests-config.php - # set up database - - mysql -e 'CREATE DATABASE wordpress_test;' -uroot - # prepare for running the tests - - cd $plugin_dir - # setup NodeJS version using NVM - - node --version - - nvm install 12 - - node --version - - npm install -g grunt-cli - - npm --version - - phpenv versions - - echo $TRAVIS_PHP_VERSION - - mysql --version - - php --version - - php -m - - phpunit --version - - curl --version - - grunt --version - - git --version - - svn --version - -# before_script: Failures in this section will result in build status 'failed' -before_script: - - | - # Remove Xdebug for a huge performance increase: - if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then - phpenv config-rm xdebug.ini - else - echo "xdebug.ini does not exist" - fi - - export PATH="$HOME/.composer/vendor/bin:$PATH" - - | - if [[ ${TRAVIS_PHP_VERSION:0:2} == "7." ]]; then - echo "Using latest PHPUnit 6.x branch" - composer global require "phpunit/phpunit=^6" - elif [[ ${TRAVIS_PHP_VERSION:0:3} == "5.6" ]]; then - echo "Using latest PHPUnit 4.x branch" - composer global require "phpunit/phpunit=^4" - fi - - npm install - - grunt build - -# Run tests -script: - - grunt travis - -notifications: - email: false diff --git a/Gruntfile.js b/Gruntfile.js index 87a66d2f4..0f5544dd0 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -25,8 +25,8 @@ module.exports = function( grunt ) { // Ignore these '!**/.{svn,git}/**', '!.editorconfig', + '!.github/**', '!.gitignore', - '!.travis.yml', '!build/**', '!Gruntfile.js', '!node_modules/**', From c59bb28956e648c50010ebd297848c04e6ea9b1c Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Wed, 20 May 2026 03:46:02 +0000 Subject: [PATCH 02/10] Tools - Unit Tests: drop stale seems_utf8 deprecation expectation. bbp_format_user_display_name() now prefers wp_is_valid_utf8() (WP 6.9+) and mb_check_encoding() ahead of the seems_utf8() fallback, so on modern environments the deprecated function is never called. The expectation became stale after r7393. Also pin lint workflow to PHP 8.4. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/lint.yml | 2 +- tests/phpunit/testcases/replies/template/authors.php | 2 -- tests/phpunit/testcases/topics/template/authors.php | 2 -- tests/phpunit/testcases/users/template/user.php | 2 -- 4 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 16e6d2411..ca8591050 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,7 +19,7 @@ jobs: - name: Set up PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.4' tools: composer:v2, cs2pr coverage: none diff --git a/tests/phpunit/testcases/replies/template/authors.php b/tests/phpunit/testcases/replies/template/authors.php index 0f9830850..9757a7ff2 100644 --- a/tests/phpunit/testcases/replies/template/authors.php +++ b/tests/phpunit/testcases/replies/template/authors.php @@ -45,8 +45,6 @@ public function test_bbp_get_reply_author_id() { * @covers ::bbp_get_reply_author_display_name */ public function test_bbp_get_reply_author_display_name() { - $this->setExpectedDeprecated( 'seems_utf8' ); - $u = $this->factory->user->create( array( 'display_name' => 'Barry B. Benson', ) ); diff --git a/tests/phpunit/testcases/topics/template/authors.php b/tests/phpunit/testcases/topics/template/authors.php index 26d9a661b..dbf58552b 100644 --- a/tests/phpunit/testcases/topics/template/authors.php +++ b/tests/phpunit/testcases/topics/template/authors.php @@ -40,8 +40,6 @@ public function test_bbp_get_topic_author_id() { * @covers ::bbp_get_topic_author_display_name */ public function test_bbp_get_topic_author_display_name() { - $this->setExpectedDeprecated( 'seems_utf8' ); - $u = $this->factory->user->create( array( 'display_name' => 'Barry B. Benson', ) ); diff --git a/tests/phpunit/testcases/users/template/user.php b/tests/phpunit/testcases/users/template/user.php index 93ee68050..19bfefbe8 100644 --- a/tests/phpunit/testcases/users/template/user.php +++ b/tests/phpunit/testcases/users/template/user.php @@ -704,8 +704,6 @@ public function test_bbp_user_lost_pass_fields() { * @covers ::bbp_get_author_link */ public function test_bbp_get_author_link() { - $this->setExpectedDeprecated( 'seems_utf8' ); - $t = $this->factory->topic->create(); $display_name = $this->keymaster_userdata->display_name; From 7ca3a4a92ea2ccdca230b5dd05c8e644d447a91f Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Wed, 20 May 2026 03:46:54 +0000 Subject: [PATCH 03/10] Tools - PHPCS: accept "bbp" as the project prefix globally. WPCS 3.0+ raises ShortPrefixPassed for prefixes under 4 chars. "bbp" is the deliberately chosen project prefix, so suppress the sub-sniff via severity=0 instead of excluding a single file. Co-Authored-By: Claude Opus 4.7 (1M context) --- phpcs.xml.dist | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 138feff51..070df15dd 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -234,8 +234,12 @@ /src/templates/* + - /bbpress\.php + 0 + + +