Skip to content

Commit 1949454

Browse files
authored
Fix CI: multi-PHP testing and PHPCS linting (#1020)
* test: bump minimum PHP to 7.4 to exercise CI * fix: support multi-PHP testing in CI * fix: use phpcs-changed to lint only modified lines
1 parent 1eeda4d commit 1949454

7 files changed

Lines changed: 128 additions & 5 deletions

File tree

.github/workflows/linting.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,18 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
1416
- uses: shivammathur/setup-php@v2
1517
with:
1618
php-version: '8.4'
1719
tools: composer
1820
coverage: none
1921
- run: composer install --no-progress
20-
- run: vendor/bin/phpcs
22+
- name: Run PHPCS (changed lines only)
23+
run: |
24+
if [ "${{ github.event_name }}" = "pull_request" ]; then
25+
vendor/bin/phpcs-changed --git --git-base "${{ github.event.pull_request.base.sha }}"
26+
else
27+
vendor/bin/phpcs-changed --git --git-base "${{ github.event.before }}"
28+
fi

.github/workflows/php-tests.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,13 @@ jobs:
2020
php-version: ${{ matrix.php }}
2121
tools: composer
2222
coverage: none
23-
- run: composer install --no-progress
23+
- name: Install dependencies
24+
run: |
25+
if composer install --no-progress 2>&1; then
26+
echo "Updating PHPUnit for best match with PHP ${{ matrix.php }}"
27+
composer update -W --no-progress phpunit/phpunit
28+
else
29+
echo "Platform reqs failed, running composer update for dev dependencies"
30+
composer update --no-progress
31+
fi
2432
- run: composer test-php

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"phan/phan": "^5.4",
1111
"php-stubs/wordpress-stubs": "^6.8",
1212
"php-stubs/wp-cli-stubs": "^2.10",
13-
"automattic/jetpack-codesniffer": "^4.0"
13+
"automattic/jetpack-codesniffer": "^4.0",
14+
"sirbrillig/phpcs-changed": "^2.11"
1415
},
1516
"autoload": {
1617
"classmap": [

composer.lock

Lines changed: 55 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpunit.11.xml.dist

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="tests/php/bootstrap.php"
5+
cacheDirectory=".phpunit.cache"
6+
colors="true"
7+
executionOrder="depends"
8+
beStrictAboutOutputDuringTests="true"
9+
displayDetailsOnPhpunitDeprecations="true"
10+
displayDetailsOnTestsThatTriggerDeprecations="true"
11+
displayDetailsOnTestsThatTriggerErrors="true"
12+
displayDetailsOnTestsThatTriggerNotices="true"
13+
displayDetailsOnTestsThatTriggerWarnings="true"
14+
failOnDeprecation="true"
15+
failOnEmptyTestSuite="true"
16+
failOnPhpunitDeprecation="true"
17+
failOnNotice="true"
18+
failOnRisky="true"
19+
failOnWarning="true"
20+
>
21+
<testsuites>
22+
<testsuite name="main">
23+
<directory suffix="Test.php">tests/php</directory>
24+
</testsuite>
25+
</testsuites>
26+
</phpunit>

phpunit.12.xml.dist

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="tests/php/bootstrap.php"
5+
cacheDirectory=".phpunit.cache"
6+
colors="true"
7+
executionOrder="depends"
8+
beStrictAboutOutputDuringTests="true"
9+
displayDetailsOnPhpunitDeprecations="true"
10+
displayDetailsOnTestsThatTriggerDeprecations="true"
11+
displayDetailsOnTestsThatTriggerErrors="true"
12+
displayDetailsOnTestsThatTriggerNotices="true"
13+
displayDetailsOnTestsThatTriggerWarnings="true"
14+
failOnDeprecation="true"
15+
failOnEmptyTestSuite="true"
16+
failOnPhpunitDeprecation="true"
17+
failOnNotice="true"
18+
failOnRisky="true"
19+
failOnWarning="true"
20+
>
21+
<testsuites>
22+
<testsuite name="main">
23+
<directory suffix="Test.php">tests/php</directory>
24+
</testsuite>
25+
</testsuites>
26+
</phpunit>

readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Contributors: donncha, automattic, adnan007, dilirity, mikemayhem3030, pyronaur, thingalon
33
Tags: performance, caching, wp-cache, wp-super-cache, cache
44
Requires at least: 6.8
5-
Requires PHP: 7.2
5+
Requires PHP: 7.4
66
Tested up to: 6.9
77
Stable tag: 3.0.3
88
License: GPLv2 or later

0 commit comments

Comments
 (0)