From 3dde70de2cdd3ab66ee27957bec9f0e1b0eee6e8 Mon Sep 17 00:00:00 2001 From: Moshe Kaplan Date: Mon, 24 Aug 2020 18:47:20 +0000 Subject: [PATCH] .gitlab-ci: Generate cppcheck reports Modify the cppcheck job to also generate cppcheck's reports and provide them as artifacts to the user. --- .gitlab-ci.yml | 9 +++++++-- tools/cppcheck/cppcheck.sh | 12 +++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 931577e0fb..432c27f21d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -225,17 +225,22 @@ merge-req:ubuntu-clang-other-tests: rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' script: - - apt-get install -y cppcheck clang-tools + - apt-get install -y cppcheck clang-tools python-pygments # build-ubuntu puts us in `build`. - cd .. - python3 tools/checklicenses.py - - ./tools/cppcheck/cppcheck.sh -l 1 + - ./tools/cppcheck/cppcheck.sh -l 1 -x | tee cppcheck_report.xml + - if [[ -s "cppcheck_report.xml" ]]; then cppcheck-htmlreport --file cppcheck_report.xml --report-dir . ; fi - cd build - cmake -DENABLE_EXTRA_COMPILER_WARNINGS=on -DENABLE_CHECKHF_CONFLICT=on -DCMAKE_EXPORT_COMPILE_COMMANDS=on -DENABLE_CCACHE=ON -G Ninja .. - ninja - ./run/tshark -v - sh -c '[ ! -e ../tools/validate-clang-check.sh ] || ../tools/validate-clang-check.sh' - ninja checkAPI + artifacts: + paths: + - cppcheck_report.xml + - cppcheck_report.html # XXX This is still beta: # https://docs.gitlab.com/ee/user/gitlab_com/index.html#windows-shared-runners-beta diff --git a/tools/cppcheck/cppcheck.sh b/tools/cppcheck/cppcheck.sh index 41b402a611..e7e4518e71 100755 --- a/tools/cppcheck/cppcheck.sh +++ b/tools/cppcheck/cppcheck.sh @@ -97,7 +97,7 @@ fi if [ "$LAST_COMMITS" -gt 0 ] ; then TARGET=$( git diff --name-only HEAD~"$LAST_COMMITS".. | grep -E '\.(c|cpp)$' ) if [ -z "${TARGET//[[:space:]]/}" ] ; then - echo "No C or C++ files found in the last $LAST_COMMITS commit(s)." + >&2 echo "No C or C++ files found in the last $LAST_COMMITS commit(s)." exit_cleanup 0 fi fi @@ -106,7 +106,7 @@ if [ "$OPEN_FILES" = "yes" ] ; then TARGET=$(git diff --name-only | grep -E '\.(c|cpp)$' ) TARGET="$TARGET $(git diff --staged --name-only | grep -E '\.(c|cpp)$' )" if [ -z "${TARGET//[[:space:]]/}" ] ; then - echo "No C or C++ files are currently opened (modified or added for next commit)." + >&2 echo "No C or C++ files are currently opened (modified or added for next commit)." exit_cleanup 0 fi fi @@ -128,9 +128,11 @@ fi # runs and we aren't left with broken HTML. trap : INT -echo "Examining:" -echo $TARGET -echo +if [ "$QUIET" = " " ]; then + echo "Examining:" + echo $TARGET + echo +fi # shellcheck disable=SC2086 $CPPCHECK --force --enable=style $QUIET \