Skip to content

Commit 193b9a8

Browse files
committed
ci: add PHP CS Fixer workflow with matrix support
- Create separate workflow for code style checks - Use matrix strategy for both PHPStan and Code Style workflows - Display PHP version in job names for better visibility - Enable caching for PHP CS Fixer results - Run CS Fixer in dry-run mode to prevent auto-fixes in CI
1 parent a596711 commit 193b9a8

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

.github/workflows/code-style.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Code Style
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
php-cs-fixer:
11+
name: PHP CS Fixer (PHP ${{ matrix.php-version }})
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
php-version: ['8.4']
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php-version }}
25+
coverage: none
26+
27+
- name: Cache Composer packages
28+
uses: actions/cache@v3
29+
with:
30+
path: vendor
31+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
32+
restore-keys: |
33+
${{ runner.os }}-php-
34+
35+
- name: Install dependencies
36+
run: composer install --prefer-dist --no-progress
37+
38+
- name: Cache PHP CS Fixer
39+
uses: actions/cache@v3
40+
with:
41+
path: .php-cs-fixer.cache
42+
key: ${{ runner.os }}-php-cs-fixer-${{ hashFiles('**/.php-cs-fixer.dist.php') }}
43+
restore-keys: |
44+
${{ runner.os }}-php-cs-fixer-
45+
46+
- name: Run PHP CS Fixer
47+
run: composer cs-check
48+
49+
- name: Show diff on failure
50+
if: failure()
51+
run: composer cs-fix -- --diff --dry-run

.github/workflows/phpstan.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88

99
jobs:
1010
phpstan:
11+
name: Static Analysis (PHP ${{ matrix.php-version }})
1112
runs-on: ubuntu-latest
1213

1314
strategy:

0 commit comments

Comments
 (0)