From 62a18b701b5368e99a969ecdccd029a241177305 Mon Sep 17 00:00:00 2001
From: joanvallve <jvallve@iri.upc.edu>
Date: Fri, 26 Jul 2024 11:42:17 +0200
Subject: [PATCH] added ci_tampleates

---
 .ci_templates/.install_bodydynamics.yml | 25 ++++++++++++++++
 .gitlab-ci.yml                          | 40 ++++++++-----------------
 2 files changed, 38 insertions(+), 27 deletions(-)
 create mode 100644 .ci_templates/.install_bodydynamics.yml

diff --git a/.ci_templates/.install_bodydynamics.yml b/.ci_templates/.install_bodydynamics.yml
new file mode 100644
index 0000000..bfb4b1d
--- /dev/null
+++ b/.ci_templates/.install_bodydynamics.yml
@@ -0,0 +1,25 @@
+.install_bodydynamics_script:
+  - cd ${CI_PROJECT_DIR}
+
+  # create 'ci_deps' folder (if not exists)
+  - mkdir -pv ci_deps
+
+  # clone or pull
+  - cd ${CI_PROJECT_DIR}/ci_deps
+  - if [ -d bodydynamics ]; then
+  -   echo "directory bodydynamics exists"
+  -   cd bodydynamics
+  -   git fetch --all
+  -   git checkout $WOLF_BODYDYNAMICS_BRANCH
+  -   git pull
+  - else
+  -   git clone -b $WOLF_BODYDYNAMICS_BRANCH ssh://git@gitlab.iri.upc.edu:2202/mobile_robotics/wolf_projects/wolf_lib/plugins/bodydynamics.git
+  -   cd bodydynamics
+  - fi
+
+  # build and install
+  - mkdir -pv build
+  - cd build
+  - cmake -DCMAKE_BUILD_TYPE=release -DBUILD_DEMOS=OFF -DBUILD_TESTS=OFF ..
+  - make -j$(nproc)
+  - make install
\ No newline at end of file
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6001e45..6d108b2 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,4 +1,5 @@
 include:
+  # core ci_templates
   - project: 'mobile_robotics/wolf_projects/wolf_lib/wolf'
     ref: 454-implementation-of-new-nodes-creation #$WOLF_CORE_BRANCH
     file:
@@ -7,6 +8,11 @@ include:
       - '.ci_templates/.clang_format.yml'
       - '.ci_templates/.install_core.yml'
       - '.ci_templates/.preliminaries.yml'
+  # imu ci_templates
+  - project: 'mobile_robotics/wolf_projects/wolf_lib/plugins/imu'
+    ref: 28-adapt-to-new-sensor-constructors-in-core #$WOLF_IMU_BRANCH
+    file:
+      - '.ci_templates/.install_imu.yml'
 
 # RUN the pipeline if it is triggered:
 # - manually from web
@@ -33,14 +39,15 @@ stages:
 ############ YAML ANCHORS ############
 .print_variables_template: &print_variables_definition
   # Print variables
-  - echo $WOLF_CORE_BRANCH
   - echo $CI_COMMIT_BRANCH
-  - echo $WOLF_BODYDYNAMICS_BRANCH
+  - echo $WOLF_CORE_BRANCH
   - echo $WOLF_IMU_BRANCH
+  - echo $WOLF_BODYDYNAMICS_BRANCH
 
 .preliminaries_template: &preliminaries_definition
   ## OVERRIDE VARIABLES
   - export WOLF_CORE_BRANCH="454-implementation-of-new-nodes-creation"
+  - export WOLF_IMU_BRANCH="28-adapt-to-new-sensor-constructors-in-core"
 
   ## PRINT VARIABLES
   - *print_variables_definition
@@ -51,24 +58,6 @@ stages:
   ## initialize build type as DEBUG
   - export BUILD_TYPE=debug
 
-.install_wolfimu_template: &install_wolfimu_definition
-  - cd ${CI_PROJECT_DIR}/ci_deps
-  - if [ -d imu ]; then
-  -   echo "directory imu exists"
-  -   cd imu
-  -   git fetch --all
-  -   git checkout $WOLF_IMU_BRANCH
-  -   git pull
-  - else
-  -   git clone -b $WOLF_IMU_BRANCH ssh://git@gitlab.iri.upc.edu:2202/mobile_robotics/wolf_projects/wolf_lib/plugins/imu.git
-  -   cd imu
-  - fi
-  - mkdir -pv build
-  - cd build
-  - cmake -DCMAKE_BUILD_TYPE=release -DBUILD_TESTS=OFF ..
-  - make -j$(nproc)
-  - make install
-
 .build_and_test_template: &build_and_test_definition
   - cd $CI_PROJECT_DIR
   - mkdir -pv build
@@ -109,7 +98,7 @@ yaml_templates_generation:
     - *preliminaries_definition
     - !reference [.install_yamlschemacpp_script]
     - !reference [.install_wolf_script]
-    - *install_wolfimu_definition
+    - !reference [.install_imu_script]
   script:
     - !reference [.generate_yaml_templates_script]
 
@@ -131,8 +120,7 @@ build_and_test:bionic:
     - *preliminaries_definition
     - !reference [.install_yamlschemacpp_script]
     - !reference [.install_wolf_script]
-    - *install_wolfimu_definition
-    - ldconfig # update links (shared libraries)
+    - !reference [.install_imu_script]
   script:
     - *build_and_test_definition
     - export BUILD_TYPE=release
@@ -156,8 +144,7 @@ build_and_test:focal:
     - *preliminaries_definition
     - !reference [.install_yamlschemacpp_script]
     - !reference [.install_wolf_script]
-    - *install_wolfimu_definition
-    - ldconfig # update links (shared libraries)
+    - !reference [.install_imu_script]
   script:
     - *build_and_test_definition
     - export BUILD_TYPE=release
@@ -181,8 +168,7 @@ build_and_test:jammy:
     - *preliminaries_definition
     - !reference [.install_yamlschemacpp_script]
     - !reference [.install_wolf_script]
-    - *install_wolfimu_definition
-    - ldconfig # update links (shared libraries)
+    - !reference [.install_imu_script]
   script:
     - *build_and_test_definition
     - export BUILD_TYPE=release
-- 
GitLab