-
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. |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments
-
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. |
Beta Was this translation helpful? Give feedback.
-
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.
Thanks. |
Beta Was this translation helpful? Give feedback.
-
I mean the following. This is the output on travis, e.g.: And the same output, but on GitHub Actions looks like: 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. |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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 jens-maus/occu-test@0a57c8f). 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 (mochajs/mocha#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?!? |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
FYI, if you’re using
For some libraries, though, this will not be enough or annoying warnings will print in the webview because it is not technically a TTY. For example, boxen needs a TTY so this repeated error message shows up: |
Beta Was this translation helpful? Give feedback.
-
There does indeed seem to be a problem with GitHub Actions not working as one would expect with
or
. I’ve tried both of these to try and get some colored output from my xUnit tests, but neither one works (where they do work when running the tests locally, on Linux). Here is one example of such a job: https://github.com/perlun/perlang/runs/690297760?check_suite_focus=true @weide-zhouIf no issue has been created for this yet, please let me know and I’ll file one. Not all tools support a FORCE_COLOR flag, unfortunately, so it would be important to get GitHub Actions working more flawlessly in this regard. |
Beta Was this translation helpful? Give feedback.
-
Hi @perlun , Thanks for your checking! Please raise a feedback/feature_request ticket here where github product manager will take a review. Regards. |
Beta Was this translation helpful? Give feedback.
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 jens-maus/occu-test@0a57c8f).
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 (mochajs/mocha#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?!?