From 9e087d8559062f69099360b152137875e37b006c Mon Sep 17 00:00:00 2001
From: Federico Felici <federico.felici@epfl.ch>
Date: Thu, 19 Sep 2019 12:13:44 +0000
Subject: [PATCH] Compatibility with pre-deployment staging

* Added version check to basic tests_matlab.m
* Staging triggered through environment variable now
---
 .gitlab-ci.yml        | 56 +++++++++++++++++++++++++++++++------------
 matlab/tests_matlab.m | 12 ++++++----
 2 files changed, 49 insertions(+), 19 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 2bd0d65c..adcbb2ee 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,31 +3,24 @@ include:
  - project: 'spc/tcv/tbx/git-tools-spc'
    file: 'gitlab-ci-tbx-template.yml'
 
-# no build for gdat, so don't define jobs for this phase
+variables:
+  TBXFOLDER: matlab
+  MATVER: last
 
+# no build for gdat, so don't define jobs for this phase
 test-matlab850:
   extends: .test-template
-  before_script:
-  - cd matlab
   variables:
     MATLABCMD: matlab850
     TESTCASE: basic-tcv
 
 test-matlab:
   extends: .test-template
-  before_script:
-  - cd matlab
   variables:
     MATLABCMD: matlab
     TESTCASE: basic-tcv
-    
-# deactivate others for now pending full deployment scripts
-
-.test-deployed-matlab850:
-  extends: .test-deployed-template
-  variables:
-    MATLABCMD: matlab850
 
+# Tests with 'all' option deactivated for now since not workin
 .test-matlab850-all:
   extends: test-matlab850
   variables:
@@ -36,12 +29,45 @@ test-matlab:
   - schedules
   - web
 
+# Staging, testing and deployment for releases
+pre-deployment-staging:
+ extends: .staging-template
+
+# Staging tests
+test-staging-920:
+ extends: .test-staging-template
+ variables:
+  MATLABCMD: matlab920
+ 
+test-staging-900:
+ extends: .test-staging-template
+ variables:
+  MATLABCMD: matlab900
+
+test-staging-850:
+ extends: .test-staging-template
+ variables:
+  MATLABCMD: matlab850
+  
+test-staging-830:
+ extends: .test-staging-template
+ variables:
+  MATLABCMD: matlab830
+  
+test-staging-800:
+ extends: .test-staging-template
+ variables:
+  MATLABCMD: matlab800
+
+# pre-deployment
+pre-deployment-checks:
+ extends: .pre-deployment-checks-template
+
+# deploy  
 deploy: 
   extends: .deploy-to-lac-template
-  variables:
-    MATVER: last
-    TBXFOLDER: matlab
 
+# test post-deploy
 test-post-deploy-matlab:
   extends: .test-post-deploy-template
   variables:
diff --git a/matlab/tests_matlab.m b/matlab/tests_matlab.m
index 993f7267..fc515894 100644
--- a/matlab/tests_matlab.m
+++ b/matlab/tests_matlab.m
@@ -1,10 +1,14 @@
 function tests_matlab(test_case)
 % function to call tests from test_script.sh
 try
-   fprintf('\n Running test file: %s\n',mfilename('fullpath'));
-   fprintf('     Time: %s\n',datestr(now));
-   
-   passed = run_gdat_tests(test_case); % add a call to your test script here, with optional test_case input
+   if verLessThan('matlab','8.5.0') 
+    disp('gdat tests do not work for matlab version <8.5.0, skipping tests');
+    passed = true;
+   else
+    fprintf('\n Running test file: %s\n',mfilename('fullpath'));
+    fprintf('     Time: %s\n',datestr(now));
+    passed = run_gdat_tests(test_case); % add a call to your test script here, with optional test_case input
+   end 
    exit_code = int32(~passed); % convert to bash shell convention
 catch ME
    disp(getReport(ME))
-- 
GitLab