Skip to content

Commit

Permalink
php: Split phpstan tests into a separate workflow (#325)
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhwinder33445 authored Apr 9, 2024
2 parents 5e0d57c + f806671 commit 2f675e7
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 54 deletions.
15 changes: 3 additions & 12 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
os: ['ubuntu-latest']

steps:
- name: Checkout code base
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -31,12 +31,7 @@ jobs:
tools: phpcs

- name: Setup dependencies
run: |
composer require -n --no-progress overtrue/phplint
git clone --depth 1 https://github.com/Icinga/icingaweb2.git vendor/icingaweb2
git clone --depth 1 https://github.com/Icinga/icingadb-web.git vendor/icingadb-web
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-library.git vendor/icinga-php-library
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git vendor/icinga-php-thirdparty
run: composer require -n --no-progress overtrue/phplint

- name: PHP Lint
if: ${{ ! cancelled() }}
Expand All @@ -45,7 +40,3 @@ jobs:
- name: PHP CodeSniffer
if: ${{ ! cancelled() }}
run: phpcs -wps --colors

- name: PHPStan
if: ${{ ! cancelled() }}
uses: php-actions/phpstan@v3
16 changes: 16 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: PHPStan

on:
pull_request:
branches:
- main

jobs:
phpstan:
uses: icinga/github-actions/.github/workflows/phpstan.yml@main
with:
dependencies: |
{
"/icingaweb2" : "https://github.com/Icinga/icingaweb2.git",
"/usr/share/icingaweb2-modules/icingadb" : "https://github.com/Icinga/icingadb-web.git"
}
36 changes: 36 additions & 0 deletions phpstan-baseline-7x.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$str of function urldecode expects string, mixed given\\.$#"
count: 1
path: application/controllers/HostsController.php

-
message: "#^Parameter \\#1 \\$str of function urldecode expects string, mixed given\\.$#"
count: 1
path: application/controllers/ServicesController.php

-
message: "#^Argument of an invalid type array\\<int, string\\>\\|false supplied for foreach, only iterables are supported\\.$#"
count: 1
path: library/Graphite/Util/MacroTemplate.php

-
message: "#^Cannot access offset int on non\\-empty\\-array\\<int, string\\>\\|false\\.$#"
count: 1
path: library/Graphite/Util/MacroTemplate.php

-
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, array\\<int, string\\>\\|false given\\.$#"
count: 1
path: library/Graphite/Util/MacroTemplate.php

-
message: "#^Property Icinga\\\\Module\\\\Graphite\\\\Util\\\\MacroTemplate\\:\\:\\$template \\(array\\<string\\>\\) does not accept array\\<int, string\\>\\|false\\.$#"
count: 1
path: library/Graphite/Util/MacroTemplate.php

-
message: "#^Parameter \\#1 \\$str of function strtolower expects string, mixed given\\.$#"
count: 1
path: library/Graphite/Web/Controller/MonitoringAwareController.php
21 changes: 21 additions & 0 deletions phpstan-baseline-8x.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$string of function urldecode expects string, mixed given\\.$#"
count: 1
path: application/controllers/HostsController.php

-
message: "#^Parameter \\#1 \\$string of function urldecode expects string, mixed given\\.$#"
count: 1
path: application/controllers/ServicesController.php

-
message: "#^Parameter \\#1 \\$separator of function explode expects non\\-empty\\-string, string given\\.$#"
count: 1
path: library/Graphite/Util/MacroTemplate.php

-
message: "#^Parameter \\#1 \\$string of function strtolower expects string, mixed given\\.$#"
count: 1
path: library/Graphite/Web/Controller/MonitoringAwareController.php
12 changes: 12 additions & 0 deletions phpstan-baseline-by-php-version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

$includes = [];
if (PHP_VERSION_ID < 80000) {
$includes[] = __DIR__ . '/phpstan-baseline-7x.neon';
} else {
$includes[] = __DIR__ . '/phpstan-baseline-8x.neon';
}

return [
'includes' => $includes
];
45 changes: 5 additions & 40 deletions phpstan-baseline.neon → phpstan-baseline-standard.neon
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ parameters:
count: 1
path: application/controllers/GraphController.php

-
message: "#^Parameter \\#2 \\$checkCommand of method Icinga\\\\Module\\\\Graphite\\\\Controllers\\\\GraphController\\:\\:supplyImage\\(\\) expects string, mixed given\\.$#"
count: 2
path: application/controllers/GraphController.php

-
message: "#^Parameter \\#2 \\$value of static method ipl\\\\Stdlib\\\\Filter\\:\\:equal\\(\\) expects array\\|bool\\|float\\|int\\|string, mixed given\\.$#"
count: 3
Expand Down Expand Up @@ -85,11 +80,6 @@ parameters:
count: 1
path: application/controllers/HostsController.php

-
message: "#^Parameter \\#1 \\$string of function urldecode expects string, mixed given\\.$#"
count: 1
path: application/controllers/HostsController.php

-
message: "#^Parameter \\#2 \\$value of static method ipl\\\\Stdlib\\\\Filter\\:\\:equal\\(\\) expects array\\|bool\\|float\\|int\\|string, mixed given\\.$#"
count: 1
Expand Down Expand Up @@ -190,11 +180,6 @@ parameters:
count: 1
path: application/controllers/ServicesController.php

-
message: "#^Parameter \\#1 \\$string of function urldecode expects string, mixed given\\.$#"
count: 1
path: application/controllers/ServicesController.php

-
message: "#^Parameter \\#2 \\$value of static method ipl\\\\Stdlib\\\\Filter\\:\\:equal\\(\\) expects array\\|bool\\|float\\|int\\|string, mixed given\\.$#"
count: 1
Expand Down Expand Up @@ -385,6 +370,11 @@ parameters:
count: 1
path: library/Graphite/Graphing/MetricsQuery.php

-
message: "#^Parameter \\#2 \\$object of method Icinga\\\\Module\\\\Graphite\\\\Util\\\\IcingadbUtils\\:\\:resolveMacro\\(\\) expects Icinga\\\\Module\\\\Icingadb\\\\Compat\\\\CompatHost\\|Icinga\\\\Module\\\\Icingadb\\\\Compat\\\\CompatService\\|Icinga\\\\Module\\\\Icingadb\\\\Model\\\\Host\\|Icinga\\\\Module\\\\Icingadb\\\\Model\\\\Service, ipl\\\\Orm\\\\Model given\\.$#"
count: 1
path: library/Graphite/Graphing/MetricsQuery.php

-
message: "#^Call to an undefined method Icinga\\\\Data\\\\Fetchable\\:\\:where\\(\\)\\.$#"
count: 1
Expand Down Expand Up @@ -515,11 +505,6 @@ parameters:
count: 1
path: library/Graphite/Util/InternalProcessTracker.php

-
message: "#^Parameter \\#1 \\$separator of function explode expects non\\-empty\\-string, string given\\.$#"
count: 1
path: library/Graphite/Util/MacroTemplate.php

-
message: "#^Cannot cast mixed to int\\.$#"
count: 2
Expand Down Expand Up @@ -560,11 +545,6 @@ parameters:
count: 1
path: library/Graphite/Web/Controller/MonitoringAwareController.php

-
message: "#^Parameter \\#1 \\$string of function strtolower expects string, mixed given\\.$#"
count: 1
path: library/Graphite/Web/Controller/MonitoringAwareController.php

-
message: "#^Parameter \\#1 \\$value of method Icinga\\\\Module\\\\Graphite\\\\Web\\\\Form\\\\Validator\\\\CustomErrorMessagesValidator\\:\\:validate\\(\\) expects string, mixed given\\.$#"
count: 1
Expand Down Expand Up @@ -705,21 +685,11 @@ parameters:
count: 1
path: library/Graphite/Web/Widget/Graphs/Icingadb/IcingadbHost.php

-
message: "#^Method Icinga\\\\Module\\\\Graphite\\\\Web\\\\Widget\\\\Graphs\\\\Icingadb\\\\IcingadbHost\\:\\:getMonitoredObjectIdentifier\\(\\) should return string but returns mixed\\.$#"
count: 1
path: library/Graphite/Web/Widget/Graphs/Icingadb/IcingadbHost.php

-
message: "#^Method Icinga\\\\Module\\\\Graphite\\\\Web\\\\Widget\\\\Graphs\\\\Icingadb\\\\IcingadbHost\\:\\:getObjectType\\(\\) has no return type specified\\.$#"
count: 1
path: library/Graphite/Web/Widget/Graphs/Icingadb/IcingadbHost.php

-
message: "#^Parameter \\#2 \\$value of method Icinga\\\\Web\\\\Url\\:\\:setParam\\(\\) expects array\\|bool\\|string, mixed given\\.$#"
count: 1
path: library/Graphite/Web/Widget/Graphs/Icingadb/IcingadbHost.php

-
message: "#^Cannot access property \\$name on mixed\\.$#"
count: 4
Expand All @@ -745,11 +715,6 @@ parameters:
count: 1
path: library/Graphite/Web/Widget/Graphs/Icingadb/IcingadbService.php

-
message: "#^Parameter \\#2 \\$value of method Icinga\\\\Web\\\\Url\\:\\:setParam\\(\\) expects array\\|bool\\|string, mixed given\\.$#"
count: 1
path: library/Graphite/Web/Widget/Graphs/Icingadb/IcingadbService.php

-
message: "#^Call to an undefined method Icinga\\\\Module\\\\Graphite\\\\Web\\\\Widget\\\\Graphs\\\\Icingadb\\\\IcingadbHost\\|Icinga\\\\Module\\\\Graphite\\\\Web\\\\Widget\\\\Graphs\\\\Icingadb\\\\IcingadbService\\:\\:createServiceTitle\\(\\)\\.$#"
count: 1
Expand Down
7 changes: 5 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
includes:
- phpstan-baseline.neon
- phpstan-baseline-standard.neon
- phpstan-baseline-by-php-version.php

parameters:
level: max
Expand All @@ -13,7 +14,9 @@ parameters:
- library

scanDirectories:
- vendor
- /icingaweb2
- /usr/share/icinga-php
- /usr/share/icingaweb2-modules

ignoreErrors:
-
Expand Down

0 comments on commit 2f675e7

Please sign in to comment.