Skip to content

Commit

Permalink
fix(problem_matcher): ignore ANSI color escape codes for matching
Browse files Browse the repository at this point in the history
When PackSquash outputs log messages with colors, problem matchers do
not seem to work. However, they worked fine in the past, when colors
were not printed. I suspected that GitHub not removing ANSI color escape
codes before matching could be the culpirit, and indeed there are some
ignored GitHub issues in the VS Code repositories about it (GitHub
runners inherit problem matchers from VS Code).

Let's tweak the regexes used for matching to take into account the ANSI
escape sequences that PackSquash may use. To test that they work as
expected, temporarily introduce a failure in a test workflow.
  • Loading branch information
AlexTMjugador committed Oct 11, 2022
1 parent c84fd43 commit 11fa3f7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/test_empty_pack_with_latest_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Generate minimal PackSquash options file
run: echo 'pack_directory = "test/empty_resource_pack"' > packsquash-options.toml
- name: Run PackSquash
uses: ./ # Uses an action in the root directory
with:
packsquash_version: latest
options_file: packsquash-options.toml
path: test/empty_resource_pack
19 changes: 17 additions & 2 deletions src/problem_matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const json = {
severity: 'error',
pattern: [
{
regexp: '^[!❌] (?!.*Invalid stick parity bit)(.+)$',
regexp: '^(?:\x1B\\[\\d+\\w*)*[!❌] (?!.*Invalid stick parity bit)(.+?)(?:\x1B\\[0m)?$',
message: 1
}
]
Expand All @@ -18,10 +18,25 @@ const json = {
severity: 'warning',
pattern: [
{
regexp: '^[*⚡] (.+)$',
regexp: '^(?:\x1B\\[\\d+\\w*)*[*⚡] (.+?)(?:\x1B\\[0m)?$',
message: 1
}
]
},
{
owner: 'packsquash-file-warning',
severity: 'warning',
pattern: [
{
regexp: '^(?:\x1B\\[\\d+\\w*)*[*⚡] (.+): .+$',
file: 1
},
{
regexp: '^(?:\x1B\\[\\d+\\w*)* ?[*⚡] (.+?)(?:\x1B\\[0m)?$',
message: 1,
loop: 1
}
]
}
]
};
Expand Down

0 comments on commit 11fa3f7

Please sign in to comment.