From 1182a5644ebbe7f4cd3f10c728ed80f34533b286 Mon Sep 17 00:00:00 2001 From: Mikhail Tyukin Date: Tue, 1 Sep 2026 07:22:52 -0400 Subject: [PATCH] [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. --- .github/workflows/build.yml | 13 ++++- .github/workflows/problem-matcher.json | 69 ++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/problem-matcher.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 115bfe92e3b..4e98820e772 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/.github/workflows/problem-matcher.json b/.github/workflows/problem-matcher.json new file mode 100644 index 00000000000..a2a07cbee25 --- /dev/null +++ b/.github/workflows/problem-matcher.json @@ -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 + } + ] + } + ] +}