-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: default fromPath for problem matchers #3802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: default fromPath for problem matchers #3802
Conversation
e2dafbd to
9917e39
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
|
End-to-end testing makes sense. Here are the tests I ran through: Workflow YAMLjobs:
build:
runs-on: self-hosted
permissions:
id-token: write
steps:
- run: |
echo Create files
git init .
mkdir -p dir-level-1/dir-level-2/dir-level-3
echo "a content" > a.txt
echo "b content" > dir-level-1/b.txt
echo "c content" > dir-level-1/dir-level-2/c.txt
echo "d content" > dir-level-1/dir-level-2/dir-level-3/d.txt
- run: |
echo "$MATCHER_JSON" > matcher.json
echo "::add-matcher::matcher.json"
env:
# badFile.js: line 50, col 11, Error - 'myVar' is defined but never used. (no-unused-vars)
MATCHER_JSON: |
{
"problemMatcher": [
{
"owner": "my-matcher",
"pattern": [
{
"regexp": "^(.+):\\sline\\s(\\d+),\\scol\\s(\\d+),\\s(Error|Warning|Info)\\s-\\s(.+)\\s\\((.+)\\)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5,
"code": 6
}
]
}
]
}
- run: |
echo Print errors
echo 'a.txt: line 1, col 1, Error - First error (e1)'
echo 'dir-level-1/b.txt: line 1, col 1, Error - Second error (e2)'
echo 'dir-level-1/dir-level-2/c.txt: line 1, col 1, Error - Third error (e3)'
################################################################################
- run: |
echo "::remove-matcher owner=my-matcher::"
echo "$MATCHER_JSON" > matcher.json
echo "::add-matcher::matcher.json"
env:
# badFile.js: line 50, col 11, Error - 'myVar' is defined but never used. (no-unused-vars)
MATCHER_JSON: |
{
"problemMatcher": [
{
"owner": "my-matcher",
"pattern": [
{
"regexp": "^(.+): (.+):\\sline\\s(\\d+),\\scol\\s(\\d+),\\s(Error|Warning|Info)\\s-\\s(.+)\\s\\((.+)\\)$",
"fromPath": 1,
"file": 2,
"line": 3,
"column": 4,
"severity": 5,
"message": 6,
"code": 7
}
]
}
]
}
- run: |
echo Print errors
echo 'proj.txt: a.txt: line 1, col 1, Error - Fourth error (e4)'
echo 'dir-level-1/proj.txt: b.txt: line 1, col 1, Error - Fifth error (e5)'
echo 'dir-level-1/dir-level-2/proj.txt: c.txt: line 1, col 1, Error - Sixth error (e6)'
################################################################################
- run: |
echo "::remove-matcher owner=my-matcher::"
echo "$MATCHER_JSON" > matcher.json
echo "::add-matcher::matcher.json"
env:
# badFile.js: line 50, col 11, Error - 'myVar' is defined but never used. (no-unused-vars)
MATCHER_JSON: |
{
"problemMatcher": [
{
"owner": "my-matcher",
"fromPath": "dir-level-1/proj.txt",
"pattern": [
{
"regexp": "^(.+):\\sline\\s(\\d+),\\scol\\s(\\d+),\\s(Error|Warning|Info)\\s-\\s(.+)\\s\\((.+)\\)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5,
"code": 6
}
]
}
]
}
- run: |
echo Print errors
echo 'b.txt: line 1, col 1, Error - Seventh error (e7)'
echo 'dir-level-2/c.txt: line 1, col 1, Error - Eighth error (e8)'
echo 'dir-level-2/dir-level-3/d.txt: line 1, col 1, Error - Ninth error (e9)' |
|
FYI - When running through E2E testing, based on the way it currently works, A future enhancement would be for |
9917e39 to
07235fb
Compare
That makes sense, and I can easily use a file path for my particular use case. Thanks! |
Ran into the need for this when trying to set up a problem matcher in electron/electron#46577. The issue there is filenames in build errors are relative to a build directory which is outside of the source directory, and there's not enough information in the build error to be able to construct the correct path.
With this change I'll be able to add
"fromPath": "src/out/Default/"and everything should just work.