From 8ed4f94988a9c6dd11a3504302dbea3309bde524 Mon Sep 17 00:00:00 2001 From: "Roland Franssen :)" Date: Fri, 30 Jun 2023 21:45:11 +0200 Subject: [PATCH 01/12] Infer output format from GITHUB_ACTIONS env aka --output-format=github --- src/Psalm/Internal/Cli/Psalm.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Psalm/Internal/Cli/Psalm.php b/src/Psalm/Internal/Cli/Psalm.php index c9473b30eb7..89a86dd4efa 100644 --- a/src/Psalm/Internal/Cli/Psalm.php +++ b/src/Psalm/Internal/Cli/Psalm.php @@ -416,6 +416,10 @@ private static function findDefaultOutputFormat(): string return Report::TYPE_PHP_STORM; } + if ('true' === getenv('GITHUB_ACTIONS')) { + return Report::TYPE_GITHUB_ACTIONS; + } + return Report::TYPE_CONSOLE; } From 7cf87b28dc2296104e654c1889beb2eaf2a02592 Mon Sep 17 00:00:00 2001 From: "Roland Franssen :)" Date: Sat, 1 Jul 2023 13:28:05 +0200 Subject: [PATCH 02/12] Update PsalmRunnerTrait.php --- tests/EndToEnd/PsalmRunnerTrait.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/EndToEnd/PsalmRunnerTrait.php b/tests/EndToEnd/PsalmRunnerTrait.php index 14361055364..8edea3c51ed 100644 --- a/tests/EndToEnd/PsalmRunnerTrait.php +++ b/tests/EndToEnd/PsalmRunnerTrait.php @@ -22,6 +22,9 @@ private function runPsalm( bool $shouldFail = false, bool $relyOnConfigDir = true ): array { + // Ensure CI agnostic output + array_unshift($args, '--output-format=console'); + // As config files all contain `resolveFromConfigFile="true"` Psalm // shouldn't need to be run from the same directory that the code being // analysed exists in. From f0e285696398aaf9c8d25ed9ebd0c8f44ca3a195 Mon Sep 17 00:00:00 2001 From: "Roland Franssen :)" Date: Sat, 1 Jul 2023 13:36:42 +0200 Subject: [PATCH 03/12] Update PsalmRunnerTrait.php --- tests/EndToEnd/PsalmRunnerTrait.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/EndToEnd/PsalmRunnerTrait.php b/tests/EndToEnd/PsalmRunnerTrait.php index 8edea3c51ed..87524768e6d 100644 --- a/tests/EndToEnd/PsalmRunnerTrait.php +++ b/tests/EndToEnd/PsalmRunnerTrait.php @@ -23,7 +23,9 @@ private function runPsalm( bool $relyOnConfigDir = true ): array { // Ensure CI agnostic output - array_unshift($args, '--output-format=console'); + if (!in_array('--init', $args, true)) { + array_unshift($args, '--output-format=console'); + } // As config files all contain `resolveFromConfigFile="true"` Psalm // shouldn't need to be run from the same directory that the code being From 06172740cdef50da5337d09d47a55bf093edd5ef Mon Sep 17 00:00:00 2001 From: "Roland Franssen :)" Date: Sat, 1 Jul 2023 13:40:04 +0200 Subject: [PATCH 04/12] Update PsalmRunnerTrait.php --- tests/EndToEnd/PsalmRunnerTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/EndToEnd/PsalmRunnerTrait.php b/tests/EndToEnd/PsalmRunnerTrait.php index 87524768e6d..ab0334241bb 100644 --- a/tests/EndToEnd/PsalmRunnerTrait.php +++ b/tests/EndToEnd/PsalmRunnerTrait.php @@ -23,7 +23,7 @@ private function runPsalm( bool $relyOnConfigDir = true ): array { // Ensure CI agnostic output - if (!in_array('--init', $args, true)) { + if (!in_array('--init', $args, true) && !in_array('--alter', $args, true)) { array_unshift($args, '--output-format=console'); } From 52c629c3318b81c3acdef1cb9b25d7d319a62754 Mon Sep 17 00:00:00 2001 From: "Roland Franssen :)" Date: Sat, 1 Jul 2023 13:48:58 +0200 Subject: [PATCH 05/12] infer --debug in GHA --- src/Psalm/Internal/Cli/Psalm.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Psalm/Internal/Cli/Psalm.php b/src/Psalm/Internal/Cli/Psalm.php index 89a86dd4efa..bebd9137e3e 100644 --- a/src/Psalm/Internal/Cli/Psalm.php +++ b/src/Psalm/Internal/Cli/Psalm.php @@ -183,6 +183,11 @@ public static function run(array $argv): void throw new RuntimeException('Failed to parse CLI options'); } + // debug CI environment + if (!in_array('--debug', $option, true) && 'true' === getenv('GITHUB_ACTIONS') && '1' === getenv('RUNNER_DEBUG'))) { + array_unshift('--debug', $options); + } + self::forwardCliCall($options, $argv); self::validateCliArguments($args); From ce9d9db11581ab893fc36d41a4d8d37240d871a2 Mon Sep 17 00:00:00 2001 From: "Roland Franssen :)" Date: Sat, 1 Jul 2023 13:54:15 +0200 Subject: [PATCH 06/12] Update Psalm.php --- src/Psalm/Internal/Cli/Psalm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Cli/Psalm.php b/src/Psalm/Internal/Cli/Psalm.php index bebd9137e3e..5024abeeec9 100644 --- a/src/Psalm/Internal/Cli/Psalm.php +++ b/src/Psalm/Internal/Cli/Psalm.php @@ -184,7 +184,7 @@ public static function run(array $argv): void } // debug CI environment - if (!in_array('--debug', $option, true) && 'true' === getenv('GITHUB_ACTIONS') && '1' === getenv('RUNNER_DEBUG'))) { + if (!in_array('--debug', $option, true) && 'true' === getenv('GITHUB_ACTIONS') && '1' === getenv('RUNNER_DEBUG')) { array_unshift('--debug', $options); } From 010306fda8adcfb2e055994590992c04c43efe24 Mon Sep 17 00:00:00 2001 From: "Roland Franssen :)" Date: Sat, 1 Jul 2023 14:00:12 +0200 Subject: [PATCH 07/12] Update Psalm.php --- src/Psalm/Internal/Cli/Psalm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Cli/Psalm.php b/src/Psalm/Internal/Cli/Psalm.php index 5024abeeec9..536ad828240 100644 --- a/src/Psalm/Internal/Cli/Psalm.php +++ b/src/Psalm/Internal/Cli/Psalm.php @@ -184,7 +184,7 @@ public static function run(array $argv): void } // debug CI environment - if (!in_array('--debug', $option, true) && 'true' === getenv('GITHUB_ACTIONS') && '1' === getenv('RUNNER_DEBUG')) { + if (!in_array('--debug', $options, true) && 'true' === getenv('GITHUB_ACTIONS') && '1' === getenv('RUNNER_DEBUG')) { array_unshift('--debug', $options); } From 33b0693c4fce26f8d07702c3acfd87a9a19a3272 Mon Sep 17 00:00:00 2001 From: "Roland Franssen :)" Date: Sat, 1 Jul 2023 16:47:16 +0200 Subject: [PATCH 08/12] ugh --- src/Psalm/Internal/Cli/Psalm.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Psalm/Internal/Cli/Psalm.php b/src/Psalm/Internal/Cli/Psalm.php index 536ad828240..5ccc4fa1cb8 100644 --- a/src/Psalm/Internal/Cli/Psalm.php +++ b/src/Psalm/Internal/Cli/Psalm.php @@ -41,6 +41,7 @@ use function array_merge; use function array_slice; use function array_sum; +use function array_unshift; use function array_values; use function chdir; use function count; From 039c526c584c444fda5c6179467817f1c043b0e4 Mon Sep 17 00:00:00 2001 From: "Roland Franssen :)" Date: Sat, 1 Jul 2023 16:47:42 +0200 Subject: [PATCH 09/12] Update PsalmRunnerTrait.php --- tests/EndToEnd/PsalmRunnerTrait.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/EndToEnd/PsalmRunnerTrait.php b/tests/EndToEnd/PsalmRunnerTrait.php index ab0334241bb..03e7f714ec2 100644 --- a/tests/EndToEnd/PsalmRunnerTrait.php +++ b/tests/EndToEnd/PsalmRunnerTrait.php @@ -5,6 +5,8 @@ use Symfony\Component\Process\Process; use function array_merge; +use function array_unshift; +use function in_array; trait PsalmRunnerTrait { From f07cdfc129301ebd5f7c1d86de3aadf7e03a8a8d Mon Sep 17 00:00:00 2001 From: "Roland Franssen :)" Date: Sat, 1 Jul 2023 16:50:25 +0200 Subject: [PATCH 10/12] Update Psalm.php --- src/Psalm/Internal/Cli/Psalm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Cli/Psalm.php b/src/Psalm/Internal/Cli/Psalm.php index 5ccc4fa1cb8..ee14bec18aa 100644 --- a/src/Psalm/Internal/Cli/Psalm.php +++ b/src/Psalm/Internal/Cli/Psalm.php @@ -186,7 +186,7 @@ public static function run(array $argv): void // debug CI environment if (!in_array('--debug', $options, true) && 'true' === getenv('GITHUB_ACTIONS') && '1' === getenv('RUNNER_DEBUG')) { - array_unshift('--debug', $options); + array_unshift($options, '--debug'); } self::forwardCliCall($options, $argv); From bf31ffbd92b830753ea6c2c92357c9654d6e1ea3 Mon Sep 17 00:00:00 2001 From: "Roland Franssen :)" Date: Sat, 1 Jul 2023 16:56:33 +0200 Subject: [PATCH 11/12] Update Psalm.php --- src/Psalm/Internal/Cli/Psalm.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Cli/Psalm.php b/src/Psalm/Internal/Cli/Psalm.php index ee14bec18aa..84436e450a8 100644 --- a/src/Psalm/Internal/Cli/Psalm.php +++ b/src/Psalm/Internal/Cli/Psalm.php @@ -185,7 +185,10 @@ public static function run(array $argv): void } // debug CI environment - if (!in_array('--debug', $options, true) && 'true' === getenv('GITHUB_ACTIONS') && '1' === getenv('RUNNER_DEBUG')) { + if (!in_array('--debug', $options, true) + && 'true' === getenv('GITHUB_ACTIONS') + && '1' === getenv('RUNNER_DEBUG') + ) { array_unshift($options, '--debug'); } From b525f9cf70c0eeaa66b5a40ba0bfe45725669f2f Mon Sep 17 00:00:00 2001 From: "Roland Franssen :)" Date: Sat, 1 Jul 2023 17:01:49 +0200 Subject: [PATCH 12/12] PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY --- src/Psalm/Internal/Cli/Psalm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Cli/Psalm.php b/src/Psalm/Internal/Cli/Psalm.php index 84436e450a8..76d5098c463 100644 --- a/src/Psalm/Internal/Cli/Psalm.php +++ b/src/Psalm/Internal/Cli/Psalm.php @@ -186,7 +186,7 @@ public static function run(array $argv): void // debug CI environment if (!in_array('--debug', $options, true) - && 'true' === getenv('GITHUB_ACTIONS') + && 'true' === getenv('GITHUB_ACTIONS') && '1' === getenv('RUNNER_DEBUG') ) { array_unshift($options, '--debug');