From e48ffcf42ef3b7af64455f482caa112674364418 Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Tue, 31 Oct 2023 20:23:12 +0000 Subject: [PATCH] ci: Merge both if conditions in clang-tidy job script --- utils/tests/gitlab-ci-code-linting.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/utils/tests/gitlab-ci-code-linting.yml b/utils/tests/gitlab-ci-code-linting.yml index fa6f664bf..b675ab561 100644 --- a/utils/tests/gitlab-ci-code-linting.yml +++ b/utils/tests/gitlab-ci-code-linting.yml @@ -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"