Open os14 opened 1 month ago
@os14 this is intentional, GitHub Actions and other CIs export CI=1
to indicate that the application is running in a CI environment. Some CIs don't support colors. Termenv, the underlying library currently used to render colors, detects the CI
environment variable and disables colors accordingly. To enable colors make sure that you set CI=''
in your workflow or application.
@os14 this is intentional, GitHub Actions and other CIs export
CI=1
to indicate that the application is running in a CI environment. Some CIs don't support colors. Termenv, the underlying library currently used to render colors, detects theCI
environment variable and disables colors accordingly. To enable colors make sure that you setCI=''
in your workflow or application.
I found that, in GitHub Actions at least, all it takes is CLICOLOR_FORCE=1
.
I tested the logics here:
Using the following snippet:
// fatih/color
white := color.New(color.FgBlue)
boldWhite := white.Add(color.Bold)
boldWhite.Println("Colors using fatih/color")
// charmbracelet/log
logger := log.New(os.Stdout)
logger.Info("Colors using charmbracelet/log")
if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Println("IsTerminal: true")
} else {
fmt.Println("IsTerminal: false")
}
fmt.Printf("TERM: %s\n", os.Getenv("TERM"))
fmt.Printf("CI: %s\n", os.Getenv("CI"))
fmt.Printf("CLICOLOR_FORCE: %s\n", os.Getenv("CLICOLOR_FORCE"))
and adding the following to the Github Actions step, more info on that here:
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
Here are the results:
Is your feature request related to a problem? Please describe. we have a cli tool that uses charmbracelet/log for logging, locally it prints nice colors, but in github actions terminal it doesn't print colors.
Describe the solution you'd like perhaps the issue is on github side but i would like to get a workaround for this or ideally make it works out of the box.
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context local:![image](https://github.com/charmbracelet/log/assets/17493790/adeacc08-8c8b-4e47-bc27-44b16cff13e1)
github actions:![image](https://github.com/charmbracelet/log/assets/17493790/04628a0e-24ec-4bb3-894c-e0d09ad860d2)