Skip to contentSkip to conversation

Switch to self-built container images for lava test jobs

PATCH New Jan Kiszka 1 participant 3 messages Nov 14, 2024

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

v2 cover Switch to self-built container images for lava test jobs

Changes in v2:
- add curl to container
- set default for CONTAINER_REGISTRY
- document new CI variables

Saves bits (and money), speeds up test job starts, avoids current snapshot.d.o issues.

Jan

Jan Kiszka (2):
ci: Add scheduled job to build lavacli container
ci: Switch test job container to self-built one

 .gitlab-ci.yml             | 15 ++++++++++++++-
 ci/Dockerfile.lavacli      | 17 +++++++++++++++++
 ci/gitlab-ci-base.yml      |  2 +-
 scripts/install-lavacli.sh | 23 -----------------------
 tests/README.md            |  5 +++++
 5 files changed, 37 insertions(+), 25 deletions(-)
 create mode 100644 ci/Dockerfile.lavacli
 delete mode 100755 scripts/install-lavacli.sh
Signature · 1 line
2.43.0
author
#1 lore raw

PATCH v2 1/2 ci: Add scheduled job to build lavacli container

From: Jan Kiszka <[email protected]>

We want to switch to self-built Debian containers with lavacli pre-installed. That will speed-up the start of test jobs and avoid the manual installation of lavacli in each of them. To keep that container up to date, prepare a pipeline job that will be scheduled once a month to perform a build and deployment to gitlab.com (source.denx.de lacks a container registry).

---
 .gitlab-ci.yml        | 15 ++++++++++++++-
 ci/Dockerfile.lavacli | 17 +++++++++++++++++
 tests/README.md       |  5 +++++
 3 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 ci/Dockerfile.lavacli
.gitlab-ci.yml +14 -1
index b8945bc..6f9bcd6 100644
@@ -12,9 +12,11 @@
 variables:
   LAVA_TESTS_ENABLED: "true"
   ALL_QEMU_JOBS: "false"
+  CONTAINER_REGISTRY: "registry.gitlab.com"
 
 stages:
   - parent
+  - build
 
 .parent:
   stage: parent
@@ -56,4 +58,15 @@ xenomai-3/next-long-term:
     include:
       - local: '/ci/xenomai_3_next_long_term.yml'
   rules:
-  - if: $CI_PIPELINE_SOURCE == "schedule"
+    - if: '$CI_PIPELINE_SOURCE == "schedule" && $ONLY_RUN == $CI_JOB_NAME'
+
+lavacli-container:
+  image: quay.io/buildah/stable
+  stage: build
+  before_script:
+    - buildah login -u "$CONTAINER_DEPLOY_TOKEN_USER" --password $CONTAINER_DEPLOY_TOKEN_PWD $CONTAINER_REGISTRY
+  script:
+    - buildah build -f ci/Dockerfile.lavacli -t $CONTAINER_REGISTRY/xenomai/xenomai-lava-container/lavacli .
+    - buildah push $CONTAINER_REGISTRY/xenomai/xenomai-lava-container/lavacli
+  rules:
+    - if: '$CI_PIPELINE_SOURCE == "schedule" && $ONLY_RUN == $CI_JOB_NAME'
ci/Dockerfile.lavacli new file +17 -0
new file mode 100644
index 0000000..b3daa2a
@@ -0,0 +1,17 @@
+#
+# Xenomai Real-Time System
+#
+# Copyright (c) Siemens AG, 2024
+#
+# Authors:
+#  Jan Kiszka <[email protected]>
+#
+# SPDX-License-Identifier: MIT
+#
+
+FROM debian:stable
+
+ARG DEBIAN_FRONTEND=noninteractive
+
+RUN apt-get update && \
+    apt-get install -y sudo gettext-base curl jq xmlstarlet lavacli
tests/README.md +5 -0
index c3f05cd..b6421b4 100644
@@ -110,6 +110,7 @@ The following variables are used and set by the ci system:
   - `LAVA_MASTER_TOKEN`: token to connect with the lava master
   - `LAVA_ARTIFACTS_URL`: optional variable where to get the artifacts for testing
   - `LAVA_MASTER_URL`: URL to the LAVA Master
+  - `CONTAINER_REGISTRY`: Container registry server to pull lavacli base image from. Uses registry.gitlab.com if unset.
 
 - Image deployment settings:
   - `USE_S3_BUCKET`: Set to `1` in order to upload build artifacts to AWS S3
@@ -120,6 +121,10 @@ The following variables are used and set by the ci system:
 - Build settings:
   - `BUILD_OPTIONS` : optional parameter. Used for triggers. Overwrite to build the newest ipipe together with xenomai or other combinations.
 
+- Scheduled lavacli container build (not needed if using official container):
+  - `CONTAINER_DEPLOY_TOKEN_USER`: Username of deploy token for uploading lavacli container to `CONTAINER_REGISTRY`
+  - `CONTAINER_DEPLOY_TOKEN_PWD`: Password of deploy token for uploading lavacli container to `CONTAINER_REGISTRY`
+
 ## LAVA Template variable
 
 - `TARGET`: Name of the target in the LAVA Lab
Signature · 1 line
2.43.0
author
#2 lore raw

PATCH v2 2/2 ci: Switch test job container to self-built one

In reply to Jan Kiszka

From: Jan Kiszka <[email protected]>

Speeds up a the start of test jobs, avoids access to snapshot.d.o (as used by kas-isar containers).

---
 ci/gitlab-ci-base.yml      |  2 +-
 scripts/install-lavacli.sh | 23 -----------------------
 2 files changed, 1 insertion(+), 24 deletions(-)
 delete mode 100755 scripts/install-lavacli.sh
ci/gitlab-ci-base.yml +1 -1
index a40dbcb..853d929 100644
@@ -93,12 +93,12 @@ default:
 
 .test:
   stage: test
+  image: $CONTAINER_REGISTRY/xenomai/xenomai-lava-container/lavacli
   tags:
     - lava
   before_script:
     - !reference [.common-config, script]
   script:
-    - scripts/install-lavacli.sh
     - scripts/run-lava-tests.sh ${TARGET}
   variables:
     BUILD_JOB_NAME: "build-${BUILD_IDENTIFIER}:${TARGET}"
scripts/install-lavacli.sh deleted +0 -23
deleted file mode 100755
index ae61497..0000000
@@ -1,23 +0,0 @@
-#!/bin/sh
-#
-# Xenomai Real-Time System
-#
-# Copyright (c) Siemens AG, 2019
-#
-# Authors:
-#  Quirin Gylstorff <[email protected]>
-#
-# SPDX-License-Identifier: MIT
-#
-# check if Debian 10 or later. If not use the pip version
-# of lavacli. The apt version from stretch-backports cannot communicate
-# with the lava master on Debian 10.
-os_version_id=$(sed -nr 's/VERSION_ID="([0-9]+)"/\1/p' /etc/os-release)
-sudo apt-get update
-sudo apt-get install -y jq xmlstarlet
-if [ "${os_version_id}" -ge "10" ]; then
-    sudo apt-get install -y lavacli
-else
-    sudo pip3 install wheel
-    sudo pip3 install lavacli
-fi
Signature · 1 line
2.43.0