[GITHUB] Add problem matcher to enable annotations (#9472)

Enable the GitHub Actions annotation feature for GCC, Clang and MSVC.
This allows you to spot build failures very easily. Use sed to change
relative file paths to absolute ones, making CI recognize it properly.

Currently only linker errors and C/C++ compiler errors are annotated.
This commit is contained in:
Mikhail Tyukin
2026-09-01 07:22:52 -04:00
committed by GitHub
parent 0a2244b0b5
commit 1182a5644e
2 changed files with 81 additions and 1 deletions

View File

@@ -64,13 +64,16 @@ jobs:
echo "CCACHE_DIR=${{github.workspace}}/ccache" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=1G" >> $GITHUB_ENV
echo "CCACHE_SLOPPINESS=time_macros" >> $GITHUB_ENV
- name: Configure problem matchers
run: echo ::add-matcher::src/.github/workflows/problem-matcher.json
- name: Ease ccache compiler check (GCC)
if: ${{ matrix.compiler == 'gcc' }}
run: echo "CCACHE_COMPILERCHECK=string:${{steps.get_rosbe_spec.outputs.git-sha}}-${{hashfiles('./build_rosbe_ci.sh')}}" >> $GITHUB_ENV
- name: Configure
run: echo 'cmake -S ${{github.workspace}}/src -B ${{github.workspace}}/build -G Ninja -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-${{matrix.compiler}}.cmake -DARCH:STRING=${{matrix.arch}} -DCMAKE_BUILD_TYPE=${{matrix.config}} -DDLL_EXPORT_VERSION=${{matrix.dllver}} -DENABLE_CCACHE=1 -DENABLE_ROSTESTS=1 -DENABLE_ROSAPPS=1 ${{env.D_CLANG_VERSION}}' | ${{github.workspace}}/RosBE-CI/RosBE.sh . 0 ${{matrix.arch}}
# GCC and Clang use relative file paths for error messages, use sed to convert these to absolute paths so that GitHub could parse them
- name: Build
run: echo 'cmake --build ${{github.workspace}}/build -- -k0' | ${{github.workspace}}/RosBE-CI/RosBE.sh . 0 ${{matrix.arch}}
run: set -o pipefail && echo 'cmake --build ${{github.workspace}}/build --' | ${{github.workspace}}/RosBE-CI/RosBE.sh . 0 ${{matrix.arch}} 2>&1 | sed 's|^\.\./src/|${{github.workspace}}/src/|'
- name: Generate ISOs
run: echo 'cmake --build ${{github.workspace}}/build --target bootcd' | ${{github.workspace}}/RosBE-CI/RosBE.sh . 0 ${{matrix.arch}}
- name: Print ccache statistics
@@ -123,6 +126,8 @@ jobs:
uses: actions/checkout@v6
with:
path: src
- name: Configure problem matchers
run: echo ::add-matcher::src/.github/workflows/problem-matcher.json
- name: Configure
run: cmake -S src -B build -G Ninja -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=${{matrix.arch}} -DCMAKE_BUILD_TYPE=${{matrix.config}} -DDLL_EXPORT_VERSION=${{matrix.dllver}} -DENABLE_ROSTESTS=1 -DENABLE_ROSAPPS=1
- name: Build
@@ -185,6 +190,8 @@ jobs:
uses: actions/checkout@v6
with:
path: src
- name: Configure problem matchers
run: echo ::add-matcher::src/.github/workflows/problem-matcher.json
- name: Configure
run: cmake -S src -B build -G Ninja -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=${{matrix.arch}} -DCMAKE_BUILD_TYPE=${{matrix.config}} -DENABLE_ROSTESTS=1 -DENABLE_ROSAPPS=1
- name: Build base module
@@ -290,6 +297,8 @@ jobs:
uses: actions/checkout@v6
with:
path: src
- name: Configure problem matchers
run: echo ::add-matcher::src/.github/workflows/problem-matcher.json
- name: Configure
run: cmake -S src -B build -G Ninja -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=${{matrix.arch}} -DCMAKE_BUILD_TYPE=${{matrix.config}} -DENABLE_ROSTESTS=1 -DENABLE_ROSAPPS=1 -DUSE_CLANG_CL:BOOL=TRUE
- name: Build
@@ -327,6 +336,8 @@ jobs:
- uses: actions/checkout@v6
with:
path: src
- name: Configure problem matchers
run: echo ::add-matcher::src/.github/workflows/problem-matcher.json
- name: Configure
run: |
mkdir build

69
.github/workflows/problem-matcher.json vendored Normal file
View File

@@ -0,0 +1,69 @@
{
"problemMatcher": [
{
"owner": "gcc",
"severity": "error",
"pattern": [
{
"regexp": "^(.+):(\\d+):(\\d+):\\s+(fatal error|error|warning|note):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
]
},
{
"owner": "msvc",
"pattern": [
{
"regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+),?(\\d+)?(?:,\\d+,\\d+)?\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"code": 5,
"message": 6
}
]
},
{
"owner": "clang",
"pattern": [
{
"regexp": "^(.*?)\\((\\d+),(\\d+)\\):\\s+(warning|error|note):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
]
},
{
"owner": "msvc-linker",
"pattern": [
{
"regexp": "^(.*?)\\s*:\\s*(fatal error|error|warning)\\s+([A-Z0-9]+)\\s*:\\s*(.*)$",
"file": 1,
"severity": 2,
"code": 3,
"message": 4
}
]
},
{
"owner": "gcc-linker",
"severity": "error",
"pattern": [
{
"regexp": "^(.*?(?:ld|collect2)(?:\\.exe)?):\\s*(?:(warning|error|fatal error):?\\s+)?(.*)$",
"file": 1,
"severity": 2,
"message": 3
}
]
}
]
}