From 90e2be2348fecf5213fdb462ccc08a6657794fa3 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Tue, 9 Apr 2024 10:52:01 +0200 Subject: [PATCH] php: Split phpstan tests into a separate workflow --- .github/workflows/php.yml | 15 +++------------ .github/workflows/phpstan.yml | 16 ++++++++++++++++ phpstan-baseline.neon | 25 +++++-------------------- phpstan.neon | 4 +++- 4 files changed, 27 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/phpstan.yml diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index e6e24170..c7806ef2 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -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 @@ -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() }} @@ -45,7 +40,3 @@ jobs: - name: PHP CodeSniffer if: ${{ ! cancelled() }} run: phpcs -wps --colors - - - name: PHPStan - if: ${{ ! cancelled() }} - uses: php-actions/phpstan@v3 diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 00000000..c82d48a1 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -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" + } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 60e4201a..1923f08f 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -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 @@ -385,6 +380,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 @@ -705,21 +705,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 @@ -745,11 +735,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 diff --git a/phpstan.neon b/phpstan.neon index 78a9dccb..c129242c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -13,7 +13,9 @@ parameters: - library scanDirectories: - - vendor + - /icingaweb2 + - /usr/share/icinga-php + - /usr/share/icingaweb2-modules ignoreErrors: -