From 05aae414893276d8d3d321d8b645d391b64bf4f4 Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Wed, 7 Feb 2018 17:12:31 +0100
Subject: [PATCH] More factorization

---
 .gitlab-ci.yml | 49 +++++++++++++++++++++++++++++--------------------
 1 file changed, 29 insertions(+), 20 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 770cf7a3b..aba3e341a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,16 +1,35 @@
 image: hpclib/hiepacs
 
-.test_starpu_cuda_mpi_template: &test_starpu_cuda_mpi_script
+.build_script_template: &build_script
+  stage: build
   script:
-    - echo $TESTS_RESTRICTION
+    - echo BUILD_OPTIONS $BUILD_OPTIONS
+    - echo BUILD_LOG $BUILD_LOG
+    - (cd build &&
+       cmake -C ../cmake_modules/gitlab-ci-initial-cache.cmake ..
+             $BUILD_OPTIONS &&
+        ctest --no-compress-output -V -j 5
+             -D ExperimentalBuild
+             -D ExperimentalSubmit
+             | tee $BUILD_LOG)
+    - (cd build &&
+       make install | tee -a $BUILD_LOG &&
+       rm install/ -r)
+
+.test_script_template: &test_script
+  stage: test
+  script:
+    - echo TESTS_RESTRICTION $TESTS_RESTRICTION
+    - echo BUILD_LOG $BUILD_LOG
+    - echo BUILD_COVERAGE $BUILD_COVERAGE
     - (cd build &&
        ctest --no-compress-output -V
              $TESTS_RESTRICTION
              -D ExperimentalTest
              -D ExperimentalCoverage
              -D ExperimentalSubmit
-             | tee -a ../chameleon-build-starpu.log)
-    - lcov --directory build --capture --output-file chameleon_starpu_mpi.lcov
+             | tee -a $BUILD_LOG)
+    - lcov --directory build --capture --output-file $BUILD_COVERAGE
 
 stages:
   - build
@@ -24,29 +43,21 @@ before_script:
   - mkdir -p build
 
 build_starpu_cuda_mpi:
-  stage: build
+  <<: *build_script
   artifacts:
     name: build_starpu_cuda_mpi
     expire_in: 48 hours
     paths:
       - build
       - chameleon-build-starpu.log
-  script:
-    - (cd build &&
-       cmake -C ../cmake_modules/gitlab-ci-initial-cache.cmake ..
-             -DCHAMELEON_USE_CUDA=ON
-             -DCHAMELEON_USE_MPI=ON &&
-        ctest --no-compress-output -V -j 5
-             -D ExperimentalBuild
-             -D ExperimentalSubmit
-             | tee ../chameleon-build-starpu.log)
-    - (cd build &&
-       make install | tee -a ../chameleon-build-starpu.log &&
-       rm install/ -r)
+  variables:
+    BUILD_OPTIONS: "-DCHAMELEON_USE_CUDA=ON -DCHAMELEON_USE_MPI=ON"
+    BUILD_LOG: ../chameleon-build-starpu.log
 
 test_starpu_cuda_mpi:
   <<: *test_starpu_cuda_mpi_script
-  stage: test
+  variables:
+    TESTS_RESTRICTION: "-R \"test_shm_s|mpi_s\""
   dependencies:
     - build_starpu_cuda_mpi
   artifacts:
@@ -56,8 +67,6 @@ test_starpu_cuda_mpi:
       - build
       - chameleon-build-starpu.log
       - chameleon_starpu_mpi.lcov
-  variables:
-    TESTS_RESTRICTION: "-R \"test_shm_s|mpi_s\""
 
 sonar:
   stage: analysis
-- 
GitLab