From c17b6f18183bfc3c129370b578f245c0ca778476 Mon Sep 17 00:00:00 2001 From: marcusquinn <6428977+marcusquinn@users.noreply.github.com> Date: Mon, 24 Nov 2025 19:38:01 +0000 Subject: [PATCH] Fix remaining CI/CD issues - Add yoast/phpunit-polyfills ^2.0 to composer.json for WordPress test suite compatibility - Define WP_TESTS_PHPUNIT_POLYFILLS_PATH in bootstrap.php before loading WP test framework - Update actions/cache to v4 (deprecated SHA references cause failures) - Update actions/setup-java to v4 - Update codacy/codacy-analysis-cli-action to v4 tag (SHA ref not found) - Update github/codeql-action/upload-sarif to v3 --- .github/workflows/code-quality.yml | 8 ++++---- composer.json | 1 + tests/phpunit/bootstrap.php | 5 +++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index d3be83c..b38f80f 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -97,13 +97,13 @@ jobs: fetch-depth: 0 - name: Set up JDK 17 - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0 + uses: actions/setup-java@v4 with: java-version: 17 distribution: 'temurin' - name: Cache SonarCloud packages - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v3.3.2 + uses: actions/cache@v4 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar @@ -154,7 +154,7 @@ jobs: fi - name: Run Codacy Analysis CLI - uses: codacy/codacy-analysis-cli-action@5cc54a75f9ad8e86bb795a5d3d4f2f70c9baa1a7 # v4.3.0 + uses: codacy/codacy-analysis-cli-action@v4 with: project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} verbose: true @@ -169,7 +169,7 @@ jobs: - name: Upload SARIF results file if: steps.check_codacy_token.outputs.skip_upload != 'true' - uses: github/codeql-action/upload-sarif@cdcdbb579706841c47f7063dda365e292e5cad7a # v2.2.7 + uses: github/codeql-action/upload-sarif@v3 with: sarif_file: results.sarif continue-on-error: true diff --git a/composer.json b/composer.json index 4d5291d..89fa47f 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ }, "require-dev": { "phpunit/phpunit": "^9.5.0", + "yoast/phpunit-polyfills": "^2.0", "10up/wp_mock": "^1.0", "dealerdirect/phpcodesniffer-composer-installer": "^1.0", "wp-coding-standards/wpcs": "^3.0", diff --git a/tests/phpunit/bootstrap.php b/tests/phpunit/bootstrap.php index 77e7852..cf765e4 100644 --- a/tests/phpunit/bootstrap.php +++ b/tests/phpunit/bootstrap.php @@ -10,6 +10,11 @@ require_once dirname( dirname( __DIR__ ) ) . '/vendor/autoload.php'; // Check if we're running the WordPress tests if ( getenv( 'WP_PHPUNIT__DIR' ) ) { + // Define PHPUnit Polyfills path for WordPress test suite. + if ( ! defined( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH' ) ) { + define( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH', dirname( dirname( __DIR__ ) ) . '/vendor/yoast/phpunit-polyfills/' ); + } + // Give access to tests_add_filter() function. require_once getenv( 'WP_PHPUNIT__DIR' ) . '/includes/functions.php';