Skip to content

Commit

Permalink
Merge pull request #432 from lptn/psalm-on-ci
Browse files Browse the repository at this point in the history
Add Psalm to project and CI
  • Loading branch information
toonvandenbos authored Jun 27, 2023
2 parents bee5558 + 3dd384d commit 87835f2
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 1 deletion.
45 changes: 45 additions & 0 deletions .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Psalm

on:
workflow_dispatch:
push:
paths:
- '**.php'
- 'composer*'
- 'psalm*'

jobs:
psalm:
name: Psalm
runs-on: ubuntu-latest
timeout-minutes: 6
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}

# mtime needs to be restored for Psalm cache to work correctly
- name: Restore mtimes
uses: chetan/git-restore-mtime-action@v1

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
coverage: none

- name: Install composer dependencies
run: |
composer config --ansi -- http-basic.nova.laravel.com ${{ secrets.NOVA_USERNAME }} ${{ secrets.NOVA_LICENSE_KEY }}
composer install --no-interaction --no-progress --no-scripts
# the way cache keys are set up will always cause a cache miss
# but will restore the cache generated during the previous run based on partial match
- name: Retrieve Psalm’s cache
uses: actions/cache@v3
with:
path: ./cache/psalm
key: ${{ runner.os }}-psalm-cache-${{ hashFiles('psalm.xml', 'psalm-baseline.xml', './composer.json') }}

- name: Run Psalm
run: ./vendor/bin/psalm --find-unused-psalm-suppress --output-format=github
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require-dev": {
"laravel/pint": "^1.2",
"phpunit/phpunit": "^9.5",
"laravel/pint": "^1.2"
"psalm/plugin-laravel": "^2.0"
},
"scripts": {
"psalm": "psalm --find-unused-psalm-suppress --output-format=phpstorm",
"psalm-update-baseline": "psalm --set-baseline=psalm-baseline.xml",
"test": "phpunit --colors=always tests",
"fix-style": "./vendor/bin/pint"
}
Expand Down
29 changes: 29 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.6.0@e784128902dfe01d489c4123d69918a9f3c1eac5">
<file src="src/FileAdder/FileAdder.php">
<UndefinedClass>
<code>OriginalFileAdder</code>
</UndefinedClass>
</file>
<file src="src/FileAdder/FileAdderFactory.php">
<UndefinedClass>
<code>OriginalFileAdderFactory</code>
</UndefinedClass>
</file>
<file src="src/Flexible.php">
<UndefinedClass>
<code>$model</code>
<code>\Whitecube\NovaPage\Pages\Template</code>
</UndefinedClass>
</file>
<file src="src/Layouts/Collection.php">
<UnimplementedInterfaceMethod>
<code>Collection</code>
</UnimplementedInterfaceMethod>
</file>
<file src="src/Layouts/Layout.php">
<UndefinedTrait>
<code>HasAttributes</code>
</UndefinedTrait>
</file>
</files>
20 changes: 20 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<psalm
errorLevel="7"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedBaselineEntry="true"
errorBaseline="psalm-baseline.xml"
>
<projectFiles>
<directory name="src"/>
<ignoreFiles>
<directory name="vendor"/>
</ignoreFiles>
</projectFiles>
<plugins>
<pluginClass class="Psalm\LaravelPlugin\Plugin"/>
</plugins>
</psalm>

0 comments on commit 87835f2

Please sign in to comment.