From 3df4f29724844acfea5bf19a6618f6da4e7eb7d3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Fritze?= <rene.fritze@wwu.de>
Date: Thu, 30 Jul 2020 16:39:53 +0200
Subject: [PATCH] [ci] split into separate python+cpp stages

---
 .ci/gitlab/config.yml         | 199 ++++++++++++++++++++++++++++++----
 .ci/gitlab/config_template.py |  34 +++---
 2 files changed, 193 insertions(+), 40 deletions(-)

diff --git a/.ci/gitlab/config.yml b/.ci/gitlab/config.yml
index b957c5286..dcefa5f96 100644
--- a/.ci/gitlab/config.yml
+++ b/.ci/gitlab/config.yml
@@ -2,7 +2,8 @@
 # Edit and Re-run .ci/gitlab/config_tpl.py instead  #
 stages:
   - images
-  - test
+  - cpp
+  - python
 
 variables:
     GIT_SUBMODULE_STRATEGY: recursive
@@ -21,9 +22,10 @@ variables:
             - runner_system_failure
             - stuck_or_timeout_failure
             - api_failure
-    only: ['branches', 'tags', 'triggers', 'merge_requests']
-    except:
-        - /^staging/.*$/i
+    rules:
+        - if: '$CI_COMMIT_REF_NAME =~ /^staging.*/'
+          when: never
+        - when: on_success
     retry:
         max: 2
         when:
@@ -62,9 +64,10 @@ variables:
             - runner_system_failure
             - stuck_or_timeout_failure
             - api_failure
-    only: ['branches', 'tags', 'triggers', 'merge-requests']
-    except:
-        - /^staging/.*$/i
+    rules:
+        - if: '$CI_COMMIT_REF_NAME =~ /^staging.*/'
+          when: never
+        - when: on_success
     retry:
         max: 2
         when:
@@ -72,19 +75,15 @@ variables:
     image: $CI_REGISTRY/ag-ohlberger/dune-community/dune-xt/ci_testing_${CI_IMAGE}:${CI_COMMIT_SHORT_SHA}
 
     before_script:
-      - mkdir /home/dune-ci/testresults && chmod -R 777 /home/dune-ci/testresults
-    script:
       - |
+        mkdir /home/dune-ci/testresults && chmod -R 777 /home/dune-ci/testresults
         [[ -f ./.gitsuper ]] && echo "Please remove .gitsuper from the repo" && exit 1
-        /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_cpp.bash
-        /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_python.bash
 
     artifacts:
       reports:
         junit: '/home/dune-ci/testresults/*xml'
     environment:
         name: unsafe
-    stage: test
 
 debian-unstable_gcc_full:
     extends: .image_builder
@@ -101,83 +100,235 @@ debian_clang_full:
 
 
 
-common unstable_gcc_full:
+common unstable_gcc_full cpp:
+    extends: .subdir-test
+    variables:
+        CI_IMAGE: debian-unstable_gcc_full
+        TESTS_MODULE_SUBDIR: common
+    stage: cpp
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_cpp.bash
+
+common unstable_gcc_full python:
     extends: .subdir-test
     variables:
         CI_IMAGE: debian-unstable_gcc_full
         TESTS_MODULE_SUBDIR: common
+    stage: python
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_python.bash
+
+grid unstable_gcc_full cpp:
+    extends: .subdir-test
+    variables:
+        CI_IMAGE: debian-unstable_gcc_full
+        TESTS_MODULE_SUBDIR: grid
+    stage: cpp
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_cpp.bash
 
-grid unstable_gcc_full:
+grid unstable_gcc_full python:
     extends: .subdir-test
     variables:
         CI_IMAGE: debian-unstable_gcc_full
         TESTS_MODULE_SUBDIR: grid
+    stage: python
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_python.bash
 
-functions unstable_gcc_full:
+functions unstable_gcc_full cpp:
     extends: .subdir-test
     variables:
         CI_IMAGE: debian-unstable_gcc_full
         TESTS_MODULE_SUBDIR: functions
     tags:
         - amm-only
+    stage: cpp
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_cpp.bash
 
