--- /dev/null
+# Settings file automatically used by clang-tidy
+#
+# See ./contrib/utilities/run_clang_tidy.sh for details
+
+# We disable performance-inefficient-string-concatenation because we don't care about "a"+to_string(5)+...
+
+Checks: "-*,cppcoreguidelines-pro-type-static-cast-downcast,google-readability-casting,modernize-*,-modernize-pass-by-value,-modernize-raw-string-literal,-modernize-use-auto,-modernize-use-override,-modernize-use-default-member-init,-modernize-use-transparent-functors,use-emplace,mpi-*,performance-*,-performance-inefficient-string-concatenation"
+
+WarningsAsErrors: '*'
--- /dev/null
+#!groovy
+
+/*
+Settings to apply inside Jenkins:
+ - discover pull requests (remove branches/master)
+ - Strategy: merged PR
+ - enable "Disable GitHub Multibranch Status Plugin"
+ - trigger build on pull request comment: .* /rebuild.* (without space!)
+ - Jenkinsfile: choose contrib/ci/Jenkinsfile.tidy
+ - scan: every 4 hours
+ - discard: 5+ items
+*/
+
+pipeline
+{
+ agent none
+
+ stages
+ {
+ stage("check")
+ {
+ when {
+ allOf {
+ not {branch 'master'}
+ }
+ }
+
+ agent
+ {
+ docker
+ {
+ image 'dealii/indent'
+ }
+ }
+
+ steps
+ {
+ githubNotify context: 'tidy', description: 'pending...', status: 'PENDING'
+ sh '''
+ wget -q -O - https://api.github.com/repos/dealii/dealii/issues/${CHANGE_ID}/labels | grep 'ready to test' || \
+ { echo "This commit will only be tested when it has the label 'ready to test'. Trigger a rebuild by adding a comment that contains '/rebuild'..."; exit 1; }
+ '''
+ }
+ post
+ {
+ failure
+ {
+ githubNotify context: 'tidy', description: 'need ready to test label and /rebuild', status: 'PENDING'
+ script
+ {
+ currentBuild.result='NOT_BUILT'
+ }
+ }
+ }
+ }
+
+ stage('build')
+ {
+ agent
+ {
+ docker
+ {
+ image 'tjhei/candi-base-clang'
+ }
+ }
+ steps
+ {
+ timeout(time: 2, unit: 'HOURS')
+ {
+ sh "echo \"building on node ${env.NODE_NAME}\""
+
+ sh '''#!/bin/bash
+ mkdir build && cd build
+ $WORKSPACE/contrib/utilities/run_clang_tidy.sh $WORKSPACE
+ '''
+ githubNotify context: 'tidy', description: 'OK', status: 'SUCCESS'
+ }
+ }
+
+ post
+ {
+ failure
+ {
+ githubNotify context: 'tidy', description: 'build failed', status: 'FAILURE'
+ }
+ }
+ }
+
+ }
+}
# Usage:
# /contrib/utilities/run_clang_tidy.sh SRC_DIR OPTIONAL_CMAKE_ARGS
# with:
-# SRC_DIR is an absolute path to a deal.II source directory
+# SRC_DIR points to a deal.II source directory
# OPTIONAL_CMAKE_ARGS are optional arguments to pass to CMake
# make sure to run this script in an empty build directory
#
# Clang 5.0.1+ and have clang, clang++, and run-clang-tidy.py in
# your path.
-# grab first argument:
+# grab first argument and make relative path an absolute one:
SRC=$1
+SRC=$(cd "$SRC";pwd)
shift
if test ! -d "$SRC/source" -o ! -d "$SRC/include" -o ! -d "$SRC/examples" -o ! -f "$SRC/CMakeLists.txt" ; then
fi
echo "SRC-DIR=$SRC"
-# do not allow bundled packages, otherwise we get too many warnings from TBB/UMFPACK/etc.
# enable MPI (to get MPI warnings)
# export compile commands (so that run-clang-tidy.py works)
-ARGS="-D DEAL_II_ALLOW_BUNDLED=OFF -D DEAL_II_WITH_MPI=ON -D CMAKE_EXPORT_COMPILE_COMMANDS=ON $@"
+ARGS=("-D" "DEAL_II_WITH_MPI=ON" "-D" "CMAKE_EXPORT_COMPILE_COMMANDS=ON" "$@")
-# disable performance-inefficient-string-concatenation because we don't care about "a"+to_string(5)+...
-CHECKS="-*,
- cppcoreguidelines-pro-type-static-cast-downcast,
- google-readability-casting,
- modernize-*,
- -modernize-pass-by-value,
- -modernize-raw-string-literal,
- -modernize-use-auto,
- -modernize-use-override,
- -modernize-use-default-member-init,
- -modernize-use-transparent-functors,
- mpi-*,
- performance-*,
- -performance-inefficient-string-concatenation"
-
-CHECKS="$(echo "${CHECKS}" | tr -d '[:space:]')"
-echo "$CHECKS"
+# for a list of checks, see /.clang-tidy
+cat "$SRC/.clang-tidy"
if ! [ -x "$(command -v run-clang-tidy.py)" ] || ! [ -x "$(command -v clang++)" ]; then
echo "make sure clang, clang++, and run-clang-tidy.py (part of clang) are in the path"
exit 2
fi
-CC=clang CXX=clang++ cmake $ARGS "$SRC" || (echo "cmake failed!"; false) || exit 2
+CC=clang CXX=clang++ cmake "${ARGS[@]}" "$SRC" || (echo "cmake failed!"; false) || exit 2
cmake --build . --target expand_all_instantiations || (echo "make expand_all_instantiations failed!"; false) || exit 3
-run-clang-tidy.py -p . -checks="$CHECKS" -quiet -header-filter="$SRC/include/*" -fix
+# finally run it:
+# pipe away stderr (just contains nonsensical "x warnings generated")
+# pipe output to output.txt
+run-clang-tidy.py -p . -quiet -header-filter="$SRC/include/*" 2>error.txt >output.txt
+
+if grep -E -q '(warning|error): ' output.txt; then
+ grep -E '(warning|error): ' output.txt
+ exit 4
+fi
+
+echo "OK"
+exit 0
+