Skip to content

Commit 1481481

Browse files
committed
feature #1265 Add phpstan to github actions workflow (burned42)
This PR was squashed before being merged into the main branch. Discussion ---------- Add phpstan to github actions workflow Fixes #1260 I tried checking different repos under https://github.com/symfony to see how those solve running phpstan and tried to apply that here. I saw that all the repos seem to install phpstan in the actions workflows instead of adding them to composer.json,so I did that, too. Also it seems like all of the projects I checked out are using the phpstan level 5, so that's what I was using. What I also found out is that most of them configured phpstan to use some phpunit autoload file, that's also why phpunit has to be installed in the workflow before running phpstan. Most of the errors reported with this configuration are probably not that hard to solve, but I didn't want to include any unrelated code changes here, so I added a baseline file. I can also try to fix them if you think that should be part of this PR. I think adding phpstan to the lint workflow sounds right, but I wasn't too sure if phpstan should be added to the 'linters' job or if it should get its own job. I decided to add it to the existing one to avoid having to duplicate all the composer/php setup steps into another job. I hope that's something like what you expected to see regarding running phpstan for this project :) Commits ------- 30a6fd9 Add phpstan to github actions workflow
2 parents c109bb5 + 30a6fd9 commit 1481481

File tree

4 files changed

+717
-3
lines changed

4 files changed

+717
-3
lines changed

.github/workflows/lint.yaml

+9-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
coverage: "none"
4040
extensions: intl
4141
php-version: ${{ matrix.php-version }}
42-
tools: composer:v2
42+
tools: composer:v2, phpstan
4343

4444
- name: "Set composer cache directory"
4545
id: composer-cache
@@ -53,9 +53,12 @@ jobs:
5353
restore-keys: ${{ runner.os }}-${{ matrix.php-version }}-composer-
5454

5555
- name: "Composer install"
56-
id: install
5756
run: composer install --no-interaction --no-progress
5857

58+
- name: Install PHPUnit
59+
id: install
60+
run: vendor/bin/simple-phpunit install
61+
5962
- name: Lint YAML files
6063
if: always() && steps.install.outcome == 'success'
6164
run: ./bin/console lint:yaml config --parse-tags
@@ -87,3 +90,7 @@ jobs:
8790
- name: Check if any dependencies are compromised
8891
if: always() && steps.install.outcome == 'success'
8992
run: /home/runner/.symfony/bin/symfony check:security
93+
94+
- name: Run PHPStan
95+
if: always() && steps.install.outcome == 'success'
96+
run: phpstan analyze

0 commit comments

Comments
 (0)