ci: Replace clang-tidy-diff with full clang-tidy on changed files

This commit is contained in:
Eduardo Almeida
2025-04-11 18:39:05 +01:00
parent 0485fa6dcf
commit 399e31bb90

View File

@@ -53,22 +53,21 @@ clang-tidy-19:
- git remote add -t $CI_DEFAULT_BRANCH --no-tags -f upstream https://gitlab.com/nsnam/ns-3-dev.git
- git diff --name-only upstream/$CI_DEFAULT_BRANCH > $FILES_CHANGED
# Run full clang-tidy in the following cases: 1) default branch, 2) ".clang-tidy" file changed
# Run clang-tidy-diff in the opposite cases.
# Run clang-tidy on all files in the following cases: 1) default branch, 2) ".clang-tidy" file changed
# Otherwise, run clang-tidy on changed files only.
# File paths generated by git diff are relative to the working tree. Therefore, iregex should only contain paths relative to the working tree.
- if [[ $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH ]] || (grep -q ".clang-tidy" $FILES_CHANGED) ; then
echo "Running full clang-tidy" ;
run-clang-tidy-19 -p cmake-cache/ -quiet
1> $CLANG_TIDY_OUTPUT
2> /dev/null ;
- |
if [[ $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH ]] || (grep -q ".clang-tidy" $FILES_CHANGED) ; then
FILES_TO_CHECK="";
echo "Running clang-tidy on all files";
else
echo "Running clang-tidy-diff" ;
git diff -U0 upstream/$CI_DEFAULT_BRANCH |
clang-tidy-diff-19.py -path cmake-cache/ -p1 -quiet -use-color
-iregex "(contrib|examples|src|scratch|utils)\/.+\.(cpp|cc|cxx|h|hpp)"
1> $CLANG_TIDY_OUTPUT
2> /dev/null || true ;
FILES_TO_CHECK=$(cat $FILES_CHANGED);
echo "Running clang-tidy on the following changed files:";
echo $FILES_TO_CHECK;
fi
- run-clang-tidy-19 -p cmake-cache/ -quiet $FILES_TO_CHECK
1> $CLANG_TIDY_OUTPUT
2> /dev/null
# Trim empty lines from output file
- sed -i '/^$/d' $CLANG_TIDY_OUTPUT