scan GUI sources with clang-tidy in CI (#3233)

* build UI dependencies before running clang-tidy

* clang-tidy.yml: enabled GUI sources and build some dependencies for clang-tidy

* work around missing dependency for Qt install step
This commit is contained in:
Oliver Stöneberg 2021-10-31 20:15:32 +01:00 committed by GitHub
parent df59b07ba1
commit 54d621555d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 9 deletions

View File

@ -21,23 +21,24 @@ jobs:
apt-get install -y cmake g++ make
apt-get install -y z3 libz3-dev
apt-get install -y libpcre3-dev
apt-get install -y libffi7 # work around missing dependency for Qt install step
apt-get install -y software-properties-common
add-apt-repository universe
apt-get update
apt-get install -y clang-tidy-13
# uses "sudo" internally which is not available on docker by default
#- name: Install Qt
# uses: jurplel/install-qt-action@v2
# with:
# modules: 'qtcharts'
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
install-deps: 'nosudo'
version: '5.15.2'
modules: 'qtcharts'
- name: Prepare CMake
run: |
mkdir cmake.output
cd cmake.output
# cannot include GUI since we need to generate the ui_*.h files first
cmake -G "Unix Makefiles" -DUSE_Z3=On -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=Off -DWITH_QCHART=Off ..
cmake -G "Unix Makefiles" -DUSE_Z3=On -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On ..
cd ..
- name: Clang-Tidy
@ -45,4 +46,5 @@ jobs:
# make sure the precompiled headers exist
make -C cmake.output lib/CMakeFiles/lib_objs.dir/cmake_pch.hxx.cxx
make -C cmake.output test/CMakeFiles/testrunner.dir/cmake_pch.hxx.cxx
make -C cmake.output autogen
cmake --build cmake.output --target run-clang-tidy 2> /dev/null

View File

@ -12,4 +12,10 @@ message(STATUS "RUN_CLANG_TIDY=${RUN_CLANG_TIDY}")
if (RUN_CLANG_TIDY)
# disable all compiler warnings since we are just interested in the tidy ones
add_custom_target(run-clang-tidy ${RUN_CLANG_TIDY} -p=${CMAKE_BINARY_DIR} -j ${NPROC} -extra-arg=-w -quiet)
if (BUILD_GUI)
add_dependencies(run-clang-tidy gui-build-deps)
if (BUILD_TESTS)
add_dependencies(run-clang-tidy triage-build-ui-deps)
endif()
endif()
endif()

View File

@ -15,12 +15,15 @@ if (BUILD_GUI)
QT5_WRAP_UI(uis_hdrs ${uis})
QT5_ADD_RESOURCES(resources "gui.qrc")
QT5_ADD_TRANSLATION(qms ${tss})
list(APPEND cppcheck-gui_SOURCES ${hdrs} ${srcs} ${uis_hdrs} ${resources} ${qms} $<TARGET_OBJECTS:lib_objs> $<TARGET_OBJECTS:simplecpp_objs>)
list(APPEND cppcheck-gui-deps ${hdrs} ${uis_hdrs} ${resources} ${qms} )
add_custom_target(gui-build-deps SOURCES ${cppcheck-gui-deps})
list(APPEND cppcheck-gui_SOURCES ${srcs} $<TARGET_OBJECTS:lib_objs> $<TARGET_OBJECTS:simplecpp_objs>)
if(USE_BUNDLED_TINYXML2)
list(APPEND cppcheck-gui_SOURCES $<TARGET_OBJECTS:tinyxml2_objs>)
endif()
add_executable(cppcheck-gui ${cppcheck-gui_SOURCES})
add_executable(cppcheck-gui ${cppcheck-gui-deps} ${cppcheck-gui_SOURCES})
set_target_properties(cppcheck-gui PROPERTIES AUTOMOC ON)
target_include_directories(cppcheck-gui PRIVATE ${PROJECT_SOURCE_DIR}/lib/)
if(USE_BUNDLED_TINYXML2)

View File

@ -12,6 +12,7 @@ if (BUILD_GUI AND BUILD_TESTS)
file(GLOB uis "*.ui")
qt5_wrap_ui(uis_hdrs ${uis})
add_custom_target(triage-build-ui-deps SOURCES ${hdrs} ${uis_hdrs})
add_executable(
triage
${hdrs}