Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add clang tidy support to CI #49

Merged
merged 2 commits into from Jan 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions .circleci/clang_tidy.sh
@@ -0,0 +1,16 @@
# run clang tidy
cmake -DENABLE_CLANG_TIDY=ON .
make tidy > output.txt
#if [[ -n $(grep "warning: " output.txt) ]] || [[ -n $(grep "error: " output.txt) ]]; then
# for now only fail the test on errors. Change this as project matures
if [[ -n $(grep "error: " output.txt) ]]; then
echo "You must pass the clang tidy checks before submitting a pull request"
echo ""
grep --color -E '^|warning: |error: ' output.txt
exit -1;
else
# still output the file to show warnings
echo ""
grep --color -E '^|warning: |error: ' output.txt
echo -e "\033[1;32m\xE2\x9C\x93 passed:\033[0m $1";
fi
7 changes: 5 additions & 2 deletions .circleci/config.yml
Expand Up @@ -48,7 +48,7 @@ jobs:
sudo apt-add-repository -y "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-5.0 main"
sudo apt-add-repository -y ppa:george-edison55/cmake-3.x
sudo apt-get update
sudo apt-get -y install clang-5.0 lcov cmake
sudo apt-get -y install clang-5.0 clang-tidy-5.0 lcov cmake
- run:
name: Make scripts executable
command: sudo chmod -R +x ./.circleci/*.sh
Expand All @@ -58,6 +58,9 @@ jobs:
- run:
name: Build
command: ./.circleci/script_desktop.sh
- run:
name: Clang Tidy
command: ./.circleci/clang_tidy.sh
build-macos-9-2:
macos:
xcode: "9.2.0"
Expand Down Expand Up @@ -96,4 +99,4 @@ workflows:
- build-linux-gcc7
- build-linux-clang-5
- build-macos-9-2
- build-macos-9-3
- build-macos-9-3
32 changes: 32 additions & 0 deletions CMakeLists.txt
Expand Up @@ -11,6 +11,7 @@ HunterGate(
)
project(Ark-Cpp-Client)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 11)

set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR})
Expand All @@ -30,6 +31,37 @@ execute_process(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)

# ------------------------------------------------------------------------------
# Clang Tidy
# ------------------------------------------------------------------------------

if(ENABLE_CLANG_TIDY)

find_program(CLANG_TIDY_BIN clang-tidy-5.0)
find_program(RUN_CLANG_TIDY_BIN run-clang-tidy-5.0.py)

if(CLANG_TIDY_BIN STREQUAL "CLANG_TIDY_BIN-NOTFOUND")
message(FATAL_ERROR "unable to locate clang-tidy-5.0")
endif()

if(RUN_CLANG_TIDY_BIN STREQUAL "RUN_CLANG_TIDY_BIN-NOTFOUND")
message(FATAL_ERROR "unable to locate run-clang-tidy-5.0.py")
endif()

list(APPEND RUN_CLANG_TIDY_BIN_ARGS
-clang-tidy-binary ${CLANG_TIDY_BIN}
-header-filter=.*
-checks=clan*,cert*,misc*,perf*,cppc*,read*,mode*,-cert-err58-cpp,-misc-noexcept-move-constructor
)

add_custom_target(
tidy
COMMAND ${RUN_CLANG_TIDY_BIN} ${RUN_CLANG_TIDY_BIN_ARGS}
COMMENT "running clang tidy"
)

endif()

add_subdirectory(src)
add_subdirectory(test)