Skip to content

console: auto activate ansi colors in github actions #38585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
staabm opened this issue Oct 15, 2020 · 3 comments
Closed

console: auto activate ansi colors in github actions #38585

staabm opened this issue Oct 15, 2020 · 3 comments

Comments

@staabm
Copy link
Contributor

staabm commented Oct 15, 2020

Symfony version(s) affected: 4.x

Description
Github Actions added support for ansi colors recently.

it turns out that symfony console based apps don't auto-enable syntax coloring.
initially I had reported this issue on composer/composer#9269 but jordi would instead want a fix in symfony/console and/or Github Actions instead.

therefore I also opened a issue on the Github actions runner, without feedback yet though
actions/runner#750

to get fancy colors on github actions, we need to manually enable ..ansi which is tedious:
see e.g. https://github.com/redaxo/redaxo/pull/3939/files

How to reproduce

run composer install within a github action

Possible Solution
imply --ansi when false !== getenv('GITHUB_ACTION')

Additional context
people work arround this problem by sprinkling additional --ansi flags across all the php based tools invoked within github action already, see e.g. https://tomasvotruba.com/blog/2020/09/28/how-to-add-colors-to-continuious-integration-output/

@derrabus
Copy link
Member

imply --ansi when false !== getenv('GITHUB_ACTION')

Is there a way we could auto-detect color support without building a workaround specific to GitHub actions? I understand that this is kind of what you're asking in actions/runner#750 already.

I don't feel confident about solely relying on that env variable. One scenario I could imagine here: You would use the Process component to run another Symfony Console based tool (e.g. your tool calls Composer for certain tasks). In that case the env variable would still be set, but auto-enabling color output is probably not desirable in that context.

@stof
Copy link
Member

stof commented Oct 15, 2020

env-based detection are a bad idea. they would break scripts running things like some-comment > output.txt, as it would consider that output.txt supports ANSI colors...

@chalasr
Copy link
Member

chalasr commented Dec 13, 2020

I'm closing this issue as the proposed solution does not look right. This would better be solved on GA' side to me.

@chalasr chalasr closed this as completed Dec 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants