diff --git a/utils/tests/gitlab-ci-code-linting.yml b/utils/tests/gitlab-ci-code-linting.yml index 105b65cd1..723ab9314 100644 --- a/utils/tests/gitlab-ci-code-linting.yml +++ b/utils/tests/gitlab-ci-code-linting.yml @@ -2,6 +2,7 @@ # # Contains jobs to check the ns-3 coding style and perform lint checking. +# Clang-format check-style-clang-format: stage: code-linting image: ubuntu:latest @@ -14,38 +15,73 @@ check-style-clang-format: - python3 utils/check-style-clang-format.py . timeout: 1h -clang-tidy: +# Clang-tidy +.base-clang-tidy: stage: code-linting image: ubuntu:latest variables: MPI_CI: 1 CLANG_TIDY_OUTPUT: clang-tidy-output.log + GIT_DEPTH: 0 before_script: - apt update - DEBIAN_FRONTEND=noninteractive apt install -y clang cmake - clang-tidy-14 + clang-tidy clang-tidy-14 python3 python3-pip libboost-all-dev libgtk-3-dev libopenmpi-dev libsqlite3-dev gsl-bin libgsl-dev libgsl27 - ssh + git ssh - pip3 install cppyy - script: - ./ns3 configure -d debug --enable-clang-tidy --enable-examples --enable-tests --enable-asserts --enable-mpi --enable-python-bindings - - run-clang-tidy-14 -p cmake-cache/ -quiet - 1> clang-tidy-errors.log - 2> /dev/null - - (! egrep -A 3 "error:|warning:|note:" $CLANG_TIDY_OUTPUT) - - echo "No clang-tidy errors found" artifacts: paths: - $CLANG_TIDY_OUTPUT when: on_failure timeout: 3h +clang-tidy: + extends: .base-clang-tidy + rules: + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + when: on_success + - changes: + paths: + - .clang-tidy + compare_to: master + when: on_success + script: + - run-clang-tidy-14 -p cmake-cache/ -quiet + 1> $CLANG_TIDY_OUTPUT + 2> /dev/null + - (! egrep -A 3 "error:|warning:|note:" $CLANG_TIDY_OUTPUT) + - echo "No clang-tidy errors found" + +clang-tidy-diff: + extends: .base-clang-tidy + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + when: never + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + when: never + - changes: + paths: + - .clang-tidy + compare_to: master + when: never + - when: on_success + script: + - git diff -U0 $(git merge-base --fork-point origin/$CI_DEFAULT_BRANCH) | + clang-tidy-diff-14.py -path cmake-cache/ -p1 -quiet + 1> $CLANG_TIDY_OUTPUT + 2> /dev/null + - (! egrep -A 3 "error:|warning:|note:" $CLANG_TIDY_OUTPUT) + - echo "No clang-tidy errors found" + +# Emacs line emacs-line: stage: code-linting image: ubuntu:latest