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
This commit is contained in:
2025-11-24 19:38:01 +00:00
parent 1590be3ba6
commit c17b6f1818
3 changed files with 10 additions and 4 deletions

View File

@@ -97,13 +97,13 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- name: Set up JDK 17 - name: Set up JDK 17
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0 uses: actions/setup-java@v4
with: with:
java-version: 17 java-version: 17
distribution: 'temurin' distribution: 'temurin'
- name: Cache SonarCloud packages - name: Cache SonarCloud packages
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v3.3.2 uses: actions/cache@v4
with: with:
path: ~/.sonar/cache path: ~/.sonar/cache
key: ${{ runner.os }}-sonar key: ${{ runner.os }}-sonar
@@ -154,7 +154,7 @@ jobs:
fi fi
- name: Run Codacy Analysis CLI - name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@5cc54a75f9ad8e86bb795a5d3d4f2f70c9baa1a7 # v4.3.0 uses: codacy/codacy-analysis-cli-action@v4
with: with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
verbose: true verbose: true
@@ -169,7 +169,7 @@ jobs:
- name: Upload SARIF results file - name: Upload SARIF results file
if: steps.check_codacy_token.outputs.skip_upload != 'true' 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: with:
sarif_file: results.sarif sarif_file: results.sarif
continue-on-error: true continue-on-error: true

View File

@@ -16,6 +16,7 @@
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^9.5.0", "phpunit/phpunit": "^9.5.0",
"yoast/phpunit-polyfills": "^2.0",
"10up/wp_mock": "^1.0", "10up/wp_mock": "^1.0",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0", "dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"wp-coding-standards/wpcs": "^3.0", "wp-coding-standards/wpcs": "^3.0",

View File

@@ -10,6 +10,11 @@ require_once dirname( dirname( __DIR__ ) ) . '/vendor/autoload.php';
// Check if we're running the WordPress tests // Check if we're running the WordPress tests
if ( getenv( 'WP_PHPUNIT__DIR' ) ) { 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. // Give access to tests_add_filter() function.
require_once getenv( 'WP_PHPUNIT__DIR' ) . '/includes/functions.php'; require_once getenv( 'WP_PHPUNIT__DIR' ) . '/includes/functions.php';