Skip to content

Clang tidy via annotations #131

Clang tidy via annotations

Clang tidy via annotations #131

Workflow file for this run

name: Clang Tidy
on:
pull_request: # Required to post comments on PR from forks
jobs:
clang-tidy-review:
runs-on: ubuntu-latest
if: startsWith(github.event_name, 'pull_request') # Posting a review only makes sense on PRs
steps:
# Repo config for pull_request_target
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
submodules: recursive
- name: Install clang-tidy
run: |
sudo debconf-communicate <<< "set man-db/auto-update false"
sudo dpkg-reconfigure man-db
sudo apt-get update
sudo apt-get remove -y ^clang-tidy
sudo apt-get install -y clang-19 clang-tidy-19
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-19 100
- name: Generate compilation database
run: |
cd ${{ github.workspace }}
./dbt configure
sed -i 's/-mthumb-interwork//g' build/compile_commands.json
sed -i 's/-fdevirtualize-at-ltrans//g' build/compile_commands.json
sed -i 's/-fuse-linker-plugin//g' build/compile_commands.json
- name: Extract system includes from GCC
id: extract_system_includes
run: |
${{ github.workspace }}/toolchain/current/arm-none-eabi-gcc/bin/arm-none-eabi-g++ -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=hard -E -x c++ - -v < /dev/null 2>&1 \
| sed -n '/^#include <...> search starts here:$/,/^End of search list.$/p' \
| tail -n +2 \
| head -n -1 \
| sed 's/^\s*//g' \
| sed 's/^\(.*\)$/--extra-arg-before=-isystem\1/g' \
| tr '\n' ' ' > system_includes.txt
echo "system_includes=$(cat system_includes.txt)" >> $GITHUB_OUTPUT
echo "Extracted system includes:"
cat system_includes.txt
- name: Check clang-tidy version
run: clang-tidy --version
- uses: stellar-aria/clang-tidy-annotations@7a07996fe01ffaa846b0f4a5e9de3c58a3217f73 #ZehMatt/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build_dir: ${{ github.workspace }}/build
source_dir: ${{ github.workspace }}
only_affected_lines: true
fail_on_problems: true
clang_tidy_args: ${{ steps.extract_system_includes.outputs.system_includes }} --extra-arg-before=--no-standard-includes
clang_tidy_file: ${{ github.workspace }}/.clang-tidy