From f51f151be277cc80c9b6c8c501c7cd45afe2fd23 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Tue, 3 Nov 2020 11:11:11 +0100
Subject: [PATCH] =?UTF-8?q?CI:=20take=20advantage=20of=20the=20new=20?=
 =?UTF-8?q?=E2=80=9Cneeds=E2=80=9D=20keyword?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

In particular, this allows us to split the “test” and “pkg” stages, without
increasing the execution time.

(manually cherry picked from commit ac59b220150011745407d50209da0585d9dc28a7)
---
 .gitlab-ci.yml | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5e2fec1210..60b293871c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -20,7 +20,8 @@ before_script:
 
 stages:
   - build
-  - test_and_pkg
+  - test
+  - pkg
   - deploy
 
 build_binaries:
@@ -64,7 +65,7 @@ build_doc:
     expire_in: 1 week
 
 pkg_source:
-  stage: test_and_pkg
+  stage: pkg
   script:
     - rm doc/manual/source/_static/mathjax && sed -i "/^mathjax_path *=/d" doc/manual/source/conf.py
     - 'for f in configure.ac preprocessor/configure.ac mex/build/matlab/configure.ac mex/build/octave/configure.ac; do sed -i "s/^AC_INIT(\[\(.*\)\],\s*\[\(.*\)\])/AC_INIT([\1], [$VERSION])/" $f; done'
@@ -75,10 +76,10 @@ pkg_source:
     paths:
       - dynare-*.tar.xz
     expire_in: 1 week
-  dependencies: []
+  needs: []
 
 pkg_windows:
-  stage: test_and_pkg
+  stage: pkg
   script:
     - ln -s ~/tarballs windows/deps/
     - make -C windows
@@ -96,11 +97,10 @@ pkg_windows:
       - windows/7z/*
       - windows/zip/*
     expire_in: 1 week
-  dependencies:
-    - build_doc
+  needs: [ "build_doc" ]
 
 pkg_macOS:
-  stage: test_and_pkg
+  stage: pkg
   script:
     - ln -s ~/tarballs macOS/deps/
     - make -C macOS
@@ -115,11 +115,10 @@ pkg_macOS:
     paths:
       - macOS/pkg/*
     expire_in: 1 week
-  dependencies:
-    - build_doc
+  needs: [ "build_doc" ]
 
 .test_matlab_template:
-  stage: test_and_pkg
+  stage: test
   artifacts:
     paths:
       - tests/*.m.log
@@ -132,8 +131,7 @@ pkg_macOS:
       - tests/*/*/*.jnl
       - tests/run_test_matlab_output.txt
     when: always
-  dependencies:
-    - build_binaries
+  needs: [ "build_binaries" ]
 
 test_matlab:
   extends: .test_matlab_template
@@ -153,7 +151,7 @@ test_old_matlab:
   when: manual
 
 test_octave:
-  stage: test_and_pkg
+  stage: test
   variables:
     OPENBLAS_NUM_THREADS: 1
   script:
@@ -172,12 +170,11 @@ test_octave:
       - tests/*/*/*.jnl
       - tests/run_test_octave_output.txt
     when: always
-  dependencies:
-    - build_binaries
+  needs: [ "build_binaries" ]
   when: manual
 
 test_dynare++:
-  stage: test_and_pkg
+  stage: test
   script:
     - autoreconf -si
     - ./configure --disable-matlab --disable-octave
@@ -186,8 +183,7 @@ test_dynare++:
     - touch dynare++/*/*.a dynare++/*/*/*.a
     - touch dynare++/integ/src/quadrature-points dynare++/src/dynare++
     - make -C dynare++ check
-  dependencies:
-    - build_binaries
+  needs: [ "build_binaries" ]
   artifacts:
     paths:
       - dynare++/kord/out.txt
@@ -196,6 +192,10 @@ test_dynare++:
       - dynare++/tests/*.mat
       - dynare++/tests/*.dump
 
+# For the deploy jobs, we don’t use the “needs” keyword, since we don’t want
+# those jobs to start before the “test” and “pkg” stages have succeeded. Hence
+# we stick to the “dependencies” keyword.
+
 deploy_snapshot_enterprise:
   stage: deploy
   rules:
-- 
GitLab