Skip to content

Commit 996cce4

Browse files
committed
Add Psalm to project and CI
1 parent 246519e commit 996cce4

File tree

4 files changed

+98
-1
lines changed

4 files changed

+98
-1
lines changed

.github/workflows/psalm.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Psalm
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- '**.php'
8+
- 'composer*'
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.1
29+
coverage: none
30+
31+
- name: Install composer dependencies
32+
run: |
33+
composer config --ansi -- http-basic.nova.laravel.com ${{ secrets.NOVA_USERNAME }} ${{ secrets.NOVA_LICENSE_KEY }}
34+
composer install --no-interaction --no-progress --no-scripts
35+
36+
# the way cache keys are set up will always cause a cache miss
37+
# but will restore the cache generated during the previous run based on partial match
38+
- name: Retrieve Psalm’s cache
39+
uses: actions/cache@v3
40+
with:
41+
path: ./cache/psalm
42+
key: ${{ runner.os }}-psalm-cache-${{ hashFiles('psalm.xml', 'psalm-baseline.xml', './composer.json') }}
43+
44+
- name: Run Psalm
45+
run: ./vendor/bin/psalm --find-unused-psalm-suppress --output-format=github

composer.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,13 @@
5252
"minimum-stability": "dev",
5353
"prefer-stable": true,
5454
"require-dev": {
55+
"laravel/pint": "^1.2",
5556
"phpunit/phpunit": "^9.5",
56-
"laravel/pint": "^1.2"
57+
"psalm/plugin-laravel": "^2.0"
5758
},
5859
"scripts": {
60+
"psalm": "psalm --find-unused-psalm-suppress --output-format=phpstorm",
61+
"psalm-update-baseline": "psalm --set-baseline=psalm-baseline.xml",
5962
"test": "phpunit --colors=always tests",
6063
"fix-style": "./vendor/bin/pint"
6164
}

psalm-baseline.xml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<files psalm-version="5.6.0@e784128902dfe01d489c4123d69918a9f3c1eac5">
3+
<file src="src/FileAdder/FileAdder.php">
4+
<UndefinedClass>
5+
<code>OriginalFileAdder</code>
6+
</UndefinedClass>
7+
</file>
8+
<file src="src/FileAdder/FileAdderFactory.php">
9+
<UndefinedClass>
10+
<code>OriginalFileAdderFactory</code>
11+
</UndefinedClass>
12+
</file>
13+
<file src="src/Flexible.php">
14+
<UndefinedClass>
15+
<code>$model</code>
16+
<code>\Whitecube\NovaPage\Pages\Template</code>
17+
</UndefinedClass>
18+
</file>
19+
<file src="src/Layouts/Collection.php">
20+
<UnimplementedInterfaceMethod>
21+
<code>Collection</code>
22+
</UnimplementedInterfaceMethod>
23+
</file>
24+
<file src="src/Layouts/Layout.php">
25+
<UndefinedTrait>
26+
<code>HasAttributes</code>
27+
</UndefinedTrait>
28+
</file>
29+
</files>

psalm.xml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="7"
4+
resolveFromConfigFile="true"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xmlns="https://getpsalm.org/schema/config"
7+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
8+
findUnusedBaselineEntry="true"
9+
errorBaseline="psalm-baseline.xml"
10+
>
11+
<projectFiles>
12+
<directory name="src"/>
13+
<ignoreFiles>
14+
<directory name="vendor"/>
15+
</ignoreFiles>
16+
</projectFiles>
17+
<plugins>
18+
<pluginClass class="Psalm\LaravelPlugin\Plugin"/>
19+
</plugins>
20+
</psalm>

0 commit comments

Comments
 (0)