ci: Do not run clang-tidy-diff when also running full clang-tidy

This commit is contained in:
Eduardo Almeida
2023-05-03 05:30:03 +01:00
parent 71a214636d
commit a7214a780d

View File

@@ -22,6 +22,7 @@ clang-tidy:
variables:
MPI_CI: 1
CLANG_TIDY_OUTPUT: clang-tidy-output.log
FILES_CHANGED: git-diff-name-only.log
before_script:
- apt update
- DEBIAN_FRONTEND=noninteractive apt install -y
@@ -43,17 +44,21 @@ clang-tidy:
git remote add upstream https://gitlab.com/nsnam/ns-3-dev.git ;
fi
- git fetch upstream $CI_DEFAULT_BRANCH
- git diff --name-only upstream/$CI_DEFAULT_BRANCH > $FILES_CHANGED
# Run clang-tidy-diff. If running on default branch, Git diff is empty and this is ignored.
# Run clang-tidy-diff in the opposite cases of the if-else below.
# File paths generated by git diff are relative to the working tree. Therefore, iregex should only contain paths relative to the working tree.
- git diff -U0 upstream/$CI_DEFAULT_BRANCH |
- if !([[ $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH ]] || (grep -q ".clang-tidy" $FILES_CHANGED)) ; then
echo "Running clang-tidy-diff" ;
git diff -U0 upstream/$CI_DEFAULT_BRANCH |
clang-tidy-diff-14.py -path cmake-cache/ -p1 -quiet -use-color
-iregex "(contrib|examples|src|scratch|utils)\/.+\.(cpp|cc|cxx|c|h|hpp)"
1> $CLANG_TIDY_OUTPUT
2> /dev/null
2> /dev/null ;
fi
# Run full clang-tidy in the following cases: 1) default branch, 2) ".clang-tidy" file changed, 3) clang-tidy-diff had an error
- if [[ $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH ]] || (echo $(git diff --name-only upstream/$CI_DEFAULT_BRANCH) | grep -q ".clang-tidy") || (egrep -q -A 3 "file not found \[clang-diagnostic-error\]" $CLANG_TIDY_OUTPUT) ; then
- if [[ $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH ]] || (grep -q ".clang-tidy" $FILES_CHANGED) || (egrep -q -A 3 "file not found \[clang-diagnostic-error\]" $CLANG_TIDY_OUTPUT) ; then
echo "Running full clang-tidy" ;
run-clang-tidy-14 -p cmake-cache/ -quiet
1> $CLANG_TIDY_OUTPUT