Skip to content

Commit ca79bcc

Browse files
committed
Add Psalm on errorLevel=1
1 parent 8e97a20 commit ca79bcc

File tree

4 files changed

+436
-1
lines changed

4 files changed

+436
-1
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Static Analysis
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- '**.php'
8+
- 'composer.lock'
9+
- 'psalm*'
10+
11+
jobs:
12+
psalm:
13+
name: Psalm
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 6
16+
steps:
17+
- uses: actions/checkout@v3
18+
with:
19+
ref: ${{ github.head_ref }}
20+
21+
# mtime needs to be restored for Psalm cache to work correctly
22+
- name: Restore mtimes
23+
uses: chetan/git-restore-mtime-action@v1
24+
25+
- name: Setup PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: 8.2
29+
coverage: none
30+
31+
- name: Get Composer cache directory
32+
id: composer-cache
33+
run: |
34+
echo "composer_dir={$(composer config cache-files-dir)}" >> $GITHUB_OUTPUT
35+
36+
- name: Retrieve Composer‘s cache
37+
uses: actions/cache@v3
38+
with:
39+
path: ${{ steps.composer-cache.outputs.composer_dir }}
40+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
41+
restore-keys: |
42+
${{ runner.os }}-composer-
43+
44+
- name: Install composer dependencies
45+
run: "composer install --no-interaction --no-progress --no-scripts"
46+
47+
# the way cache keys are set up will always cause a cache miss
48+
# but will restore the cache generated during the previous run based on partial match
49+
- name: Retrieve Psalm’s cache
50+
uses: actions/cache@v3
51+
with:
52+
path: ./cache/psalm
53+
key: ${{ runner.os }}-psalm-cache-${{ hashFiles('psalm.xml.dist', 'psalm-baseline.xml', './composer.lock') }}
54+
55+
- name: Run Psalm
56+
run: ./vendor/bin/psalm --find-unused-psalm-suppress --output-format=github --shepherd

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"geoip2/geoip2": "~2.1",
2828
"vlucas/phpdotenv": "^5.0",
2929
"phpstan/phpstan": "^1.2",
30-
"squizlabs/php_codesniffer": "^3.6"
30+
"squizlabs/php_codesniffer": "^3.6",
31+
"vimeo/psalm": "^5.7"
3132
},
3233
"autoload": {
3334
"files": [

0 commit comments

Comments
 (0)