-la unstable_gcc_full:
+functions unstable_gcc_full python:
+    extends: .subdir-test
+    variables:
+        CI_IMAGE: debian-unstable_gcc_full
+        TESTS_MODULE_SUBDIR: functions
+    tags:
+        - amm-only
+    stage: python
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_python.bash
+
+la unstable_gcc_full cpp:
+    extends: .subdir-test
+    variables:
+        CI_IMAGE: debian-unstable_gcc_full
+        TESTS_MODULE_SUBDIR: la
+    tags:
+        - amm-only
+    stage: cpp
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_cpp.bash
+
+la unstable_gcc_full python:
     extends: .subdir-test
     variables:
         CI_IMAGE: debian-unstable_gcc_full
         TESTS_MODULE_SUBDIR: la
     tags:
         - amm-only
+    stage: python
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_python.bash
 
-common gcc_full:
+common gcc_full cpp:
     extends: .subdir-test
     variables:
         CI_IMAGE: debian_gcc_full
         TESTS_MODULE_SUBDIR: common
+    stage: cpp
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_cpp.bash
+
+common gcc_full python:
+    extends: .subdir-test
+    variables:
+        CI_IMAGE: debian_gcc_full
+        TESTS_MODULE_SUBDIR: common
+    stage: python
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_python.bash
+
+grid gcc_full cpp:
+    extends: .subdir-test
+    variables:
+        CI_IMAGE: debian_gcc_full
+        TESTS_MODULE_SUBDIR: grid
+    stage: cpp
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_cpp.bash
 
-grid gcc_full:
+grid gcc_full python:
     extends: .subdir-test
     variables:
         CI_IMAGE: debian_gcc_full
         TESTS_MODULE_SUBDIR: grid
+    stage: python
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_python.bash
+
+functions gcc_full cpp:
+    extends: .subdir-test
+    variables:
+        CI_IMAGE: debian_gcc_full
+        TESTS_MODULE_SUBDIR: functions
+    tags:
+        - amm-only
+    stage: cpp
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_cpp.bash
 
-functions gcc_full:
+functions gcc_full python:
     extends: .subdir-test
     variables:
         CI_IMAGE: debian_gcc_full
         TESTS_MODULE_SUBDIR: functions
     tags:
         - amm-only
+    stage: python
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_python.bash
+
+la gcc_full cpp:
+    extends: .subdir-test
+    variables:
+        CI_IMAGE: debian_gcc_full
+        TESTS_MODULE_SUBDIR: la
+    tags:
+        - amm-only
+    stage: cpp
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_cpp.bash
 
-la gcc_full:
+la gcc_full python:
     extends: .subdir-test
     variables:
         CI_IMAGE: debian_gcc_full
         TESTS_MODULE_SUBDIR: la
     tags:
         - amm-only
+    stage: python
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_python.bash
 
-common clang_full:
+common clang_full cpp:
     extends: .subdir-test
     variables:
         CI_IMAGE: debian_clang_full
         TESTS_MODULE_SUBDIR: common
+    stage: cpp
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_cpp.bash
 
-grid clang_full:
+common clang_full python:
+    extends: .subdir-test
+    variables:
+        CI_IMAGE: debian_clang_full
+        TESTS_MODULE_SUBDIR: common
+    stage: python
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_python.bash
+
+grid clang_full cpp:
+    extends: .subdir-test
+    variables:
+        CI_IMAGE: debian_clang_full
+        TESTS_MODULE_SUBDIR: grid
+    stage: cpp
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_cpp.bash
+
+grid clang_full python:
     extends: .subdir-test
     variables:
         CI_IMAGE: debian_clang_full
         TESTS_MODULE_SUBDIR: grid
+    stage: python
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_python.bash
 
-functions clang_full:
+functions clang_full cpp:
     extends: .subdir-test
     variables:
         CI_IMAGE: debian_clang_full
         TESTS_MODULE_SUBDIR: functions
+    stage: cpp
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_cpp.bash
 
-la clang_full:
+functions clang_full python:
+    extends: .subdir-test
+    variables:
+        CI_IMAGE: debian_clang_full
+        TESTS_MODULE_SUBDIR: functions
+    stage: python
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_python.bash
+
+la clang_full cpp:
     extends: .subdir-test
     variables:
         CI_IMAGE: debian_clang_full
         TESTS_MODULE_SUBDIR: la
