Skip to content

Commit

Permalink
[ci] Update and add clang-tidy build job
Browse files Browse the repository at this point in the history
  • Loading branch information
zach2good committed Jul 26, 2023
1 parent 052794f commit 6a3575c
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 34 deletions.
49 changes: 21 additions & 28 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,35 +1,28 @@
---
# https://clang.llvm.org/extra/clang-tidy/checks/list.html
# https://releases.llvm.org/14.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/list.html
Checks: >
-*,
bugprone-*,
-bugprone-parent-virtual-call,
-bugprone-reserved-identifier,
cert-flp30-c,
cert-mem57-cpp,
cert-oop57-cpp,
cert-oop58-cpp,
clang-analyzer-*,
concurrency-*,
cppcoreguidelines-*,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-owning-memory,
misc-*,
modernize-*,
-modernize-avoid-c-arrays,
-modernize-return-braced-init-list,
-modernize-use-auto,
-modernize-use-trailing-return-type,
cppcoreguidelines-avoid-goto,
cppcoreguidelines-init-variables,
cppcoreguidelines-no-malloc,
cppcoreguidelines-pro-type-const-cast,
cppcoreguidelines-pro-type-member-init,
cppcoreguidelines-slicing,
cppcoreguidelines-special-member-functions,
cppcoreguidelines-virtual-class-destructor,
misc-definitions-in-headers,
modernize-pass-by-value,
modernize-use-emplace,
modernize-use-nullptr,
modernize-use-override,
performance-*,
readability-*,
portability-*,
-readability-convert-member-functions-to-static,
-readability-else-after-return,
-readability-implicit-bool-conversion,
-readability-function-cognitive-complexity,
-readability-inconsistent-declaration-parameter-name,
-readability-magic-numbers,
-readability-uppercase-literal-suffix,
# TODO: Enable these
# concurrency-mt-unsafe,
# cppcoreguidelines-prefer-member-initializer,
# cppcoreguidelines-pro-type-vararg,

# TODO: These are important, but they're destructive. Turn on one day.
# cppcoreguidelines-pro-type-static-cast-downcast,
# cppcoreguidelines-pro-type-cstyle-cast,
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,32 @@ jobs:
run: |
cmake --build build -j4
Linux_Clang14_64bit_ClangTidy:
needs: Sanity_Checks
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y software-properties-common cmake libmariadb-dev-compat libluajit-5.1-dev libzmq3-dev zlib1g-dev libssl-dev binutils-dev
#- name: Cache 'build' folder
# uses: actions/cache@v3
# with:
# path: build
# key: ${{ runner.os }}-clang
- name: Configure CMake
run: |
export CC=/usr/bin/clang-14
export CXX=/usr/bin/clang++-14
mkdir -p build
cmake -S . -B build -DENABLE_CLANG_TIDY=ON
- name: Build
run: |
cmake --build build -j4
Full_Startup_Checks_Linux:
runs-on: ubuntu-22.04
needs: Linux_Clang14_64bit
Expand Down
6 changes: 3 additions & 3 deletions cmake/ClangTidy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ if(ENABLE_CLANG_TIDY)
message(WARNING "CMake_RUN_CLANG_TIDY is ON but clang-tidy is not found!")
set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE)
else()
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND};-header-filter='(${CMAKE_SOURCE_DIR}/src/.*|${CMAKE_SOURCE_DIR}/ext/.*|${CMAKE_BINARY_DIR}/.*)';-format-style='file'")
if(ENABLE_CLANG_TIDY_AUTO_FIX)
set(CLANG_TIDY_FIX "-fix")
set(CMAKE_CXX_CLANG_TIDY "${CMAKE_CXX_CLANG_TIDY};-fix")
endif()
message(STATUS "CLANG_TIDY_FIX: ${CLANG_TIDY_FIX}")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND};-header-filter='${CMAKE_SOURCE_DIR}/src/*';${CLANG_TIDY_FIX};-format-style='file'")
endif()
message(STATUS "CMAKE_CXX_CLANG_TIDY: ${CMAKE_CXX_CLANG_TIDY}")

# Create a preprocessor definition that depends on .clang-tidy content so
# the compile command will change when .clang-tidy changes. This ensures
Expand Down
4 changes: 3 additions & 1 deletion src/map/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ target_include_directories(xi_map
${module_include_dirs}
)

target_precompile_headers(xi_map PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/pch.h)
if(NOT ${ENABLE_CLANG_TIDY})
target_precompile_headers(xi_map PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/pch.h)
endif()

if (APPLE)
disable_lto(xi_map)
Expand Down
2 changes: 2 additions & 0 deletions src/map/ai/helpers/pathfind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ along with this program. If not, see http://www.gnu.org/licenses/
#include "lua/luautils.h"
#include "zone.h"

#include <cfloat>

namespace
{
bool arePositionsClose(const position_t& a, const position_t& b)
Expand Down
1 change: 1 addition & 0 deletions src/map/conquest_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ along with this program. If not, see http://www.gnu.org/licenses/
#include <string>

#include "common/cbasetypes.h"
#include "common/sql.h"
#include "zone.h"

struct region_control_t
Expand Down
3 changes: 3 additions & 0 deletions src/map/instance_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ along with this program. If not, see http://www.gnu.org/licenses/
#include "entities/charentity.h"
#include "entities/mobentity.h"
#include "entities/npcentity.h"
#include "instance.h"
#include "items/item_weapon.h"
#include "lua/luautils.h"
#include "mob_modifier.h"
#include "mob_spell_list.h"
#include "zone_entities.h"
#include "zone_instance.h"

#include "utils/instanceutils.h"
#include "utils/mobutils.h"
Expand Down
5 changes: 3 additions & 2 deletions src/map/items/item_linkshell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
===========================================================================
*/

#include "item_linkshell.h"

#include "common/socket.h"
#include "common/utils.h"

#include <cstring>

#include "item_linkshell.h"

CItemLinkshell::CItemLinkshell(uint16 id)
: CItem(id)
{
Expand Down
3 changes: 3 additions & 0 deletions src/map/zone_entities.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ along with this program. If not, see http://www.gnu.org/licenses/

#include "zone.h"

#include <set>
#include <vector>

class CZoneEntities
{
public:
Expand Down

0 comments on commit 6a3575c

Please sign in to comment.