From c1b95549ed5028202e9cfca22c2187ad85b56dfa Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Mon, 9 Mar 2026 14:59:52 +1000 Subject: [PATCH 1/2] Update CI to PHP 8.4/8.5 using wp-env for tests - Replace custom install-wp-tests.sh CI setup with wp-env - Test against PHP 8.4 and 8.5 (dropping 7.4) - Update wp-env default PHP version to 8.4 - Update coding standards workflow to PHP 8.4 - Widen composer PHPUnit constraint to support 9.6/10/11 - Widen yoast/phpunit-polyfills to ^2.0 || ^3.0 - Remove PHPUnit 10-incompatible XML attributes Co-Authored-By: Claude Opus 4.6 --- .github/workflows/coding-standards.yml | 2 +- .github/workflows/tests.yml | 38 ++++++++++---------------- .wp-env.json | 2 +- composer.json | 4 +-- phpunit.xml.dist | 3 -- 5 files changed, 19 insertions(+), 30 deletions(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 180b4934..e28c88d3 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -16,7 +16,7 @@ jobs: - name: Install PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.3' + php-version: '8.4' coverage: 'none' tools: composer, cs2pr diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 067dcb64..aefd03cd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,29 +9,20 @@ jobs: name: PHPUnit ${{ matrix.php }} runs-on: ubuntu-latest - services: - mysql: - image: mysql:5.7 - ports: - - 3306/tcp - env: - MYSQL_ROOT_PASSWORD: password - # Set health checks to wait until mysql has started - options: >- - --health-cmd "mysqladmin ping" - --health-interval 10s - --health-timeout 5s - --health-retries 3 - strategy: fail-fast: false matrix: - php: [ '7.4', '8.3' ] + php: [ '8.4', '8.5' ] steps: - name: Check out Git repository uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -39,18 +30,19 @@ jobs: coverage: 'none' tools: composer - - name: Install dependencies + - name: Install Composer dependencies uses: ramsey/composer-install@v2 with: composer-options: "--no-progress --no-ansi --no-interaction" - - name: Install WordPress test setup - run: bash bin/install-wp-tests.sh wordpress_test root password 127.0.0.1:${{ job.services.mysql.ports[3306] }} latest + - name: Install wp-env + run: npm -g install @wordpress/env + + - name: Override PHP version + run: echo '{ "phpVersion":"${{ matrix.php }}" }' > .wp-env.override.json - - name: Setup problem matchers for PHPUnit - run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + - name: Start wp-env + run: wp-env start - name: Run tests - env: - WP_TESTS_DIR: /tmp/wordpress-tests-lib/ - run: vendor/bin/phpunit + run: wp-env run tests-cli --env-cwd=wp-content/plugins/wporg-gp-translation-events ./vendor/bin/phpunit diff --git a/.wp-env.json b/.wp-env.json index eede0128..d6e68c9e 100644 --- a/.wp-env.json +++ b/.wp-env.json @@ -1,6 +1,6 @@ { "core": null, - "phpVersion": "8.3", + "phpVersion": "8.4", "plugins": [ "GlotPress/GlotPress", "https://downloads.wordpress.org/plugin/sqlite-object-cache.1.3.7.zip", diff --git a/composer.json b/composer.json index 504366c3..dfcee8d5 100644 --- a/composer.json +++ b/composer.json @@ -3,8 +3,8 @@ "description": "", "license": "GPL-2.0-only", "require-dev": { - "phpunit/phpunit": "^9.6.16", - "yoast/phpunit-polyfills": "^2.0.0", + "phpunit/phpunit": "^9.6.16 || ^10.0 || ^11.0", + "yoast/phpunit-polyfills": "^2.0.0 || ^3.0", "wp-coding-standards/wpcs": "^3.0" }, "scripts":{ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4af023cb..3cbe17a9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,9 +3,6 @@ bootstrap="tests/bootstrap.php" backupGlobals="false" colors="true" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" > From a620d9d7f0f8bd86093dfe66d6572dca0f9ac8ad Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Mon, 9 Mar 2026 15:03:29 +1000 Subject: [PATCH 2/2] Fix CI: GlotPress directory casing and npm cache conflict - Update bootstrap.php to detect GlotPress directory name case-insensitively (wp-env installs as 'GlotPress' not 'glotpress') - Use --force flag for npm install to avoid EEXIST cache errors Co-Authored-By: Claude Opus 4.6 --- .github/workflows/tests.yml | 2 +- tests/bootstrap.php | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index aefd03cd..796c4360 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -36,7 +36,7 @@ jobs: composer-options: "--no-progress --no-ansi --no-interaction" - name: Install wp-env - run: npm -g install @wordpress/env + run: npm -g install @wordpress/env --force - name: Override PHP version run: echo '{ "phpVersion":"${{ matrix.php }}" }' > .wp-env.override.json diff --git a/tests/bootstrap.php b/tests/bootstrap.php index a57bf205..1614f746 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -8,12 +8,17 @@ } function _glotpress_path( string $path ): string { - $glotpress_path = dirname( __DIR__, 2 ) . '/glotpress/'; - if ( getenv( 'GITHUB_ACTIONS' ) ) { - $glotpress_path = '/tmp/wordpress/wp-content/plugins/glotpress/'; + $plugins_dir = dirname( __DIR__, 2 ); + + // GlotPress may be installed as 'glotpress' or 'GlotPress' depending on the environment. + foreach ( array( 'glotpress', 'GlotPress' ) as $dir_name ) { + if ( is_dir( $plugins_dir . '/' . $dir_name ) ) { + return $plugins_dir . '/' . $dir_name . '/' . $path; + } } - return $glotpress_path . $path; + // Fallback to lowercase. + return $plugins_dir . '/glotpress/' . $path; } // Forward custom PHPUnit Polyfills configuration to PHPUnit bootstrap file.