From 8f96b6467a81d6884441f8ab8127d73952f54715 Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Fri, 1 Nov 2019 11:33:42 +0000 Subject: [PATCH] + ci-config with clang-tidy --- .ci/clang-tidy.sh | 32 ++++++++++++++++++++++++++++++++ .gitlab-ci.yml | 47 +++++++++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 1 - 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 .ci/clang-tidy.sh create mode 100644 .gitlab-ci.yml diff --git a/.ci/clang-tidy.sh b/.ci/clang-tidy.sh new file mode 100644 index 0000000..8b7c6f2 --- /dev/null +++ b/.ci/clang-tidy.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +echo "Doing clang-tidy..." +bool=false +# explicitly set IFS to contain only a line feed +IFS=' +' +filelist="$(find . -not -not \( -path './client/cpptoml/*' -prune \) -type f ! -name "$(printf "*\n*")")" +for file in $filelist; do + if echo "$file" | grep -q -E ".*\.cpp$" ; then + #Extra check missing dependencies due to clang-tidy doesn't toggle exit code. + clang_tidy_lib_check="$(clang-tidy -warnings-as-errors='*' -header-filter='.*,-cpptoml.hpp' -checks='*,-llvm-header-guard,-fuchsia-statically-constructed-objects,-fuchsia-default-arguments,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-constant-array-index,-bugprone-narrowing-conversions,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-hicpp-signed-bitwise,-bugprone-exception-escape,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-cstyle-cast,-hicpp-member-init' "$file" -- -I. -std=c++14 2>&1)" + for tidy_line in $clang_tidy_lib_check; do + echo "$tidy_line" | grep -q -v -E "^Error while processing*" + if [ $? -eq 1 ]; then + bool=true + fi + echo "$tidy_line" | grep -q -v -E ".* error: .*" + if [ $? -eq 1 ]; then + bool=true + fi + echo "$tidy_line" + done + fi +done +if $bool; then + exit 1 +else + echo "No clang-tidy errors found." +fi + +exit 0 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..e731c7f --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,47 @@ +--- + +image: samueldebruyn/debian-git:latest + +stages: + - style + - test + - build + + +yamllint: + image: sdesbure/yamllint:latest + stage: lint + tags: + - docker-ci + script: + - apk update + - apk add --no-cache git + - git config --file=.gitmodules submodule.client.url ../client/client.git + - git config --file=.gitmodules submodule.shared-memory.url ../shared-memory/Shared-Memory.git + - git config --file=.gitmodules submodule.fltk.url ../fltk/fltk.git + - git submodule sync --recursive + - git submodule update --init client shared-memory fltk + - "#################################################################" + - yamllint --version + - "#################################################################" + - sh .ci/yamllint.sh + +clang_tidy: + image: jhase/ + tags: + - docker-ci + script: + - clang-tidy;-header-filter=.;-checks=*; + +make_test: + stage: test + tags: + - docker-ci + script: + - apt-get update + - apt-get install -y make cmake clang-tidy + - mkdir build + - cd build + - cmake .. + - make + - make test diff --git a/CMakeLists.txt b/CMakeLists.txt index 232b66e..4fbc7e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,6 @@ project(Terminal) set(CMAKE_CXX_STANDARD 14) # enable clang_tidy -set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-checks=*") set(CMAKE_CXX_CLANG_TIDY clang-tidy;-header-filter=.;-checks=*;) file(GLOB_RECURSE SOURCES src/*.cpp)