From 407bc4115327b5dc4edde8ecd3323cc951f38669 Mon Sep 17 00:00:00 2001
From: Tomas Pecka <peckato1@fit.cvut.cz>
Date: Sun, 21 Apr 2019 19:09:33 +0200
Subject: [PATCH] CI: Static analysis (clang-tidy, cppcheck)

---
 .gitlab-ci.yml | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 25c0260218..5c5b1557b5 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -20,7 +20,7 @@ stages:
     - CMake/generate.py -wm
     - mkdir release
     - cd release
-    - cmake -DCMAKE_BUILD_TYPE=Release ..
+    - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
     - make -j $(grep -c processor /proc/cpuinfo)
   artifacts:
     paths:
@@ -124,9 +124,35 @@ build:doc:
       - doc/
     expire_in: 1 day
 
-
 #==========  Stage test  ==========
 
+.static: &static
+  stage: test
+  image: amd64/debian:testing-slim
+  before_script:
+    - apt-get update
+  dependencies:
+    - build:debian:testing:clang
+  except:
+    variables:
+      - $SCHEDULED_NIGHTLY
+  allow_failure: true
+
+static:cppcheck:
+  <<: *static
+  script:
+    - apt-get install -y cppcheck
+    - cppcheck -q --enable=all --project=release/compile_commands.json --suppress="*:*/contrib/*" -j$(grep -c processor /proc/cpuinfo) --error-exitcode=1
+
+static:clang-tidy:
+  <<: *static
+  script:
+    - apt-get install -y clang-tidy
+    - apt-get install -y libxml2-dev libtclap-dev libreadline-dev qtbase5-dev graphviz-dev libjsoncpp-dev
+    - find . -wholename "*/src/*.cpp" -print0 | xargs -n1 -P$(grep -c processor /proc/cpuinfo) -0 clang-tidy -warnings-as-errors='*' -p release/
+
+# ---
+
 .test: &test
   stage: test
   script:
-- 
GitLab