Skip to content

Commit 9b45519

Browse files
committed
Add github action for static analysis code
1 parent cac6206 commit 9b45519

1 file changed

Lines changed: 87 additions & 0 deletions

File tree

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: "Static analysis code"
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
env:
8+
COMPOSER_FLAGS: "--ansi --prefer-dist --no-interaction --no-progress"
9+
10+
jobs:
11+
12+
## PHP linter
13+
linter:
14+
name: "Check syntax errors"
15+
16+
runs-on: ubuntu-latest
17+
18+
strategy:
19+
matrix:
20+
php-version:
21+
- "7.2"
22+
- "7.3"
23+
- "7.4"
24+
25+
steps:
26+
- name: "Checkout"
27+
uses: "actions/checkout@v2"
28+
29+
- name: "Install PHP"
30+
uses: "shivammathur/setup-php@v2"
31+
with:
32+
coverage: "none"
33+
php-version: ${{ matrix.php-version }}
34+
35+
- name: "Lint PHP files"
36+
run: find ./src -type f -name '*.php' -print0 | xargs -0 -L1 -P4 -- php -l -f
37+
38+
## PHPSTAN
39+
phpstan:
40+
name: "PHP Static Analysis"
41+
42+
runs-on: ubuntu-latest
43+
44+
strategy:
45+
matrix:
46+
php-version:
47+
- "7.2"
48+
- "7.3"
49+
- "7.4"
50+
steps:
51+
- name: "Cancel Previous Runs"
52+
uses: styfle/cancel-workflow-action@0.9.0
53+
with:
54+
all_but_latest: true
55+
access_token: ${{ github.token }}
56+
57+
- name: "Checkout"
58+
uses: "actions/checkout@v2"
59+
60+
- name: "Install PHP"
61+
uses: "shivammathur/setup-php@v2"
62+
with:
63+
coverage: "none"
64+
php-version: ${{ matrix.php-version }}
65+
66+
- name: "Setup github auth token for composer"
67+
run: composer config github-oauth.github.com ${{ github.token }}
68+
69+
- name: "Get composer cache directory"
70+
id: composer-cache
71+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
72+
73+
- name: "Cache Composer Directory"
74+
uses: actions/cache@v2
75+
with:
76+
path: ${{ steps.composer-cache.outputs.dir }}
77+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
78+
restore-keys: ${{ runner.os }}-composer-
79+
80+
- name: "Composer Install"
81+
run: |
82+
composer install ${{ env.COMPOSER_FLAGS }}
83+
rm composer.lock
84+
composer config platform.php ${{ matrix.php }}
85+
86+
- name: Run phpstan
87+
run: composer phpstan

0 commit comments

Comments
 (0)