From 113d5a5447da97657e6ea4b139d2016781a3414a Mon Sep 17 00:00:00 2001
From: Alberto Miranda <alberto.miranda@bsc.es>
Date: Mon, 27 Feb 2023 14:12:24 +0100
Subject: [PATCH] CI: Add jobs for Clang

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

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1810aab8..abc4566d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -6,7 +6,7 @@ stages:
   - build
   - test
 
-release_build:
+gcc-release:
   stage: build
   script:
     - export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64
@@ -26,7 +26,7 @@ release_build:
       ..
     - make -j$(nproc) install
 
-debug_build:
+gcc-debug:
   stage: build
   script:
     - export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64
@@ -34,7 +34,7 @@ debug_build:
     - mkdir -p build
     - cd build
     - cmake
-      -DCMAKE_BUILD_TYPE:STRING=ASan
+      -DCMAKE_BUILD_TYPE:STRING=Debug
       -DCMAKE_PREFIX_PATH:STRING=/usr/local
       -DCMAKE_INSTALL_PREFIX:STRING=${CI_PROJECT_DIR}/compiled
       -DSCORD_BUILD_EXAMPLES:BOOL=ON
@@ -46,6 +46,7 @@ debug_build:
       ..
     - make -j$(nproc) install
   artifacts:
+    expire_in: 2 days
     paths:
       - compiled/bin/
       - compiled/etc/
@@ -54,18 +55,35 @@ debug_build:
       - build/tests/
       - build/src/scord/scord
       - build/src/scord-ctl/scord-ctl
-      # depending on your build setup it's most likely a good idea to cache outputs to reduce the build time
-  cache:
-    key: $CI_COMMIT_REF_SLUG
-    paths:
-      - build/
-      - compiled/bin
-      - compiled/etc
+
+clang:
+  stage: build
+  parallel:
+    matrix:
+      - CMAKE_BUILD_TYPE: [ Debug, Release ]
+  script:
+    - export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64
+    - export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig
+    - mkdir -p build
+    - cd build
+    - cmake
+      -DCMAKE_CXX_COMPILER=/usr/bin/clang++
+      -DCMAKE_C_COMPILER=/usr/bin/clang
+      -DCMAKE_PREFIX_PATH:STRING=/usr/local
+      -DCMAKE_INSTALL_PREFIX:STRING=${CI_PROJECT_DIR}/compiled
+      -DSCORD_BUILD_EXAMPLES:BOOL=ON
+      -DSCORD_BUILD_TESTS:BOOL=ON
+      -DSCORD_TRANSPORT_LIBRARY=libfabric
+      -DSCORD_TRANSPORT_PROTOCOL=ofi+tcp
+      -DSCORD_BIND_ADDRESS=127.0.0.1
+      -DSCORD_BIND_PORT=52000
+      ..
+    - make -j$(nproc) install
 
 # run RPC tests using the binary built before
 rpc:
   stage: test
-  needs: [debug_build]
+  needs: [ gcc-debug ]
   script:
     - export ASAN_OPTIONS=detect_odr_violation=0:detect_leaks=0
     - export LSAN_OPTIONS=verbosity=1:log_threads=1:suppressions=${CI_PROJECT_DIR}/tests/LSanSuppress.supp
@@ -82,7 +100,7 @@ rpc:
 # run unit tests
 unit:
   stage: test
-  needs: [debug_build]
+  needs: [ gcc-debug ]
   script:
     - export ASAN_OPTIONS=detect_odr_violation=0
     - export LSAN_OPTIONS=verbosity=1:log_threads=1:suppressions=${CI_PROJECT_DIR}/tests/LSanSuppress.supp
-- 
GitLab