I try to set-up a problem matcher in a github workflow to annotate the compilation errors directly in the “files changed” list.
The project is in c/c++, so we catch the errors out of a nmake command on Windows that runs the compiler and linker.
The sources are in the folder ./myProject/src
and the makefile is in the folder ./myProject/build/
so in the makefile every compilation command contains path to file in the following style : ../src/pathToSourceFile.c
I run all that stuff with build-project.yml :
- name: Deploy
shell: cmd
run: |
echo ::add-matcher::./myProject/.github/matchers/deploy.json
cd myProject/build
call "%VCVARS_PATH%/vcvars64.bat"
nmake last-version
echo ::remove-matcher owner=deploy::
The problem matcher I use is the file ./myProject/.github/matchers/deploy.json:
{
"problemMatcher": [{
"owner": "deploy",
"pattern": [{
"regexp": "^(.*)\((\d+)\): (warning|error) (C\d+): (.*)$",
"file": 1,
"line": 2,
"severity": 3,
"code": 4,
"message": 5
}]
}]
}
The regex is verified, it works well but the annotations still don’t appear because github workflow doesn’t find the matching source files as it doesn’t seem to take into account the relative ../src/file.c
paths.
When I replace all the ../src/
by myProject/src/
in the nmake command output with a python script then it works. The problem matcher file output is then myProject/src/file.c and the github workflow is able to find those files.
But I don’t want to use a python script as it should work with relative paths (it works locally in vs-code). And I don’t want to change the makefile with paths relative to the repo root, all have to stay relative to the myProject/build folder.
I tried a lot of things :
- add
"fileLocation": ["relative", "./myProject/build"]
in the problem matcher - catch the
../
in the regex and set"fileLocation": ["relative", "./myProject"]
to avoid the “go to parent magical” - set
working-directory: "./myProject/"
orworking-directory: "./myProject/build"
in the yml file
…
Nothing works and I’m a bit confused with all of that.
What is the chosen base/current folder in each context ?
What do I have to add exactly, and where, to allow github workflow to find the corresponding source files (without filtering the command output or modifying the makefile) ?