From 996cce473f63647d13f377e0ae07b9405bd34730 Mon Sep 17 00:00:00 2001 From: Alies Lapatsin Date: Tue, 24 Jan 2023 12:17:22 +0100 Subject: [PATCH] Add Psalm to project and CI --- .github/workflows/psalm.yml | 45 +++++++++++++++++++++++++++++++++++++ composer.json | 5 ++++- psalm-baseline.xml | 29 ++++++++++++++++++++++++ psalm.xml | 20 +++++++++++++++++ 4 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/psalm.yml create mode 100644 psalm-baseline.xml create mode 100644 psalm.xml diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml new file mode 100644 index 00000000..f8f4af2b --- /dev/null +++ b/.github/workflows/psalm.yml @@ -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 diff --git a/composer.json b/composer.json index 8fc2c2dc..971d531e 100644 --- a/composer.json +++ b/composer.json @@ -52,10 +52,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" } diff --git a/psalm-baseline.xml b/psalm-baseline.xml new file mode 100644 index 00000000..c322567d --- /dev/null +++ b/psalm-baseline.xml @@ -0,0 +1,29 @@ + + + + + OriginalFileAdder + + + + + OriginalFileAdderFactory + + + + + $model + \Whitecube\NovaPage\Pages\Template + + + + + Collection + + + + + HasAttributes + + + diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 00000000..d5854603 --- /dev/null +++ b/psalm.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + +