ci: Merge both if conditions in clang-tidy job script

This commit is contained in:
Eduardo Almeida
2023-10-31 20:23:12 +00:00
parent 7e2952b102
commit e48ffcf42e

View File

@@ -62,9 +62,15 @@ clang-tidy-17:
- 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 clang-tidy-diff in the opposite cases of the if-else below.
# Run full clang-tidy in the following cases: 1) default branch, 2) ".clang-tidy" file changed
# Run clang-tidy-diff in the opposite cases.
# 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
- if [[ $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH ]] || (grep -q ".clang-tidy" $FILES_CHANGED) ; then
echo "Running full clang-tidy" ;
run-clang-tidy-17 -p cmake-cache/ -quiet
1> $CLANG_TIDY_OUTPUT
2> /dev/null ;
else
echo "Running clang-tidy-diff" ;
git diff -U0 upstream/$CI_DEFAULT_BRANCH |
clang-tidy-diff-17.py -path cmake-cache/ -p1 -quiet -use-color
@@ -73,14 +79,6 @@ clang-tidy-17:
2> /dev/null ;
fi
# Run full clang-tidy in the following cases: 1) default branch, 2) ".clang-tidy" file changed
- if [[ $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH ]] || (grep -q ".clang-tidy" $FILES_CHANGED) ; then
echo "Running full clang-tidy" ;
run-clang-tidy-17 -p cmake-cache/ -quiet
1> $CLANG_TIDY_OUTPUT
2> /dev/null ;
fi
# Check job results
- (! egrep -v "file not found \[clang-diagnostic-error\]" $CLANG_TIDY_OUTPUT | egrep -A3 "error:|warning:|note:")
- echo "No clang-tidy errors found"