Skip to content

Commit

Permalink
Add clangtidy workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Soren Soe <2106410+stsoe@users.noreply.github.com>
  • Loading branch information
stsoe committed Feb 28, 2025
1 parent 7cdb18a commit 028c6f5
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/cpp/aiebu/src/.clang-tidy → .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,28 @@
# clang-tidy looks for .clang-tidy file walking up the source directory structure to identify which checks to run
# One can customize checks in specific source directories by placing custom .clang-tidy in those source directories
Checks: '
readability-const-return-type,
clang-diagnostic-*,
clang-analyzer-*,
cert-*,
bugprone-*,
-bugprone-empty-catch,
clang-analyzer-*,
concurrency-*,
cppcoreguidelines-*,
hicpp-*,
-hicpp-no-array-decay,
-hicpp-signed-bitwise,
-hicpp-named-parameter,
modernize-*,
-modernize-use-trailing-return-type,
-modernize-use-nodiscard,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-pro-type-union-access,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-pro-bounds-constant-array-index,
-llvmlibc-*
'

WarningsAsErrors: ''
Expand Down Expand Up @@ -95,6 +100,10 @@ CheckOptions:
value: '0'
- key: bugprone-too-small-loop-variable.MagnitudeBitsUpperLimit
value: '16'
- key: bugprone-easily-swappable-parameters.NamePrefixSuffixSilenceDissimilarityTreshold
value: '1'
- key: bugprone-easily-swappable-parameters.MinimumLength
value: '3'
- key: bugprone-unhandled-self-assignment.WarnOnlyIfThisHasSuspiciousField
value: '1'
- key: bugprone-unused-return-value.CheckedFunctions
Expand All @@ -117,6 +126,8 @@ CheckOptions:
value: llvm
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
value: '0'
- key: cppcoreguidelines-avoid-non-const-global-variables.AllowInternalLinkage
value: '1'
- key: cppcoreguidelines-avoid-magic-numbers.IgnoredFloatingPointValues
value: '1.0;100.0;'
- key: cppcoreguidelines-avoid-magic-numbers.IgnoredIntegerValues
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/clangtidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# SPDX-License-Identifier: MIT
# Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.
name: Clang-Tidy Review

on:
pull_request:
types: [opened, synchronize]
branches: main-ge

workflow_dispatch:

jobs:
clangtidy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch base branch
run: |
git fetch origin ${{ github.base_ref }}
- name: Install clang-tidy
run: |
sudo apt install -y clang-tidy
- name: Build and generate compile_commands.json
run: |
cmake -B build/Release \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_INSTALL_PREFIX=build/Release
cmake --build build/Release --config Release
- name: Run clang-tidy
run: |
git diff -U0 origin/${{ github.base_ref }}...HEAD | \
clang-tidy-diff -p1 -path build -export-fixes build/Release/clang-tidy-fixes.yml
- name: Post clang-tidy comments
#uses: ZedThree/clang-tidy-review@v0.20.1
uses: stsoe/clang-tidy-review@6d2aee59f56cf41f32baa4123cc636fff8ef4eb7
with:
build_dir: build/Release
# disable default checks and rely on closest .clangtidy
clang_tidy_checks: ''
token: ${{ secrets.GITHUB_TOKEN }}

# If there are any comments, fail the check
- if: ${{ failure() && steps.clang-tidy.conclusion == 'failure' }}
run: exit 1

0 comments on commit 028c6f5

Please sign in to comment.