mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Merge pull request #9982 from ro0NL/patch-1
Infer output format from GITHUB_ACTIONS env
This commit is contained in:
commit
3c3d184de4
@ -41,6 +41,7 @@ use function array_map;
|
||||
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;
|
||||
@ -183,6 +184,14 @@ final class Psalm
|
||||
throw new RuntimeException('Failed to parse CLI options');
|
||||
}
|
||||
|
||||
// debug CI environment
|
||||
if (!in_array('--debug', $options, true)
|
||||
&& 'true' === getenv('GITHUB_ACTIONS')
|
||||
&& '1' === getenv('RUNNER_DEBUG')
|
||||
) {
|
||||
array_unshift($options, '--debug');
|
||||
}
|
||||
|
||||
self::forwardCliCall($options, $argv);
|
||||
|
||||
self::validateCliArguments($args);
|
||||
@ -416,6 +425,10 @@ final class Psalm
|
||||
return Report::TYPE_PHP_STORM;
|
||||
}
|
||||
|
||||
if ('true' === getenv('GITHUB_ACTIONS')) {
|
||||
return Report::TYPE_GITHUB_ACTIONS;
|
||||
}
|
||||
|
||||
return Report::TYPE_CONSOLE;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,8 @@ namespace Psalm\Tests\EndToEnd;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
use function array_merge;
|
||||
use function array_unshift;
|
||||
use function in_array;
|
||||
|
||||
trait PsalmRunnerTrait
|
||||
{
|
||||
@ -22,6 +24,11 @@ trait PsalmRunnerTrait
|
||||
bool $shouldFail = false,
|
||||
bool $relyOnConfigDir = true
|
||||
): array {
|
||||
// Ensure CI agnostic output
|
||||
if (!in_array('--init', $args, true) && !in_array('--alter', $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
|
||||
// analysed exists in.
|
||||
|
Loading…
Reference in New Issue
Block a user