From d7c92afeda6bed6f798f517646dd9c11409de940 Mon Sep 17 00:00:00 2001 From: Faisal Ahammad Date: Sun, 18 Oct 2026 23:34:42 +0600 Subject: [PATCH] fix(ci): match PHPUnit library to WordPress branch wp-env loads the PHPUnit library from wordpress-develop trunk when the core version has an -alpha suffix, as on 7.1-branch (7.1.4-alpha). Trunk tests need WP_Secrets_Store, which 7.1 does not have, so the bootstrap fails. For -branch matrix legs, check out the matching wordpress-develop branch for the PHPUnit library. --- .github/workflows/test.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8e600f62..138137c6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -153,6 +153,21 @@ jobs: max_attempts: 3 command: npm run env start -- --xdebug=coverage + # wp-env pulls the PHPUnit library from wordpress-develop trunk whenever the core + # version has an -alpha suffix, which is the case between point releases on a + # branch (e.g. 7.1.4-alpha). Trunk tests can then need classes this branch does not + # have yet, so check out the matching wordpress-develop branch instead. + - name: Match the PHPUnit library to the WordPress branch + if: ${{ endsWith( matrix.wp, '-branch' ) }} + env: + WP_BRANCH: ${{ matrix.wp }} + run: | + BRANCH="${WP_BRANCH##*#}" + BRANCH="${BRANCH%-branch}" + PHPUNIT_DIR="$(npm run --silent env -- status --json | jq -r .installPath)/tests-WordPress-PHPUnit" + git -C "$PHPUNIT_DIR" fetch origin "$BRANCH" --depth 1 + git -C "$PHPUNIT_DIR" checkout FETCH_HEAD + - name: Composer install run: | rm composer.lock || true # We need to install fresh.