From 23c667ce98c36d850701f14edcd395b131fd19f3 Mon Sep 17 00:00:00 2001
From: Olivier BICHLER <olivier.bichler@cea.fr>
Date: Thu, 31 Aug 2023 18:25:33 +0200
Subject: [PATCH] Adapted CI for OVH

---
 .gitlab/ci/_global.gitlab-ci.yml |  7 +++--
 .gitlab/ci/build.gitlab-ci.yml   | 44 ++++++++------------------------
 .gitlab/ci/test.gitlab-ci.yml    | 14 ++++++----
 3 files changed, 25 insertions(+), 40 deletions(-)

diff --git a/.gitlab/ci/_global.gitlab-ci.yml b/.gitlab/ci/_global.gitlab-ci.yml
index 6f34fe70..aab5d745 100644
--- a/.gitlab/ci/_global.gitlab-ci.yml
+++ b/.gitlab/ci/_global.gitlab-ci.yml
@@ -9,5 +9,8 @@ variables:
   GIT_SSL_NO_VERIFY: 1
   DEBIAN_FRONTEND: noninteractive
 
-
-image: n2d2-ci/ubuntu20.04/cpu:latest
\ No newline at end of file
+default:
+  image: nvidia/cuda:12.2.0-devel-ubuntu22.04
+  before_script:
+    - apt update
+    - apt install -y cmake cppcheck python-is-python3 pip git gcovr
diff --git a/.gitlab/ci/build.gitlab-ci.yml b/.gitlab/ci/build.gitlab-ci.yml
index 620bc325..d704e184 100644
--- a/.gitlab/ci/build.gitlab-ci.yml
+++ b/.gitlab/ci/build.gitlab-ci.yml
@@ -2,24 +2,13 @@ build:ubuntu_cpp:
   stage: build
   tags:
     - docker
-  image: n2d2-ci/ubuntu20.04/cpu:latest
-
   script:
-    - INSTALL_PATH="$CI_PROJECT_DIR/install_cpp"
-    - mkdir -p $INSTALL_PATH
-    - mkdir -p build_cpp
+    # Download dependencies
+    # aidge_core
+    - 'curl --location --output build_artifacts.zip "https://gitlab.eclipse.org/api/v4/projects/5139/jobs/artifacts/main/download?job=build:ubuntu_cpp"'
+    - unzip -o build_artifacts.zip -d .
+    - rm -rf build_cpp
 
-    # Clone and compile dependencies
-    - MODULE_NAME="aidge_core"
-    - BASE_URL=`echo $CI_REPOSITORY_URL | sed "s;\/*$CI_PROJECT_PATH.*;;"`
-    - REPO_URL="$BASE_URL/aidge/$MODULE_NAME.git"
-    - git clone $REPO_URL $MODULE_NAME
-    - mkdir -p $MODULE_NAME/build
-    - cd $MODULE_NAME/build
-    - cmake -DCMAKE_INSTALL_PREFIX:PATH=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON ..
-    - make -j4 all install
-    - cd ../..
-    
     # Build current module
     - cd build_cpp
     - cmake -DCMAKE_INSTALL_PREFIX:PATH=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON ..
@@ -34,28 +23,17 @@ build:ubuntu_python:
   stage: build
   tags:
     - docker
-  image: n2d2-ci/ubuntu20.04/cpu:latest
-
   script:
-    - export AIDGE_INSTALL=`pwd`/install
+    # Download dependencies
+    # aidge_core
+    - 'curl --location --output build_artifacts.zip "https://gitlab.eclipse.org/api/v4/projects/5139/jobs/artifacts/main/download?job=build:ubuntu_python"'
+    - unzip -o build_artifacts.zip -d .
 
-    # Create virtaul env
     - python3 -m pip install virtualenv
     - virtualenv venv
     - source venv/bin/activate
-
-    # Clone dependencies
-    - MODULE_NAME="aidge_core"
-    - BASE_URL=`echo $CI_REPOSITORY_URL | sed "s;\/*$CI_PROJECT_PATH.*;;"`
-    - REPO_URL="$BASE_URL/aidge/$MODULE_NAME.git"
-    - git clone $REPO_URL $MODULE_NAME
-
-    # Pip install dependancy
-    - cd $MODULE_NAME
-    - python3 -m pip install . -v
-
-    - cd ..
-    - python3 -m pip install . -v
+    - export AIDGE_INSTALL=`pwd`/install
+    - python3 -m pip install .
   artifacts:
     paths:
       - venv/
\ No newline at end of file
diff --git a/.gitlab/ci/test.gitlab-ci.yml b/.gitlab/ci/test.gitlab-ci.yml
index 2ad635df..f4949552 100644
--- a/.gitlab/ci/test.gitlab-ci.yml
+++ b/.gitlab/ci/test.gitlab-ci.yml
@@ -3,22 +3,26 @@ test:ubuntu_cpp:
   needs: ["build:ubuntu_cpp"]
   tags:
     - docker
-  image: n2d2-ci/ubuntu20.04/cpu:latest
   script:
     - cd build_cpp
-    - ctest --output-on-failure
+    - ctest --output-junit ctest-results.xml --output-on-failure
+  artifacts:
+    reports:
+      junit: build_cpp/ctest-results.xml
 
 test:ubuntu_python:
   stage: test
   needs: ["build:ubuntu_python"]
   tags:
     - docker
-  image: n2d2-ci/ubuntu20.04/cpu:latest
   script:
     - source venv/bin/activate
     - cd aidge_backend_cpu
-    - python3 -m pip install numpy
+    - python3 -m pip install numpy unittest-xml-reporting
     - python3 -m pip list
     # Run on discovery all tests located in core/unit_tests/python and discard the stdout 
     # only to show the errors/warnings and the results of the tests
-    - python3 -m unittest discover -s unit_tests/ -v -b 1> /dev/null
+    - python3 -m xmlrunner discover -s unit_tests/ -v -b --output-file xmlrunner-results.xml
+  artifacts:
+    reports:
+      junit: aidge_core/xmlrunner-results.xml
-- 
GitLab