From cf922d9ee24b8e6787fbd0ef0aa7d05e73a9f387 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20H=C3=B6ppner?= <jonas.hoeppner@garz-fricke.com>
Date: Wed, 15 Sep 2021 16:43:42 +0200
Subject: [PATCH] CI: Unroll the job matrix to own jobs so dependencies can be
 expressed

The matrix jobs have all to be finished before followup jobs may be run,
if the jobs are split up into own job description, the imx6 test can
be configured to wait only for the imx6 build, not for all images to be
finished.

Change-Id: I6c3495fa01f0bac287d0d4977c67405c869021a6
---
 .gitlab-ci.yml | 108 +++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 87 insertions(+), 21 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0c2653bc..45fcd7e4 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -100,33 +100,33 @@ yamllint:
 # --------------------------------------------------------------------------------------
 # Stage: build
 # --------------------------------------------------------------------------------------
-buildimage:
+.buildimage:
   extends:
     - .buildbase
     - .build
+  variables:
+    CI_PARAM_IMAGE: guf-image
+    CI_PARAM_DISTRO: guf-wayland
   needs: []
-  stage: image
-  parallel:
-    matrix:
-      # Yocto OS
-      - CI_PARAM_MACHINE: [imx6guf, imx6ullguf, imx8mguf]
-        CI_PARAM_DISTRO: [guf-wayland]
-        CI_PARAM_IMAGE: [guf-image]
-      # FNG System
-      - CI_PARAM_MACHINE: [imx6guf, imx6ullguf, imx8mguf]
-        CI_PARAM_DISTRO: [guf-fngsystem]
-        CI_PARAM_IMAGE: [fngsystem-image]
+
+.buildfng:
+  extends:
+    - .buildimage
+  variables:
+    CI_PARAM_IMAGE: fngsystem-image
+    CI_PARAM_DISTRO: guf-fngsystem
+
+# ---------------------------------------------------------------------------------------
 
 # --------------------------------------------------------------------------------------
 # Stage: deploy
 # --------------------------------------------------------------------------------------
-deployimage:
+.deployimage:
   variables:
     GIT_SUBMODULE_STRATEGY: normal
   extends:
     - .buildbase
     - .package
-  stage: deploy
   when: manual
   script:
     - echo
@@ -139,10 +139,8 @@ deployimage:
 # --------------------------------------------------------------------------------------
 buildsdk:
   extends:
-    - .buildbase
-    - .build
+    - .buildimage
     - .package_sdk
-  needs: []
   stage: sdk
   when: manual
   variables:
@@ -150,10 +148,6 @@ buildsdk:
   parallel:
     matrix:
       - CI_PARAM_MACHINE: [imx6guf, imx6ullguf, imx8mguf]
-        CI_PARAM_DISTRO: [guf-wayland]
-        CI_PARAM_IMAGE: [guf-image]
-
-# --------------------------------------------------------------------------------------
 # Stage: documentation
 # --------------------------------------------------------------------------------------
 changelog:
@@ -173,3 +167,75 @@ changelog:
     expire_in: 4 weeks
     paths:
       - "changelog.md"
+
+# ---------------------------------------------------------------------------------------
+# Actual jobs
+# ---------------------------------------------------------------------------------------
+
+build:imx6guf:guf-wayland:
+  extends: .buildimage
+  stage: image
+  variables:
+    CI_PARAM_MACHINE: imx6guf
+
+build:imx6ullguf:guf-wayland:
+  extends: .buildimage
+  stage: image
+  variables:
+    CI_PARAM_MACHINE: imx6ullguf
+
+build:imx8mguf:guf-wayland:
+  extends: .buildimage
+  stage: image
+  variables:
+    CI_PARAM_MACHINE: imx8mguf
+
+build:imx6guf:guf-fngsystem:
+  extends: .buildfng
+  stage: image
+  variables:
+    CI_PARAM_MACHINE: imx6guf
+
+build:imx6ullguf:guf-fngsystem:
+  extends: .buildfng
+  stage: image
+  variables:
+    CI_PARAM_MACHINE: imx6ullguf
+
+build:imx8mguf:guf-fngsystem:
+  extends: .buildfng
+  stage: image
+  variables:
+    CI_PARAM_MACHINE: imx8mguf
+
+# -------------------------------------------------------------------------------------
+
+deployimage:imx6guf:guf-wayland:
+  extends: .deployimage
+  stage: deploy
+  needs: ["build:imx6guf:guf-wayland", "changelog"]
+
+deployimage:imx6ullguf:guf-wayland:
+  extends: .deployimage
+  stage: deploy
+  needs: ["build:imx6ullguf:guf-wayland", "changelog"]
+
+deployimage:imx8mguf:guf-wayland:
+  extends: .deployimage
+  stage: deploy
+  needs: ["build:imx8mguf:guf-wayland", "changelog"]
+
+deployimage:imx6guf:guf-fngsystem:
+  extends: .deployimage
+  stage: deploy
+  needs: ["build:imx6guf:guf-fngsystem", "changelog"]
+
+deployimage:imx6ullguf:guf-fngsystem:
+  extends: .deployimage
+  stage: deploy
+  needs: ["build:imx6ullguf:guf-fngsystem", "changelog"]
+
+deployimage:imx8mguf:guf-fngsystem:
+  extends: .deployimage
+  stage: deploy
+  needs: ["build:imx8mguf:guf-fngsystem", "changelog"]
-- 
GitLab