From 6ee55548c78b5df8b3f50a0335edf89e2039a5a1 Mon Sep 17 00:00:00 2001
From: Felix Weiglhofer <weiglhofer@fias.uni-frankfurt.de>
Date: Mon, 30 Oct 2023 14:29:34 +0000
Subject: [PATCH] CI: Add verify step to ensure online container is runnable.

---
 .gitlab-ci.yml | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6ef4e62c9c..daba192922 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,6 +3,7 @@ stages:
   - checkFormat
   - build
   - package
+  - verify
   - finalise
   - documentation
 
@@ -548,6 +549,22 @@ BuildOnlineContainerMR:
     # Cache settings suggested by Copilot: --cache=true --cache-repo=${IMAGE_NAME} --cache-ttl=168h --cache-shared=true --cache-dir=/cache
     # TODO: Test if these work
 
+# Ensure the container we just build is usable, and not missing any dependencies
+VerifyOnlineContainerMR:
+  stage: verify
+  only:
+    - merge_requests
+  needs:
+    - BuildOnlineContainerMR
+  tags:
+    - docker
+  variables:
+    IMAGE_NAME: $CI_REGISTRY_IMAGE/cbm_online
+    IMAGE_TAG: mr$CI_MERGE_REQUEST_IID
+  image: $IMAGE_NAME:$IMAGE_TAG
+  script:
+    - cbmreco --help
+
 # Create container for master and DC_* branches on merge
 BuildOnlineContainerBranch:
   stage: package
@@ -569,6 +586,23 @@ BuildOnlineContainerBranch:
     - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
     - /kaniko/executor --context dir://$CI_PROJECT_DIR --dockerfile $DOCKERFILE --destination $IMAGE_NAME:$IMAGE_TAG
 
+VerifyOnlineContainerBranch:
+  stage: verify
+  only:
+    - master@computing/cbmroot
+    - nightly_master@computing/cbmroot
+    - /^DC_.*$/@computing/cbmroot
+  needs:
+    - BuildOnlineContainerBranch
+  tags:
+    - docker
+  variables:
+    IMAGE_NAME: $CI_REGISTRY_IMAGE/cbm_online
+    IMAGE_TAG: $CI_COMMIT_BRANCH
+  image: $IMAGE_NAME:$IMAGE_TAG
+  script:
+    - cbmreco --help
+
 InformCodeOwners:
   stage: finalise
   tags:
-- 
GitLab