From c716a6541f291249a92503b6ddb737efbca4670e Mon Sep 17 00:00:00 2001
From: Florent Pruvost <florent.pruvost@inria.fr>
Date: Thu, 28 Nov 2024 15:00:01 +0100
Subject: [PATCH] Add a script for coverity job

---
 .gitlab/coverity.yml | 14 +-------------
 tools/coverity.sh    | 30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 13 deletions(-)
 create mode 100755 tools/coverity.sh

diff --git a/.gitlab/coverity.yml b/.gitlab/coverity.yml
index ddb922212..8a2fdd0b3 100644
--- a/.gitlab/coverity.yml
+++ b/.gitlab/coverity.yml
@@ -1,8 +1,6 @@
 ---
 coverity:
   stage: analyze
-  tags: ["docker", "large"]
-  interruptible: true
   rules:
     - if: ($CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /^ci-.*$/) && $CI_PIPELINE_SOURCE != "schedule"
     - if: ($CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME !~ /^notest-.*$/)
@@ -12,17 +10,7 @@ coverity:
   variables:
     VERSION: coverity
   script:
-    - (mkdir -p build-$VERSION && cd build-$VERSION &&
-       cmake .. -C ../cmake_modules/gitlab-ci-initial-cache.cmake
-                -DCHAMELEON_USE_CUDA=ON -DCHAMELEON_USE_MPI=ON &&
-       cov-build --dir ../cov-int make -j 4)
-    - tar czvf chameleon.tgz cov-int
-    - curl --form token=$COVERITY_TOKEN
-           --form email=florent.pruvost@inria.fr
-           --form file=@chameleon.tgz
-           --form version="`git rev-parse --short HEAD`"
-           --form description=""
-           https://scan.coverity.com/builds?project=Chameleon
+    - ./tools/coverity.sh
   artifacts:
     name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
     expire_in: 1 week
diff --git a/tools/coverity.sh b/tools/coverity.sh
new file mode 100755
index 000000000..bd2323509
--- /dev/null
+++ b/tools/coverity.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+#
+# @file coverity.sh
+#
+# @copyright 2024-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+#                      Univ. Bordeaux. All rights reserved.
+#
+# @version 1.3.0
+# @author Florent Pruvost
+# @date 2024-11-27
+#
+set -e
+set -x
+CHAMELEON_SRC_DIR=${CHAMELEON_SRC_DIR:-$PWD}
+
+# install plotting dependencies in the testing docker image
+CURRENTUSER=`whoami`
+if [[ -f /.dockerenv && $CURRENTUSER == "gitlab" ]]; then
+  export PKG_CONFIG_PATH=/home/gitlab/install/starpu/lib/pkgconfig:$PKG_CONFIG_PATH
+fi
+
+cmake -B build-$VERSION -C cmake_modules/gitlab-ci-initial-cache.cmake -DCHAMELEON_USE_CUDA=OFF -DCHAMELEON_USE_MPI=ON
+cov-build --dir cov-int/ cmake --build build-$VERSION -j4
+tar czvf chameleon.tgz cov-int/
+curl --form token=$COVERITY_TOKEN \
+     --form email=florent.pruvost@inria.fr \
+     --form file=@chameleon.tgz \
+     --form version="`git rev-parse --short HEAD`" \
+     --form description="" \
+     https://scan.coverity.com/builds?project=Chameleon
-- 
GitLab