Repository navigation
Description
Describe the bug
Color codes appear to affect regex matching of problem matchers
To Reproduce
Steps to reproduce the behavior:
- Create a problem matcher that matches plaintext, e.g.
"regexp": "Hello world" - Run an action that produces color output, for example:
bash -c "printf '\e[31mHello\e[0m world!\n'" - Observe that no match appears in the actions output or inline on a PR "files" tab.
As a more real-life example, I have created a minimal reproduction with colored output and missing the expected annotations:
https://github.com/ian-h-chamberlain/actions-color-repro/actions/runs/3777593125
However, when I updated the workflow to disable color output, annotations appear as expected:
ian-h-chamberlain/actions-color-repro#1
https://github.com/ian-h-chamberlain/actions-color-repro/actions/runs/3777594485
Expected behavior
Most (all?) are written against plain (un-colored) text, but it would be nice to have colorized output in the action logs while still supporting colored output.
This document indicates that color codes should be stripped before applying matchers.
Runner Version and Platform
Version of your runner? Current runner version: '2.299.1'
OS of the machine running the runner? ubuntu-latest
What's not working?
See the "expected behavior" above.
Other notes
I believe this logic is incomplete for stripping ANSI color codes:
| private static readonly Regex _colorCodeRegex = new(@"\x0033\[[0-9;]*m?", RegexOptions.Compiled | RegexOptions.CultureInvariant); |
| var stripped = line.Contains(_colorCodePrefix) ? _colorCodeRegex.Replace(line, string.Empty) : line; |
Here is a sample logs from a more realistic run which I believe show a wider range of ANSI control codes that might be encountered by tools that use color: 6_Run clippy linting.txt
Activity
Try disabling color output
ian-h-chamberlain commentedon Mar 4, 2023
@ruvceskistefan since you triaged this to add the
keeplabel, maybe you know who might be able to review the PR to fix this (#2430) ? It's a fairly small change and this would be a nice quality of life improvement for the runner. Thanks!Add new problem matcher that is aware of color codes
add problem matcher for vitest (#103)
Try to retain some colors while still having the problem matcher matc…
Update pytest summary problem matcher for colored output
Update pytest summary problem matcher for colored output
jsoref commentedon Jun 17, 2025
I suppose I should feel honored that my fork was linked for this ticket.
Note that instead of using https://github.com/jsoref/actions-runner/blob/f9c2bf1dd72541bf039c3c5fa4129814181ca261/docs/adrs/0276-problem-matchers.md?plain=1#L113, you can use:
runner/docs/adrs/0276-problem-matchers.md
Line 113 in 097ada9
We're pretty sure that we're also tripping on this issue. (As it happens, I do have tooling that is vaguely aware of ansi color codes -- specifically for the purpose of ignoring them -- but I can't claim that my tooling is any better than anyone else's.)
jenseng commentedon Jun 17, 2025
Until this is fixed, I've just resorted to rolling my own problem matchers that handle ANSI escape codes, though this can be a bit tedious to get right 🥲.
For example, here's a modified eslint-stylish.json I use (instead of the default one provided by actions/setup-node):
{ "problemMatcher": [ { "owner": "eslint-stylish", "pattern": [ { "regexp": "^(?:\\x1b\\[\\d+m)*([^\\s].*?)(?:\\x1b\\[\\d+m)*$", "file": 1 }, { "regexp": "^(?:\\x1b\\[\\d+m)*\\s+(?:\\x1b\\[\\d+m)*(\\d+):(\\d+)(?:\\x1b\\[\\d+m)*\\s+(?:\\x1b\\[\\d+m)*(error|warning|info)(?:\\x1b\\[\\d+m)*\\s+(.*)\\s\\s+(?:\\x1b\\[\\d+m)*(.*?)(?:\\x1b\\[\\d+m)*$", "line": 1, "column": 2, "severity": 3, "message": 4, "code": 5, "loop": true } ] } ] }ci: fix ubsan problem matcher colored output
ci: fix ubsan problem matcher colored output
ci: fix ubsan problem matcher colored output
ci: fix ubsan problem matcher colored output
ci: fix ubsan problem matcher colored output
ci: fix ubsan problem matcher colored output
ci: fix ubsan problem matcher colored output
ci: fix ubsan problem matcher colored output