-
Notifications
You must be signed in to change notification settings - Fork 13
63 lines (55 loc) · 1.73 KB
/
Lint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Lint
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.4', '8.0', '8.1', '8.2', '8.3']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2, cs2pr
- name: Lint
run: |
error=0
for file in $(find upload -type f -name "*.php" ! -path 'upload/system/storage/vendor/*'); do
php -l -n $file | grep -v "No syntax errors detected" && error=1
done
if [ $error -eq 1 ]; then
echo "Syntax errors were found."
exit 1
else
echo "No syntax errors were detected."
fi
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cache/composer/files
./.cache
./.php-cs-fixer.cache
key: ${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ matrix.php }}-
- name: PHPStan
run: |
composer require --dev phpstan/phpstan 1.11.3
./upload/system/storage/vendor/bin/phpstan analyze --no-progress
- name: Code style
if: matrix.php == '8.3'
run: |
composer require --dev friendsofphp/php-cs-fixer v3.58.1
./upload/system/storage/vendor/bin/php-cs-fixer fix --dry-run --diff --ansi || true
./upload/system/storage/vendor/bin/php-cs-fixer fix --dry-run --format=checkstyle | cs2pr