Skip to content

Commit 0448842

Browse files
martineibermattamon
authored andcommitted
Add php-stan action.
1 parent 4b81999 commit 0448842

File tree

6 files changed

+114
-1
lines changed

6 files changed

+114
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
mkdir -p var/config
6+
mkdir -p bin
7+
8+
cp .github/ci/files/.env .
9+
cp -r .github/ci/files/config/. config
10+
cp -r .github/ci/files/templates/. templates
11+
cp -r .github/ci/files/bin/console bin/console
12+
chmod 755 bin/console
13+
cp -r .github/ci/files/kernel/. kernel
14+
cp -r .github/ci/files/public/. public

.github/workflows/static-analysis.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: "Static Analysis"
2+
3+
on:
4+
schedule:
5+
- cron: '0 3 * * 1,3,5'
6+
pull_request:
7+
branches:
8+
- "[0-9]+.[0-9]+"
9+
- "[0-9]+.x"
10+
paths-ignore:
11+
- 'doc/**'
12+
- 'public/**'
13+
push:
14+
branches:
15+
- "[0-9]+.[0-9]+"
16+
- "[0-9]+.x"
17+
- "*_actions"
18+
19+
jobs:
20+
static-analysis-phpstan:
21+
name: "Static Analysis with PHPStan"
22+
runs-on: "ubuntu-20.04"
23+
strategy:
24+
matrix:
25+
include:
26+
- { php-version: "8.1", dependencies: "lowest", pimcore_version: "11.x-dev as 11.0.0", phpstan_args: "", experimental: false }
27+
- { php-version: "8.2", dependencies: "highest", pimcore_version: "11.x-dev as 11.0.0", phpstan_args: "", experimental: true }
28+
steps:
29+
- name: "Checkout code"
30+
uses: "actions/checkout@v2"
31+
32+
- name: "Install PHP"
33+
uses: "shivammathur/setup-php@v2"
34+
with:
35+
coverage: "none"
36+
php-version: "${{ matrix.php-version }}"
37+
38+
- name: "Setup Pimcore environment"
39+
run: |
40+
.github/ci/scripts/setup-pimcore-environment.sh
41+
- name: "Update Pimcore version"
42+
env:
43+
PIMCORE_VERSION: "${{ matrix.pimcore_version }}"
44+
run: |
45+
if [ ! -z "$PIMCORE_VERSION" ]; then
46+
composer require --no-update pimcore/pimcore:"${PIMCORE_VERSION}"
47+
fi
48+
- name: "Install dependencies with Composer"
49+
uses: "ramsey/composer-install@v2"
50+
with:
51+
dependency-versions: "${{ matrix.dependencies }}"
52+
53+
- name: "Run a static analysis with phpstan/phpstan"
54+
run: "vendor/bin/phpstan analyse --memory-limit=-1"
55+
56+
- name: "Generate baseline file"
57+
if: ${{ failure() }}
58+
run: "vendor/bin/phpstan analyse --memory-limit=-1 --generate-baseline"
59+
60+
- name: "Upload baseline file"
61+
if: ${{ failure() }}
62+
uses: actions/upload-artifact@v2
63+
with:
64+
name: phpstan-baseline.neon
65+
path: phpstan-baseline.neon

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"codeception/module-asserts": "^2",
2020
"codeception/module-symfony": "^1.6.0 || ^3.1.0",
2121
"codeception/phpunit-wrapper": "^9",
22-
"phpstan/phpstan": "^1.2",
22+
"phpstan/phpstan": "1.10.5",
23+
"phpstan/phpstan-symfony": "^1.2.20",
2324
"phpunit/phpunit": "^9.3"
2425
},
2526
"autoload": {

phpstan-baseline.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
parameters:
2+
ignoreErrors:

phpstan-bootstrap.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
4+
define('PIMCORE_PROJECT_ROOT', __DIR__);
5+
} elseif (file_exists(__DIR__ . '/../../../vendor/autoload.php')) {
6+
define('PIMCORE_PROJECT_ROOT', __DIR__ . '/../../..');
7+
} elseif (getenv('PIMCORE_PROJECT_ROOT')) {
8+
define('PIMCORE_PROJECT_ROOT', getenv('PIMCORE_PROJECT_ROOT'));
9+
} else {
10+
throw new \Exception('Unknown configuration! Pimcore project root not found, please set env variable PIMCORE_PROJECT_ROOT.');
11+
}
12+
13+
include PIMCORE_PROJECT_ROOT . '/vendor/autoload.php';
14+
\Pimcore\Bootstrap::setProjectRoot();
15+
\Pimcore\Bootstrap::bootstrap();
16+
17+
if (!defined('PIMCORE_TEST')) {
18+
define('PIMCORE_TEST', true);
19+
}

phpstan.neon

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
parameters:
2+
level: 6
3+
reportUnmatchedIgnoredErrors: false
4+
checkMissingIterableValueType: false
5+
checkGenericClassInNonGenericObjectType: false
6+
paths:
7+
- src
8+
bootstrapFiles:
9+
- phpstan-bootstrap.php
10+
includes:
11+
- vendor/phpstan/phpstan-symfony/extension.neon
12+
- phpstan-baseline.neon

0 commit comments

Comments
 (0)