Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 3
Message 1 of 7

ANSI color output in webview?!?

Solved! Go to Solution.

Hello,

 

I just recognized that in one of my GitHub Action workflows which I ported over from travis no ANSI colors are shown in the Webview of the output. Is there some setting or are ANSI color escape sequences are simply stripped in GitHub Actions while with travis they are perfectly displayed in the webview?

 

In the actual job that is run I use the nodejs-based mocha test framework and in its output Mocha uses ANSI escape sequences to either show success with a green arrow or in case of a failure with a red cross and this works perfectly in the Travis webview while in the GitHub Actions job output view no ANSI colors are displayed at all.

 

So does anyone have an idea how to enable ANSI colors in the webview or is this simply a missing feature?!?

 

Thanks in advance.

6 Replies
Highlighted
GitHub Staff
Message 2 of 7

Re: ANSI color output in webview?!?

Yes, we support ANSI colors.

I haven’t used Mocha specifically. Many test runners check for an env var or terminal setting before they output color.
Highlighted
Copilot Lvl 3
Message 3 of 7

Re: ANSI color output in webview?!?


@mscoutermarsh wrote:
Yes, we support ANSI colors.

I haven’t used Mocha specifically. Many test runners check for an env var or terminal setting before they output color.

 

Do you know which terminal settings or env variable as used to enable this is GitHub Actions? In fact, I already tried to set the TERM variable to "xterm-256color" right before starting the mocha test, but this didn't help. So I was wondering if there might be a standard TERM/ENV variable which I need to setup in the workflow and if so, why it is not setup per default as in travis I never had to care about that and ANSI color output is the default.

Highlighted
GitHub Partner
Message 4 of 7

Re: ANSI color output in webview?!?

Hi @jens-maus ,

 

What do you mean of ‘ANSI color escape sequences’ here? Could you please show a screenshot in travis?

 

Checked on my side, with below command, the ANSI escape sequences works in bash output as expected.

echo -e "\033[31;1;4mHello\033[0m"

ANSIColor.png

Thanks.

Highlighted
Copilot Lvl 3
Message 5 of 7

Re: ANSI color output in webview?!?


@weide-zhou wrote:

 

What do you mean of ‘ANSI color escape sequences’? Could you please show a screenshot?

 

I mean the following. This is the output on travis, e.g.:

 

Bildschirmfoto 2020-02-14 um 08.50.32.png

 

And the same output, but on GitHub Actions looks like:

 

Bildschirmfoto 2020-02-14 um 08.51.06.png

 

So please note the color difference and that within GitHub Actions no colorized output is presented at all. That's why I was wondering how to enable ANSI color output in GitHub Actions or if this is a missing feature.

Highlighted
Solution
Copilot Lvl 3
Message 6 of 7

Re: ANSI color output in webview?!?

Ok, after some more investigation I could solve the problem myself. I simply had to add the command-line option --colors when executing mocha (see https://github.com/jens-maus/occu-test/commit/0a57c8fadda3e7d4d8f2043c7171dc4d6a10966e).

 

So somehow with the default environment of GitHub Actions mocha could not identify itself that it is running within a TTY enabled device and thus enable ANSI color output itself. See here (https://github.com/mochajs/mocha/issues/1304) for similar discussions to force mocha to output ANSI colors on non tty devices. So the remaining question that might be there is, why isn't the GitHub Actions environment not identified as a proper TTY device by mocha while within travis there isn't any issue and mocha outputs all content using ANSI colors?!?

Highlighted
GitHub Partner
Message 7 of 7

Re: ANSI color output in webview?!?

Hi @jens-maus ,

 

Glad to know it's been resolved by adding the command-line option --colors when executing mocha.

It's recommended to raise a ticket here where github action managers will take a review. Thanks.