Verified Commit be755738 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Partially revert "Only run clang-tidy on changed files"

This reverts commit 5ee545dc.
parent 0ccacc58
# Ignore generated files that we can't do anything about (no major issues there, though)
resourcebasesettings.cpp
designerplugin.cpp
# Ignore generated Q_LOGGING_CATEGORY files, the checks take forever for some reason
# and are generated anyway.
[a-z_]+_debug.cpp
mocs_[a-z_]+.cpp
# Ignore autotests and tests, it halves the run time
autotests/
tests/
......@@ -9,7 +9,7 @@ build_clazy_clang_tidy:
only:
- merge_requests
before_script:
- zypper install -y clazy gnu_parallel
- zypper install -y clazy jq
- git clone --depth=1 https://invent.kde.org/sysadmin/ci-tooling.git $CI_TOOLING
- git clone --depth=1 https://invent.kde.org/sysadmin/repo-metadata.git $CI_TOOLING/repo-metadata
- git clone --depth=1 https://invent.kde.org/sysadmin/kde-build-metadata.git $CI_TOOLING/kde-build-metadata
......@@ -24,7 +24,7 @@ build_clazy_clang_tidy:
- python3 -u $CI_TOOLING/helpers/prepare-dependencies.py --product $PRODUCT --project $PROJECT --branchGroup $BRANCH_GROUP --environment production --platform $PLATFORM --installTo $INSTALL_PREFIX
- python3 -u $CI_TOOLING/helpers/configure-build.py --product $PRODUCT --project $PROJECT --branchGroup $BRANCH_GROUP --platform $PLATFORM --installTo $INSTALL_PREFIX
- python3 -u $CI_TOOLING/helpers/compile-build.py --product $PRODUCT --project $PROJECT --branchGroup $BRANCH_GROUP --platform $PLATFORM --usingInstall $INSTALL_PREFIX
- time ./tools/run-clang-tidy.sh $(pwd) $(pwd)/build $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
- time ./tools/run-clang-tidy.sh $(pwd) $(pwd)/build
variables:
PLATFORM: SUSEQt5.14
BRANCH_GROUP: kf5-qt5
......
#!/bin/bash
#!/bin/sh
# Copyright (c) 2020 Daniel Vrátil <dvratil@kde.org>
#
# This library is free software; you can redistribute it and/or modify it
......@@ -15,34 +15,45 @@
# along with this library; see the file COPYING.LIB. If not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
# Inspired by https://pspdfkit.com/blog/2018/using-clang-tidy-and-integrating-it-in-jenkins/
if [ $# -lt 2 ]; then
>&2 echo "Usage: $0 SRC_DIR BUILD_DIR [TARGET_BRANCH]"
>&2 echo "Usage: $0 SOURCE_DIR BUILD_DIR"
exit 1
fi
set -xe
if [ ! -d .git ]; then
>&2 echo "run-clang-tidy.sh must be ran in a git clone of the Akonadi repository!"
exit 1
fi
source_dir=$1; shift
build_dir=$1; shift 1
dir=$(dirname $(readlink -f "$0"))
src_dir=$1; shift
build_dir=$1; shift
if [ $# -ge 1 ]; then
merge_branch=$1; shift
else
merge_branch="master"
fi
base_commit=$(git merge-base refs/remotes/origin/${merge_branch} HEAD)
changed_files=$(git diff-tree --name-only --diff-filter=d -r ${base_commit} HEAD \
| grep -E "\.cpp|\.h" \
| grep -Ev "^autotests/|^tests/")
function sanitize_compile_commands
{
local cc_file=${build_dir}/compile_commands.json
local filter_file="${source_dir}/.clang-tidy-ignore"
if [ ! -f "${cc_file}" ]; then
>&2 echo "Couldn't find compile_commands.json"
exit 1
fi
if [ ! -f "${filter_file}" ]; then
return 0
fi
filter_files=$(cat ${filter_file} | grep -vE "^#\.*|^$" | tr '\n' '|' | head -c -1)
local cc_bak_file=${cc_file}.bak
mv ${cc_file} ${cc_bak_file}
cat ${cc_bak_file} \
| jq -r "map(select(.file|test(\"${filter_files}\")|not))" \
> ${cc_file}
task_count=$(cat ${cc_file} | jq "length")
}
sanitize_compile_commands
parallel run-clang-tidy -q -p ${build_dir} {} ::: ${changed_files} | tee "${build_dir}/clang-tidy.log"
run-clang-tidy -p ${build_dir} -j$(nproc) -q $@ | tee ${build_dir}/clang-tidy.log
cat ${build_dir}/clang-tidy.log | ${source_dir}/tools/clang-tidy-to-junit ${source_dir} > ${build_dir}/clang-tidy-report.xml
cat "${build_dir}/clang-tidy.log" | ${dir}/clang-tidy-to-junit.py ${src_dir} > "${build_dir}/clang-tidy-report.xml"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment