From ba761254c3d6a18f74a8f3ef1fc9eedcc8e047d7 Mon Sep 17 00:00:00 2001
From: Raphael Defosseux <raphael.defosseux@openairinterface.org>
Date: Tue, 30 Jan 2024 15:38:33 +0100
Subject: [PATCH] chore(ci): adding Robot-Framework pipeline

Signed-off-by: Raphael Defosseux <raphael.defosseux@openairinterface.org>
---
 ci-scripts/Jenkinsfile-GitLab-Docker | 30 ++++++++++++++++++++++++++++
 ci-scripts/generateHtmlReport.py     | 12 +++++++++--
 2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/ci-scripts/Jenkinsfile-GitLab-Docker b/ci-scripts/Jenkinsfile-GitLab-Docker
index f2416de..0afea0b 100644
--- a/ci-scripts/Jenkinsfile-GitLab-Docker
+++ b/ci-scripts/Jenkinsfile-GitLab-Docker
@@ -345,6 +345,36 @@ pipeline {
             }
           }
         }
+        // Home-made RAN emulator
+        stage ('Robot-Test') {
+          steps {
+            script {
+              gitlabCommitStatus(name: "Robot-Test") {
+                localStatus = build job: 'OAI-CN5G-RobotTest',
+                  parameters: [
+                    string(name: 'PCF_TAG', value: String.valueOf(pcf_tag)),
+                    string(name: 'PCF_BRANCH', value: String.valueOf(pcf_branch))
+                  ], propagate: false
+                localResult = localStatus.getResult()
+
+                if (localStatus.resultIsBetterOrEqualTo('SUCCESS')) {
+                  echo "Robot-Test is OK"
+                } else {
+                  error "Robot-Test is is KO"
+                }
+              }
+            }
+          }
+          post {
+            always {
+              script {
+                copyArtifacts(projectName: 'OAI-CN5G-RobotTest',
+                              filter: '*.html',
+                              selector: lastCompleted())
+              }
+            }
+          }
+        }
       }
     }
     // We are only publishing the Ubuntu image to Docker-Hub
diff --git a/ci-scripts/generateHtmlReport.py b/ci-scripts/generateHtmlReport.py
index 1bfde95..e679f13 100755
--- a/ci-scripts/generateHtmlReport.py
+++ b/ci-scripts/generateHtmlReport.py
@@ -67,15 +67,23 @@ class HtmlReport():
         gitInfo = generate_git_info(args)
         cwd = os.getcwd()
         for reportFile in os.listdir(cwd):
-            if reportFile.endswith('.html') and re.search('results_oai_cn5g_', reportFile) is not None:
+            if reportFile.endswith('.html') and (re.search('results_oai_cn5g_', reportFile) is not None or re.search('test_results_robot_', reportFile) is not None):
                 newFile = ''
+                robotBuildUrl = ''
                 gitInfoAppended = False
                 with open(os.path.join(cwd, reportFile), 'r') as rfile:
                     for line in rfile:
                         if re.search('<h2>', line) is not None and not gitInfoAppended:
                             gitInfoAppended = True
                             newFile += gitInfo
-                        newFile += line
+                        if re.search('OAI-CN5G-RobotTest -- Build-ID', line) is not None:
+                            result = re.search('href="(?P<build_url>[a-zA-Z0-9\-\:\/\.]+)"', line)
+                            if result is not None:
+                                robotBuildUrl = result.group('build_url')
+                        if re.search('archives/log.html', line) is not None:
+                            newFile += re.sub('archives', f'{robotBuildUrl}/artifact/archives', line)
+                        else:
+                            newFile += line
                 with open(os.path.join(cwd, reportFile), 'w') as wfile:
                     wfile.write(newFile)
 
-- 
GitLab