phpro / grumphp

A PHP code-quality tool
MIT License
4.14k stars 430 forks source link

Improve no-ansi reporting #818

Closed veewee closed 3 years ago

veewee commented 3 years ago
Q A
Branch master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Documented? no
Fixed tickets #817

This PR creates a less verbose output on non-ansi systems like Github actions, Travis, ... You can switch the behaviour by adding --ansi or --no-ansi flag.

veewee commented 3 years ago

This doesn't solve the issue on travis, since they do run in ANSI mode - but have a different way for displaying the results. Maybe a better idea to determine if we are running in a known CI?

Psalm does it this way : https://github.com/vimeo/psalm/blob/37a2f8a33dc38300a7f19cbaafa1a68d4f890f1a/src/psalm.php#L380-L386

Adding a flag would be possible as well, but requires some more work to be done.

drupol commented 3 years ago

Maybe we can use https://github.com/OndraM/ci-detector just like infection/infection.

prudloff-insite commented 3 years ago

This does not fix the issue on GitLab CI either.

veewee commented 3 years ago

This works for me. I added the CI package that @drupol suggested, which means you don't have to manually add --no-ansi to the cli command + it still prints in green color.

On non-ascii situations, you will first see a list of all tasks that will be executed. Once all tasks are done, you will see the result of all tasks. This limits the amount of messages to 2 blocks.

Also tried a more linear approach, but it didnt work well in combination with parallel task execution. For me, this is good enough at the moment.

Feel free to improve or point out your remarks.

Example on appveyor:

Screenshot 2020-10-30 at 10 25 47

drupol commented 3 years ago

Very nice :-)