+    stage: cpp
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_cpp.bash
+
+la clang_full python:
+    extends: .subdir-test
+    variables:
+        CI_IMAGE: debian_clang_full
+        TESTS_MODULE_SUBDIR: la
+    stage: python
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_python.bash
 
diff --git a/.ci/gitlab/config_template.py b/.ci/gitlab/config_template.py
index 46e8e6ff2..01f1c181d 100755
--- a/.ci/gitlab/config_template.py
+++ b/.ci/gitlab/config_template.py
@@ -5,7 +5,8 @@ tpl = '''# THIS FILE IS AUTOGENERATED -- DO NOT EDIT       #
 # Edit and Re-run .ci/gitlab/config_tpl.py instead  #
 stages:
   - images
-  - test
+  - cpp
+  - python
 
 variables:
     GIT_SUBMODULE_STRATEGY: recursive
@@ -24,9 +25,10 @@ variables:
             - runner_system_failure
             - stuck_or_timeout_failure
             - api_failure
-    only: ['branches', 'tags', 'triggers', 'merge_requests']
-    except:
-        - /^staging/.*$/i
+    rules:
+        - if: '$CI_COMMIT_REF_NAME =~ /^staging.*/'
+          when: never
+        - when: on_success
     retry:
         max: 2
         when:
@@ -65,9 +67,10 @@ variables:
             - runner_system_failure
             - stuck_or_timeout_failure
             - api_failure
-    only: ['branches', 'tags', 'triggers', 'merge-requests']
-    except:
-        - /^staging/.*$/i
+    rules:
+        - if: '$CI_COMMIT_REF_NAME =~ /^staging.*/'
+          when: never
+        - when: on_success
     retry:
         max: 2
         when:
@@ -75,20 +78,15 @@ variables:
     image: $CI_REGISTRY/ag-ohlberger/dune-community/dune-xt/ci_testing_${CI_IMAGE}:${CI_COMMIT_SHORT_SHA}
 
     before_script:
-      - mkdir /home/dune-ci/testresults && chmod -R 777 /home/dune-ci/testresults
-      - [[ -f ./.gitsuper ]] && echo "Please remove .gitsuper from the repo" && exit 1
-    script:
       - |
+        mkdir /home/dune-ci/testresults && chmod -R 777 /home/dune-ci/testresults
         [[ -f ./.gitsuper ]] && echo "Please remove .gitsuper from the repo" && exit 1
-        /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_cpp.bash
-        /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_python.bash
 
     artifacts:
       reports:
         junit: '/home/dune-ci/testresults/*xml'
     environment:
         name: unsafe
-    stage: test
 
 {% for image in images -%}
 {{ image }}:
@@ -97,8 +95,8 @@ variables:
         CI_IMAGE: {{ image }}
 {% endfor %}
 
-{% for image, subdir in matrix %}
-{{subdir}} {{ image[image.find('debian')+1+6:] }}:
+{% for image, subdir, kind in matrix %}
+{{subdir}} {{ image[image.find('debian')+1+6:] }} {{kind}}:
     extends: .subdir-test
     variables:
         CI_IMAGE: {{ image }}
@@ -107,6 +105,9 @@ variables:
     tags:
         - amm-only
     {%- endif %}
+    stage: {{kind}}
+    script:
+          - /home/dune-ci/src/${MY_MODULE}/.ci/shared/scripts/test_{{kind}}.bash
 {% endfor %}
 
 '''
@@ -118,6 +119,7 @@ from itertools import product
 tpl = jinja2.Template(tpl)
 images = ['debian-unstable_gcc_full', 'debian_gcc_full', 'debian_clang_full']
 subdirs = ['common', 'grid', 'functions', 'la']
-matrix = product(images, subdirs)
+kinds = ['cpp', 'python']
+matrix = product(images, subdirs, kinds)
 with open(os.path.join(os.path.dirname(__file__), 'config.yml'), 'wt') as yml:
     yml.write(tpl.render(matrix=matrix, images=images))
-- 
GitLab