mfridman / tparse

CLI tool for summarizing go test output. Pipe friendly. CI/CD friendly.
MIT License
948 stars 22 forks source link

tparse `v0.11.0` lost color? #76

Closed embano1 closed 1 year ago

embano1 commented 2 years ago

Please see the following output for different versions when running tparse against this repo. v0.11.0 seems to have lost color? Is there a way to debug this?

v0.11.0

image

v0.10.3

image
mfridman commented 2 years ago

@embano1 To debug, can you try setting the env variable CI=true?

embano1 commented 2 years ago

Ah, that fixes it! So what's the issue here?

mfridman commented 2 years ago

In a previous release tparse was always setting:

lipgloss.SetColorProfile(termenv.TrueColor)

But then I changed it to only set that when CI=true, which set in most envionments.

https://github.com/mfridman/tparse/blob/e2da1ad98541a56759a35afa743d5e0432041175/internal/app/console_writer.go#L65-L76

I suppose we could always set this, but it feels a bit awkward.

embano1 commented 1 year ago

Reason I was asking is that I was used to running my tests locally and piping to tparse. So just wondering why that stopped being coloured :)

mfridman commented 1 year ago

I'm a bit stumped why colors don't display in your local terminal. I'll remove the conditional "CI" check, and add this line:

lipgloss.SetColorProfile(termenv.TrueColor)

But tbh I don't understand why this is needed. Maybe @caarlos0 knows?


I have native Terminal and VS Code, and both render colors.

CleanShot 2022-07-10 at 08 41 16@2x CleanShot 2022-07-10 at 08 42 28@2x
mfridman commented 1 year ago

Based on a cursory scan of muesli/termenv, there is a check for "CI" env flag that disables colors:

https://github.com/muesli/termenv/blob/55e6225a50df5a672ccb5a99b43bf2b0a70aba3e/termenv.go#L34-L40

I was observing this with GitHub Actions, noted here https://github.com/charmbracelet/lipgloss/issues/74#issuecomment-1133744453

So, adding the explicit lipgloss.SetColorProfile(termenv.TrueColor) was necessary for CI environments.

For whatever reason, termenv is not properly? detecting your env and setting the colors.

https://github.com/muesli/termenv/blob/55e6225a50df5a672ccb5a99b43bf2b0a70aba3e/termenv.go#L42-L50

mfridman commented 1 year ago

Pushed a fix in v0.11.1. This essentially reverts the explicit CI check, so colors should show up for you as before.

embano1 commented 1 year ago

Awesome, works :)

caarlos0 commented 1 year ago

maybe @embano1 has a CI env set locally somehow? env | grep CI shows anything?

caarlos0 commented 1 year ago

afaik, termenv does a OSC query to check colors et al, and for that to work it needs to be an interactive term - since CI's aren't, it falls back. I might be wrong though, probably @muesli can explain better

muesli commented 1 year ago

Indeed, I introduced the CI check as a workaround for some CI systems that pretend to be a proper terminal, but then never respond to any OSC queries, causing them to timeout. GitHub workflows always behaved fine in that regard, but CircleCI and others didn't.

embano1 commented 1 year ago

maybe @embano1 has a CI env set locally somehow? env | grep CI shows anything?

was my first guess, nothing set. Using tmux with oh my zsh on latest osx.