From 1853dcfca9c0566102976617f359e21b6ce4ac9b Mon Sep 17 00:00:00 2001 From: Joost de Valk Date: Thu, 26 Nov 2026 16:22:55 +0100 Subject: [PATCH] Run CI from PHP 7.4, the minimum the plugin declares The plugin header and readme say PHP 7.4, but CI started at 8.2 and composer.json required 8.2. Lint now runs on 7.4 through 8.5, the tests get a PHP 7.4 leg, and composer.json requires 7.4 to match the header. The dev tools still need a newer PHP, so the lint job installs them on 8.3 first and the test job leaves out the tools it does not use. Co-Authored-By: Claude Fable 5.2 --- .github/workflows/lint.yml | 22 +++++++++++++++++----- .github/workflows/test.yml | 22 +++++++++++++++++++--- composer.json | 2 +- composer.lock | 4 ++-- 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 330240d..a62fed0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -26,7 +26,7 @@ jobs: matrix: # Lint against the highest/lowest supported versions of each PHP major. # And also do a run against "nightly" (the current dev version of PHP). - php_version: ['8.2', '8.3', '8.4', '8.5'] + php_version: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] name: "Lint: PHP ${{ matrix.php_version }}" @@ -34,13 +34,17 @@ jobs: - name: Checkout code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - name: Install PHP + # The locked dev tools (PHP-CS-Fixer and friends) need a newer PHP than the + # plugin itself supports, so install with a recent PHP first. + - name: Install PHP for the composer install uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0 with: - php-version: ${{ matrix.php_version }} - ini-values: zend.assertions=1, error_reporting=-1, display_errors=On + php-version: '8.3' coverage: none - tools: cs2pr + + # Without this, vendor/autoload.php refuses to load on the older PHP versions in the matrix. + - name: 'Composer: disable the platform check' + run: composer config platform-check false # Install dependencies and handle caching in one go. # @link https://github.com/marketplace/actions/install-composer-dependencies @@ -50,5 +54,13 @@ jobs: # Bust the cache at least once a month - output format: YYYY-MM-DD. custom-cache-suffix: $(date -u -d "-0 month -$(($(date +%d)-1)) days" "+%F") + - name: Install PHP for the actual lint + uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0 + with: + php-version: ${{ matrix.php_version }} + ini-values: zend.assertions=1, error_reporting=-1, display_errors=On + coverage: none + tools: cs2pr + - name: Lint against parse errors run: composer lint -- --checkstyle | cs2pr diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 494eb58..75f0156 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,6 +25,11 @@ jobs: strategy: matrix: include: + # The lowest PHP version the plugin header declares. + - php_version: '7.4' + wp_version: '6.6' + multisite: false + - php_version: '8.2' wp_version: '6.6' multisite: false @@ -71,13 +76,24 @@ jobs: - name: "Composer: remove the PHP platform requirement" run: composer config --unset platform.php + # The code style and static analysis tools are not needed here and do not install on older PHP versions. + - name: "Composer: remove the dev tools that are not needed for the tests" + run: > + composer remove --dev --no-update --no-scripts --no-interaction + friendsofphp/php-cs-fixer + php-parallel-lint/php-parallel-lint + phpcompatibility/phpcompatibility-wp + phpstan/extension-installer + phpstan/phpstan + szepeviktor/phpstan-wordpress + wp-coding-standards/wpcs + yoast/yoastcs + - name: "Install Composer dependencies" uses: ramsey/composer-install@26d8a556604053a9612623447203a691f406fbe6 # v4 with: - # Force a `composer update` run. + # Force a `composer update` run, so the test tooling matches the PHP version. dependency-versions: "highest" - # But make it selective. - composer-options: "yoast/wp-test-utils --with-dependencies" # Bust the cache at least once a month - output format: YYYY-MM-DD. custom-cache-suffix: $(date -u -d "-0 month -$(($(date +%d)-1)) days" "+%F") diff --git a/composer.json b/composer.json index 0193fef..5f2ab33 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "source": "https://github.com/emilia-capital/comment-hacks" }, "require": { - "php": ">=8.2", + "php": ">=7.4", "composer/installers": "^2.3.0" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 2e4546d..f975f1c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0707b1e9c4640433365f28aba40131c7", + "content-hash": "263f891ba12c6cf03a551de733a5ef8e", "packages": [ { "name": "composer/installers", @@ -6139,7 +6139,7 @@ "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": ">=8.2" + "php": ">=7.4" }, "platform-dev": {}, "platform-overrides": {