Enable clang-tidy on CI

This commit is contained in:
Sebastian Messmer 2018-10-14 22:38:05 +02:00
parent 4b26c67146
commit c571d18411
3 changed files with 48 additions and 4 deletions

View File

@ -57,9 +57,11 @@ references:
# They aren't set automatically unfortunately
sudo ln -s /usr/bin/$CC /usr/bin/clang
sudo ln -s /usr/bin/$CXX /usr/bin/clang++
sudo ln -s /usr/bin/clang-tidy-7 /usr/bin/clang-tidy
sudo ln -s /usr/bin/run-clang-tidy-7.py /usr/bin/run-clang-tidy.py
# Need a c++14 compliant STL for clang
sudo apt-get install g++-5
sudo apt-get install -y g++-5
sudo apt-get remove g++-4.8 gcc-4.8
fi
@ -457,6 +459,36 @@ jobs:
DISABLE_BROKEN_TSAN_TESTS: true
CMAKE_FLAGS: ""
RUN_TESTS: true
clang_tidy:
<<: *container_config
steps:
- <<: *cache_init
- <<: *container_setup_pre
- <<: *container_setup
- <<: *container_setup_post
- <<: *upgrade_boost_pre
- <<: *upgrade_boost
- <<: *upgrade_boost_post
- checkout
- run:
name: clang-tidy
command: |
# realpath, jq are needed for run-clang-tidy.sh, g++ is needed for pyyaml
sudo apt-get install realpath g++ jq
pip install pyyaml
mkdir cmake
cd cmake
if ! ../run-clang-tidy.sh -fix ; then
git diff > /tmp/clang-tidy-fixes
exit 1
fi
- store_artifacts:
path: /tmp/clang-tidy-fixes
environment:
CC: clang-7
CXX: clang++-7
BUILD_TOOLSET: clang
APT_COMPILER_PACKAGE: "clang-7 clang-tidy-7"
workflows:
version: 2
@ -507,3 +539,5 @@ workflows:
<<: *enable_for_tags
- thread_sanitizer:
<<: *enable_for_tags
- clang_tidy:
<<: *enable_for_tags

View File

@ -12,6 +12,9 @@ Checks: |
boost-use-to-string,
-cert-env33-c,
-cert-err58-cpp,
-cert-err60-cpp,
-bugprone-macro-parentheses,
-bugprone-exception-escape,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-no-malloc,
-cppcoreguidelines-pro-type-const-cast,
@ -21,10 +24,11 @@ Checks: |
-cppcoreguidelines-pro-type-cstyle-cast,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-avoid-goto,
-clang-analyzer-optin.cplusplus.VirtualCall,
-misc-macro-parentheses,
-misc-unused-raii
#WarningsAsErrors: '*'
WarningsAsErrors: ''
WarningsAsErrors: '*'
HeaderFilterRegex: '/src/|/test/'
CheckOptions:
- key: google-readability-braces-around-statements.ShortStatementLines

View File

@ -8,9 +8,15 @@
set -e
NUMCORES=`nproc`
export NUMCORES=`nproc` && if [ ! -n "$NUMCORES" ]; then export NUMCORES=`sysctl -n hw.ncpu`; fi
echo Using ${NUMCORES} cores
# Run cmake in current working directory, but on source that is in the same directory as this script file
cmake -DBUILD_TESTING=on -DCMAKE_EXPORT_COMPILE_COMMANDS=ON "${0%/*}"
# Filter all third party code from the compilation database
cat compile_commands.json|jq "map(select(.file | test(\"^$(realpath ${0%/*})/(src|test)/.*$\")))" > compile_commands2.json
rm compile_commands.json
mv compile_commands2.json compile_commands.json
run-clang-tidy.py -j${NUMCORES} -quiet -header-filter "$(realpath ${0%/*})/(src|test)/.*" $@