gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-deployment] 05/05: buildbot: prep workspace for the container job


From: gnunet
Subject: [taler-deployment] 05/05: buildbot: prep workspace for the container jobs
Date: Mon, 12 Jun 2023 20:58:19 +0200

This is an automated email from the git hooks/post-receive script.

devan-carpenter pushed a commit to branch master
in repository deployment.

commit 4aadff04ba6f007e6918e31401235547f223387b
Author: Devan Carpenter <devan@taler.net>
AuthorDate: Wed Jun 7 14:55:40 2023 -0400

    buildbot: prep workspace for the container jobs
    
    we want to clone down the project repo and prepare the workspace at the
    beginning of any container factory run.
---
 buildbot/master.cfg | 78 ++++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 56 insertions(+), 22 deletions(-)

diff --git a/buildbot/master.cfg b/buildbot/master.cfg
index 2059d0f..dcb043f 100644
--- a/buildbot/master.cfg
+++ b/buildbot/master.cfg
@@ -25,7 +25,9 @@
 # @author Christian Grothoff
 # @author Devan Carpenter
 import re
+
 from getpass import getuser
+
 from buildbot.steps.source.git import Git
 from buildbot.steps.shell import ShellCommand
 from buildbot.plugins import *
@@ -159,15 +161,21 @@ def update_deployment(factory):
         workdir="../.."
     ))
 
+
 # Convenience function that builds and runs a container.
-def container_job_run(jobCmd="/workdir/ci/ci.sh",):
+def container_run_step(factory, WORK_DIR, containerName,
+                       jobCmd="/workdir/ci/ci.sh"):
     factory.addStep(steps.ShellSequence(
-        name="container build and run"
-       commands=[
-           util.ShellArg(command=["podman", "build", "-t", containerName, 
"."]),
-           util.ShellArg(command=["podman", "run", "-ti", "--rm", "--volume", 
"$PWD:/workdir", "--workdir", "/workdir", containerName, jobCmd]),
-       ],
-       haltOnFailure=True
+        name="container build and run",
+        commands=[
+            util.ShellArg(command=["podman", "build", "-t", containerName,
+                                   "."]),
+            util.ShellArg(command=["podman", "run", "-ti", "--rm", "--volume",
+                                   "$PWD:/workdir", "--workdir", "/workdir",
+                                   containerName, jobCmd]),
+        ],
+        haltOnFailure=True,
+        workdir=WORK_DIR
     ))
 
 ##################################################################
@@ -1170,31 +1178,57 @@ BUILDERS.append(util.BuilderConfig(
 EMAIL_ALERTS.append("packaging-debian-builder")
 EMAIL_ALERTS.append("packaging-ubuntu-builder")
 
-################ 19: CONTAINER FACTORY ###################################
+#############################################
+# 19: CONTAINER FACTORY #####################
+#############################################
 ##
 # These factories uses the standard podman worker.
 WORKERS.append(worker.Worker("container-worker", "container-pass"))
 
-
-#container_repos = ["backoffice", "wallet-core", "bank", "exchange",
-#                   "merchant", "deployment", "twister", "sync",
-#                 "help", "taler-merchant-demos", "challenger"]
+#
+# container_repos = ["backoffice", "wallet-core", "bank", "exchange",
+#                    "merchant", "deployment", "twister", "sync",
+#                           "help", "taler-merchant-demos", "challenger"]
 #
 container_repos = ["wallet-core"]
 
 for reponame in container_repos:
     ##
     # Factory-wide variables
-    GIT_REPO="https://git.taler.net/"; + reponame[0] + ".git"
+    REPO_URL = "https://git.taler.net/"; + reponame[0] + ".git"
+    CONTAINER_WORKDIR = f"/home/container-worker/workspace/{reponame[0]}"
 
+    # Create a factory
     container_factory = util.BuildFactory()
-    ##
-    # Pull repo for given project
-    container_factory.addStep(git_step(GIT_REPO,"dvn/container-ci"))
-    container_factory.addStep(container_run_step)
-    
+    container_factory.workdir = CONTAINER_WORKDIR
+
+    # Setup workspace
+    container_factory.addStep(ShellCommand(
+        name="workspace",
+        descriptionDone="Workspace directory check",
+        command=f"test -d {CONTAINER_WORKDIR} || mkdir -p {CONTAINER_WORKDIR}",
+        haltOnFailure=True,
+    ))
+
+    # Ensure repo is cloned or clean.
+    # Git() will clone repo if it doesn't exist.
+    # Method fresh runs 'git clean -f -f -d -x', if checkout already exists.
+    # Only works with mode='full'
+    # Will checkout value of "branch" property from job properties.
+    # 
https://docs.buildbot.net/latest/manual/configuration/steps/source_git.html
+    container_factory.addStep(Git(
+        name="git",
+        repourl=REPO_URL,
+        mode='full',
+        method='fresh',
+        haltOnFailure=True,
+    ))
+
+    # Run container step with default commands
+    container_run_step(container_factory, CONTAINER_WORKDIR, reponame[0])
+
     BUILDERS.append(util.BuilderConfig(
-        name=reponame + "-builder",
+        name=f"{reponame[0]}-builder",
         workernames=["container-worker"],
         factory=container_factory
     ))
@@ -1202,11 +1236,11 @@ for reponame in container_repos:
     SCHEDULERS.append(schedulers.SingleBranchScheduler(
         name="container-scheduler",
         change_filter=util.ChangeFilter(
-            branch="dvn/container-ci",
-            project_re="(" + reponame + ")"
+            branch="dev/dvn/container-ci",
+            project_re=f"({reponame[0]})"
         ),
         treeStableTimer=None,
-        builderNames=[reponame + "-builder"]
+        builderNames=[f"{reponame[0]}-builder"]
     ))
 
 ## TODO: TBD

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]