Skip to content

Commit

Permalink
CICD: Integrate clang tidy with cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Saverio976 committed Sep 23, 2023
1 parent a34b05a commit e3e379d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,clang-analyzer-*,concurrency-*,cppcoreguidelines-*,modernize-*,portability-*,readability-*,-readability-identifier-length'
WarningsAsErrors: 'clang-diagnostic-*,clang-analyzer-*,-*,clang-analyzer-*,concurrency-*,cppcoreguidelines-*,modernize-*,portability-*,readability-*,-readability-identifier-length'
Checks: '-*,clang-diagnostic-*,clang-analyzer-*,-*,clang-analyzer-*,concurrency-*,cppcoreguidelines-*,modernize-*,portability-*,readability-*,-readability-identifier-length'
WarningsAsErrors: '-*,clang-diagnostic-*,clang-analyzer-*,-*,clang-analyzer-*,concurrency-*,cppcoreguidelines-*,modernize-*,portability-*,readability-*,-readability-identifier-length'
HeaderFilterRegex: '(src/ECS/)|(src/Client/)|(src/Server/)'
AnalyzeTemporaryDtors: false
1 change: 0 additions & 1 deletion .github/workflows/compil.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
run: |
winget install --accept-package-agreements --accept-source-agreements CMake
winget install --accept-package-agreements --accept-source-agreements LLVM
winget install --accept-package-agreements --accept-source-agreements --id=GnuWin32.Make -e
- name: Compil
run: ./scripts/compil.ps1 --dry-run
Expand Down
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ cmake_minimum_required(VERSION 3.15)

set(CMAKE_CXX_STANDARD 20)

find_program(CLANG_TIDY_EXE NAMES "clang-tidy")

if(CLANG_TIDY_EXE)
set(CLANG_TIDY_COMMAND "${CLANG_TIDY_EXE}" "--fix" "--fix-notes" "--fix-errors" "-header-filter=(src/ECS/)|(src/Client/)|(src/Server/)" "-checks=-*,clang-diagnostic-*,clang-analyzer-*,-*,clang-analyzer-*,concurrency-*,cppcoreguidelines-*,modernize-*,portability-*,readability-*,-readability-identifier-length")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
endif()

if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
Expand Down
7 changes: 0 additions & 7 deletions scripts/compil.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,4 @@

$ErrorActionPreference = 'Stop'

cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

if ($args.Count -gt 0 -and $args[0] -eq '--dry-run') {
$files = Get-Childitem -Path src -Include *.cpp -Recurse -ErrorAction SilentlyContinue
clang-tidy -format-style=file --fix --fix-notes --fix-errors -p build $files
}

cmake --build build
10 changes: 1 addition & 9 deletions scripts/compil.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,4 @@

set -ex

cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

if [[ "$1" == "--dry-run" ]]; then
find src/ \( -name '*.cpp' -o -name '*.hpp' \) -print0 \
| xargs -0 \
clang-tidy -format-style=file -p build --fix --fix-notes --fix-errors
fi

cmake --build build
cmake --build build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

0 comments on commit e3e379d

Please sign in to comment.