From 7e2fb305abefe5d2cbdb2ef4b00478c3d63e7046 Mon Sep 17 00:00:00 2001
From: kongr45gpen <electrovesta@gmail.com>
Date: Sat, 16 Mar 2019 04:35:52 +0200
Subject: [PATCH] Improvements on CI

- Used a docker image with a more recent version of Debian
- Enabled colours for gcc and clang
- Updated clang-tidy from 4.0 to 7.0
- Enabled some diagnostic checks for clang-tidy, and disabled others that gave false positives
- Made clang-tidy read system header files, while ignoring their errors
---
 .gitlab-ci.yml   | 23 +++++++++++++++--------
 ci/.clang-tidy   | 10 ++++++----
 ci/clang-tidy.sh |  5 +++--
 3 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 43a618b0..a2edb7b8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,4 +1,4 @@
-image: rikorose/gcc-cmake
+image: lycantropos/cmake
 
 stages:
   - build
@@ -6,16 +6,19 @@ stages:
 
 before_script:
   - g++ --version
+  - cat /etc/*-release
 
 build:
   stage: build
   variables:
       GIT_SUBMODULE_STRATEGY: normal
+      GCC_COLORS: "error=31;1:warning=35;1:note=36;1:range1=32:range2=34:locus=39;1:quote=39;1:fixit-insert=32:fixit-delete=31:diff-filename=39;1:diff-hunk=32:diff-delete=31:diff-insert=32:type-diff=32;1"
+      CLICOLOR_FORCE: 1
   script:
-    - cmake . -DCMAKE_CXX_FLAGS="-Werror"
+    - cmake . -DCMAKE_CXX_FLAGS="-Werror -fdiagnostics-color=always"
     - make -j4
     - make clean
-    - cmake . -DCMAKE_CXX_FLAGS="-Wall -Wextra" # Build again, but with more warnings
+    - cmake . -DCMAKE_CXX_FLAGS="-Wall -Wextra -fdiagnostics-color=always" # Build again, but with more warnings
     - make -j4
 
 tests:
@@ -38,7 +41,7 @@ cppcheck:
     - apt-get update -qq && apt-get install -y -qq cppcheck
     - cppcheck --version
   script:
-    - bash -x ci/cppcheck.sh
+    - ci/cppcheck.sh
 
 vera:
   stage: build
@@ -47,12 +50,16 @@ vera:
     - vera++ --version
     - cp ci/vera.profile /usr/lib/vera++/profiles/custom
   script:
-    - bash -x ci/vera.sh
+    - ci/vera.sh
 
 clang-tidy:
   stage: build
+  variables:
+    GIT_SUBMODULE_STRATEGY: normal
+    TERM: xterm-color
   before_script:
-    - apt-get update -qq && apt-get install -y -qq clang-tidy-4.0
-    - clang-tidy-4.0 --version
+    - echo deb http://deb.debian.org/debian sid main > /etc/apt/sources.list
+    - apt-get update -qq && apt-get -t sid install -y -qq clang-tidy-7
+    - clang-tidy-7 --version
   script:
-    - bash -x ci/clang-tidy.sh
+    - script -c "bash -x ci/clang-tidy.sh"
diff --git a/ci/.clang-tidy b/ci/.clang-tidy
index 61142186..79406a31 100644
--- a/ci/.clang-tidy
+++ b/ci/.clang-tidy
@@ -1,9 +1,10 @@
 ---
 Checks:          >
-  clang-diagnostic-*,
+  -clang-diagnostic-error,
   clang-analyzer-*,
   bugprone-*,
-  cppcoreguidelines-*,-cppcoreguidelines-no-malloc,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-bounds-constant-array-index,
+  cert-*,
+  cppcoreguidelines-*,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-bounds-constant-array-index,
   misc-*,-misc-non-private-member-variables-in-classes,
   fuchsia-multiple-inheritance,
   google-*,-google-readability-todo,
@@ -17,8 +18,9 @@ Checks:          >
   -misc-non-private-member-variables-in-classes,
   performance-*,
   readability-*,
-WarningsAsErrors: '*,-misc-unused-parameters,-llvm-header-guard,-cppcoreguidelines-pro-type-member-init,-google-runtime-references,-clang-diagnostic-tautological-constant-out-of-range-compare,-readability-redundant-declaration'
-HeaderFilterRegex: '.*'
+  zircon-*
+WarningsAsErrors: '*,-misc-unused-parameters,-llvm-header-guard,-cppcoreguidelines-pro-type-member-init,-google-runtime-references,-clang-diagnostic-tautological-constant-out-of-range-compare,-readability-redundant-declaration,-modernize-use-equals-default,-fuchsia-statically-constructed-objects,-hicpp-signed-bitwise,-cert-err58-cpp'
+HeaderFilterRegex: 'ecss-services\/((?!lib\/).)*$'
 AnalyzeTemporaryDtors: false
 ...
 
diff --git a/ci/clang-tidy.sh b/ci/clang-tidy.sh
index 1e676ce2..bdff8166 100755
--- a/ci/clang-tidy.sh
+++ b/ci/clang-tidy.sh
@@ -10,5 +10,6 @@
 echo -e "\033[0;34mRunning clang-tidy...\033[0m"
 
 cd "$(dirname "$0")"
-clang-tidy-4.0 `find ../src/ -type f -regextype posix-egrep -regex '.*\.(cpp|hpp|c|h)'` \
-    -extra-arg=-fcolor-diagnostics -- -std=c++14 -I../inc
+clang-tidy-7 `find ../src/ -type f -regextype posix-egrep -regex '.*\.(cpp|hpp|c|h)'` \
+    -extra-arg=-fcolor-diagnostics  -- -std=c++17 -I../inc \
+    -I/usr/include/c++/7/ -I/usr/include/x86_64-linux-gnu/c++/7 -I../lib/etl/include
-- 
GitLab