Enable clang-tidy and Ruff linting in Github Actions #9
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Clang Tidy | |
on: | |
pull_request: | |
branches: | |
- "community" | |
pull_request_target: # 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 install -y clang-19 clang-tidy-19 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.13' | |
cache: 'pip' | |
- 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 : Install clang-tidy-review | |
run: pip install ${{github.workspace}}/contrib/clang_tidy_review | |
- name: Run clang-tidy-review | |
run: | | |
review \ | |
--token=${{ secrets.GITHUB_TOKEN }} \ | |
--repo=${{ github.event.pull_request.head.repo.full_name }} \ | |
--pr=${{ github.event.pull_request.number }} \ | |
--split_workflow=True \ | |
--clang_tidy_binary=clang-tidy-19 \ | |
--build_dir=${{ github.workspace }}/build \ | |
--config_file=${{ github.workspace }}/.clang-tidy \ | |
--extra-arg-before="-I${{ github.workspace }}/toolchain/current/arm-none-eabi-gcc/arm-none-eabi/include/c++/14.2.1" \ | |
--extra-arg-before="-I${{ github.workspace }}/toolchain/current/arm-none-eabi-gcc/arm-none-eabi/include/c++/14.2.1/arm-none-eabi/thumb/v7-a+simd/hard" \ | |
--extra-arg-before="-I${{ github.workspace }}/toolchain/current/arm-none-eabi-gcc/arm-none-eabi/include/c++/14.2.1/backward" \ | |
--extra-arg-before="-I${{ github.workspace }}/toolchain/current/arm-none-eabi-gcc/lib/gcc/arm-none-eabi/14.2.1/include" \ | |
--extra-arg-before="-I${{ github.workspace }}/toolchain/current/arm-none-eabi-gcc/lib/gcc/arm-none-eabi/14.2.1/include-fixed" \ | |
--extra-arg-before="-I${{ github.workspace }}/toolchain/current/arm-none-eabi-gcc/arm-none-eabi/include" \ | |
--extra-arg-before="--no-standard-includes" | |
env: | |
USER: ${{ github.event.pull_request.user.login }} | |
- name: Post review | |
run: post --token=${{ secrets.GITHUB_TOKEN }} --repo=${{ github.event.pull_request.head.repo.full_name }} --lgtm-comment-body="" --num-comments-as-exitcode=True clang-tidy-review-output.json |