From 3d69c9d06bb7c9a21cbcc5891ddbe2ecfb2cdd66 Mon Sep 17 00:00:00 2001
From: "robinwilliam.hundt" <robinwilliam.hundt@stud.uni-goettingen.de>
Date: Thu, 10 Oct 2019 20:42:44 +0200
Subject: [PATCH] Optimized pipeline

---
 .gitlab-ci.yml | 63 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 38 insertions(+), 25 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8caa909b..554892d1 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,7 +2,6 @@ stages:
   - build
   - test
   - build_image
-  - test_build
   - pages
   - staging
 
@@ -32,6 +31,8 @@ build_test_env:
       - .venv
   tags:
     - docker
+  interruptible: true
+
 
 build_frontend:
   image: node:carbon
@@ -54,6 +55,29 @@ build_frontend:
       - frontend/node_modules/
   tags:
     - docker
+  interruptible: true
+
+build_test_image:
+  image: docker:latest
+  stage: build
+  only:
+    - branches
+  services:
+    - docker:dind
+  variables:
+    DOCKER_HOST: tcp://docker:2375/
+    DOCKER_DRIVER: overlay2
+  script:
+    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
+    - docker pull $DEV_IMAGE_BASE || true
+    - docker build --cache-from $DEV_IMAGE_BASE -t $DEV_IMAGE_BASE --target node .
+    - docker pull $DEV_IMAGE || true
+    - docker build --cache-from $DEV_IMAGE --cache-from $DEV_IMAGE_BASE -t $DEV_IMAGE .
+    - docker push $DEV_IMAGE_BASE
+    - docker push $DEV_IMAGE
+  tags:
+    - docker
+  interruptible: true
 
 # ============================== Testing section ============================= #
 # ----------------------------- Backend subsection --------------------------- #
@@ -65,6 +89,9 @@ build_frontend:
     - build_test_env
   tags:
     - docker
+  interruptible: true
+  needs:
+    - build_test_env
 
 test_pytest:
   <<: *test_definition_virtualenv
@@ -97,6 +124,10 @@ test_flake8:
     - build_frontend
   tags:
     - docker
+  interruptible: true
+  needs:
+    - build_frontend
+    - build_test_env
 
 test_frontend:
   <<: *test_definition_frontend
@@ -124,37 +155,17 @@ test_frontend_unit:
   script:
     - cd frontend/
     - yarn test:unit
-
+  interruptible: true
+  needs:
+    - build_frontend
 
 # =========================== Build Image section ============================ #
-build_dev_image:
-  image: docker:latest
-  stage: build_image
-  only:
-    - branches
-  services:
-    - docker:dind
-  variables:
-    DOCKER_HOST: tcp://docker:2375/
-    DOCKER_DRIVER: overlay2
-  script:
-    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
-    - docker pull $DEV_IMAGE_BASE || true
-    - docker build --cache-from $DEV_IMAGE_BASE -t $DEV_IMAGE_BASE --target node .
-    - docker pull $DEV_IMAGE || true
-    - docker build --cache-from $DEV_IMAGE --cache-from $DEV_IMAGE_BASE -t $DEV_IMAGE .
-    - docker push $DEV_IMAGE_BASE
-    - docker push $DEV_IMAGE
-  tags:
-    - docker
 
 build_release_image:
   image: docker:latest
   stage: build_image
   only:
     - tags
-  except:
-    - branches
   services:
     - docker:dind
   variables:
@@ -184,7 +195,9 @@ pages:
       - public
   only:
     - master
-
+  interruptible: true
+  needs:
+    - test_pytest
 
 # ============================== Staging section ============================= #
 .staging_template: &staging_definition
-- 
GitLab