Skip to content

Commit 84a0bd5

Browse files
committed
👷 Add GitHub workflow for linting and code validation
1 parent 289d8aa commit 84a0bd5

2 files changed

Lines changed: 121 additions & 0 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
name: Code Lint
3+
4+
on:
5+
push:
6+
7+
jobs:
8+
php-cs-fixer:
9+
name: PHP CS Fixer
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Setup PHP
17+
uses: shivammathur/setup-php@v2
18+
with:
19+
php-version: '8.2'
20+
extensions: mbstring, intl
21+
coverage: none
22+
tools: php-cs-fixer
23+
24+
- name: Cache Composer packages
25+
id: composer-cache
26+
uses: actions/cache@v4
27+
with:
28+
path: vendor
29+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
30+
restore-keys: |
31+
${{ runner.os }}-php-
32+
33+
- name: Install dependencies
34+
run: composer install --prefer-dist --no-progress --no-dev
35+
36+
- name: Cache PHP CS Fixer
37+
uses: actions/cache@v4
38+
with:
39+
path: .php-cs-fixer.cache
40+
key: ${{ runner.os }}-php-cs-fixer-${{ hashFiles('.php-cs-fixer.dist.php') }}
41+
restore-keys: |
42+
${{ runner.os }}-php-cs-fixer-
43+
44+
- name: Run PHP CS Fixer (dry-run)
45+
shell: /usr/bin/bash -e {0}
46+
env:
47+
COMPOSER_PROCESS_TIMEOUT: 0
48+
COMPOSER_NO_INTERACTION: 1
49+
COMPOSER_NO_AUDIT: 1
50+
run: php-cs-fixer fix --dry-run --diff --verbose
51+
52+
- name: Upload PHP CS Fixer results
53+
if: failure()
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: php-cs-fixer-results
57+
path: .php-cs-fixer.cache
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
name: Code Validation
3+
4+
on:
5+
push:
6+
7+
jobs:
8+
phpstan:
9+
name: PHPStan
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
matrix:
14+
php-version: ['7.4','8.0', '8.1', '8.2', '8.3']
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Setup PHP ${{ matrix.php-version }}
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php-version }}
24+
extensions: mbstring, intl
25+
coverage: none
26+
tools: phpstan
27+
28+
- name: Cache Composer packages
29+
id: composer-cache
30+
uses: actions/cache@v4
31+
with:
32+
path: vendor
33+
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
34+
restore-keys: |
35+
${{ runner.os }}-php-${{ matrix.php-version }}-
36+
37+
- name: Install dependencies
38+
run: composer install --prefer-dist --no-progress
39+
40+
- name: Cache PHPStan results
41+
uses: actions/cache@v4
42+
with:
43+
path: /tmp/phpstan
44+
key: ${{ runner.os }}-phpstan-${{ matrix.php-version }}-${{ hashFiles('phpstan.neon*') }}-${{ hashFiles('**/*.php') }}
45+
restore-keys: |
46+
${{ runner.os }}-phpstan-${{ matrix.php-version }}-${{ hashFiles('phpstan.neon*') }}-
47+
${{ runner.os }}-phpstan-${{ matrix.php-version }}-
48+
49+
- name: Run PHPStan
50+
run: |
51+
if [ -f "phpstan.neon" ] || [ -f "phpstan.neon.dist" ]; then
52+
vendor/bin/phpstan analyse --memory-limit=1G
53+
else
54+
vendor/bin/phpstan analyse src tests --memory-limit=1G
55+
fi
56+
57+
- name: Upload PHPStan results
58+
if: failure()
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: phpstan-results-php-${{ matrix.php-version }}
62+
path: |
63+
phpstan-report.json
64+
/tmp/phpstan

0 commit comments

Comments
 (0)