Skip to content

Commit

Permalink
Add a PHPCompat workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dkotter committed Sep 27, 2024
1 parent 5f957da commit 5a5468b
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 16 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/php-compat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: PHP Compatibility

on:
push:
branches:
- develop
- trunk
paths:
- "**.php"
pull_request:
branches:
- develop
paths:
- "**.php"

jobs:
php-compatibility:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup proper PHP version
uses: shivammathur/setup-php@v2
with:
php-version: 7.4

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

- name: Install dependencies
run: composer install --prefer-dist

- name: Run PHP Compatibility
run: ./vendor/bin/phpcs --standard=./phpcs-compat.xml.dist -p .
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"php-stubs/wp-cli-stubs": "dev-master",
"johnbillion/wp-compat": "dev-trunk",
"phpstan/phpstan-deprecation-rules": "1.2.x-dev",
"sirbrillig/phpcs-changed": "^2.11"
"sirbrillig/phpcs-changed": "^2.11",
"phpcompatibility/php-compatibility": "dev-develop as 9.99.99"
},
"scripts": {
"lint": "phpcs -s . --runtime-set testVersion 7.4-",
Expand Down
66 changes: 51 additions & 15 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions phpcs-compat.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>

Check failure on line 1 in phpcs-compat.xml.dist

View workflow job for this annotation

GitHub Actions / test

application_detected

Application files are not permitted.
<ruleset name="PHPCompatibilityWP">
<description>PHP Compatibility checks only</description>

<!-- Files to check -->
<arg name="extensions" value="php"/>
<file>.</file>

<rule ref="PHPCompatibilityWP" />

<exclude-pattern>*/dist/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>

<config name="minimum_supported_wp_version" value="6.1"/>
<config name="testVersion" value="7.4-"/>
</ruleset>

0 comments on commit 5a5468b

Please sign in to comment.