From 0bbe30a072a38d72be4b8f0846d5a212a9349a23 Mon Sep 17 00:00:00 2001
From: Florent Pruvost <florent.pruvost@inria.fr>
Date: Wed, 13 Sep 2017 16:06:28 +0200
Subject: [PATCH] add sonar-scanner analysis

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

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d3e047251..7bae29090 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -34,10 +34,52 @@ quark:
     - ctest -V -R test_shm_s
 
 doc:
+  artifacts:
+    name: chameleon_doc
+    expire_in: 1 week
+    paths:
+      - build/doc/doxygen
+      - build/doc/orgmode
   script:
     - source .gitlab-ci-env.sh
     - git submodule update --init --recursive
     - mkdir -p build
     - cd build
-    - cmake .. -DCHAMELEON_ENABLE_DOC=ON -DCHAMELEON_ENABLE_EXAMPLES=OFF -DCHAMELEON_ENABLE_TESTING=OFF -DCHAMELEON_ENABLE_TIMING=OFF
-    - make
+    - cmake .. -DCHAMELEON_ENABLE_DOC=ON -DCHAMELEON_ENABLE_EXAMPLE=OFF -DCHAMELEON_ENABLE_TESTING=OFF -DCHAMELEON_ENABLE_TIMING=OFF
+    - make doc
+
+analysis:
+  artifacts:
+    name: chameleon_analysis
+    expire_in: 1 week
+    paths:
+      - chameleon-build.log
+      - coverage/
+      - chameleon-coverage.xml
+      - chameleon-cppcheck.xml
+      - chameleon-rats.xml
+      - sonar.log
+  script:
+    - source .gitlab-ci-env.sh
+    - git submodule update --init --recursive
+    - mkdir -p build
+    - cd build
+    - export CFLAGS="-O0 -g -fPIC -fdiagnostics-show-option --coverage -fno-inline -Wall"
+    - export LDFLAGS="--coverage"
+    - cmake .. -DCHAMELEON_USE_MPI=ON -DCMAKE_INSTALL_PREFIX=$PWD/install -DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS" -DCMAKE_VERBOSE_MAKEFILE=ON
+    - make -j5 | tee ../chameleon-build.log
+    - STARPU_SILENT=1 ctest --no-compress-output || /usr/bin/true
+    - lcov --directory . --capture --output-file ../chameleon.lcov
+    - cd ..
+    - genhtml -o coverage chameleon.lcov
+    - lcov_cobertura.py chameleon.lcov --output chameleon-coverage.xml
+    - rm coreblas/include/cblas.h coreblas/include/lapacke.h coreblas/include/lapacke_config.h coreblas/include/lapacke_mangling.h
+    - export SOURCES_TO_ANALYZE=`bash -c 'find ./build/coreblas ./build/example ./build/include ./build/runtime ./build/compute ./build/control ./build/hqr ./build/testing ./build/timing -regex ".*\.c\|.*\.h" |xargs && \
+                                 find . -path ./build -prune -o -regex "^[^z]*\.c" -print && \
+                                 find . -path ./build -prune -o -regex "^[^z]*\.h" -print'`
+    - export UNDEFINITIONS="-UCHAMELEON_USE_CUBLAS_V2 -UCHAMELEON_USE_OPENCL"
+    - cppcheck -v -f --language=c --platform=unix64 --enable=all --xml --xml-version=2 --suppress=missingIncludeSystem ${UNDEFINITIONS} ${SOURCES_TO_ANALYZE} ${SOURCES_TO_EXCLUDE} 2> chameleon-cppcheck.xml
+    - rats -w 3 --xml ${SOURCES_TO_ANALYZE} > chameleon-rats.xml
+    - sonar-scanner -X -Dsonar.login=077ef775a8b4fe9ba722497ef0511ca6dcfb3fcd > sonar.log
+  only:
+    - master
\ No newline at end of file
-- 
GitLab