From 399e31bb9059797f1c511e05776cb94fadab9f53 Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Fri, 11 Apr 2025 18:39:05 +0100 Subject: [PATCH] ci: Replace clang-tidy-diff with full clang-tidy on changed files --- utils/tests/gitlab-ci-code-linting.yml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/utils/tests/gitlab-ci-code-linting.yml b/utils/tests/gitlab-ci-code-linting.yml index bf52b0594..7b701c43e 100644 --- a/utils/tests/gitlab-ci-code-linting.yml +++ b/utils/tests/gitlab-ci-code-linting.yml @@ -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