]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Add a NixShellCommand step to buildbot
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Sat, 26 Jun 2021 12:18:04 +0000 (14:18 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Sat, 26 Jun 2021 12:18:04 +0000 (14:18 +0200)
modules/private/buildbot/common/build_helpers.py
modules/private/buildbot/projects/immaeEu/__init__.py

index ed7ada368016b085e4aa8573cfae4ed1958a3d37..acea90591f5ca16b524e0e41b7d22087ef72cf7c 100644 (file)
@@ -1,10 +1,11 @@
 from buildbot.plugins import util, steps, schedulers
 from buildbot_buildslist import BuildsList
+from shutil import which
 
 __all__ = [
         "force_scheduler", "deploy_scheduler", "hook_scheduler",
         "clean_branch", "package_and_upload", "SlackStatusPush",
-        "XMPPStatusPush"
+        "XMPPStatusPush", "NixShellCommand"
         ]
 
 # Small helpers"
@@ -30,6 +31,26 @@ def package_and_upload(package, package_dest, package_url):
                 command=["rm", "-f", package]),
             ]
 
+# Steps
+class NixShellCommand(steps.ShellCommand):
+    def __init__(self, command=None, pure=True, nixfile=None, **kwargs):
+        assert(isinstance(command, str))
+        oldpath = kwargs.get("env", {}).get("PATH", None)
+        if which("nix-shell", path=oldpath) is None:
+            kwargs["env"] = kwargs.get("env", {})
+            if isinstance(oldpath, str):
+                kwargs["env"]["PATH"] = "/run/current-system/sw/bin:" + oldpath
+            elif isinstance(oldpath, list):
+                kwargs["env"]["PATH"] = ["/run/current-system/sw/bin"] + oldpath
+        nixcommand = ["nix-shell"]
+        if pure:
+            nixcommand.append("--pure")
+        nixcommand.append("--run")
+        nixcommand.append(command)
+        if nixfile is not None:
+            nixcommand.append(nixfile)
+        super().__init__(command=nixcommand, **kwargs)
+
 # Schedulers
 def force_scheduler(name, builders):
     return schedulers.ForceScheduler(name=name,
index dfe684c1ae8dc6e2e83547eef2d15c11a000a077..f119b4f2d2a49f3166a4399b0c1eaff1c755aec8 100644 (file)
@@ -147,9 +147,9 @@ def recettes_factory():
     factory.addStep(steps.Git(logEnviron=False, repourl=E.RECETTES_GIT_URL,
         submodules=True, sshPrivateKey=open(E.SSH_KEY_PATH).read().rstrip(),
         sshHostKey=E.SSH_HOST_KEY, mode="full", method="copy"))
-    factory.addStep(steps.ShellCommand(name="build website",
+    factory.addStep(NixShellCommand(name="build website",
         logEnviron=False, haltOnFailure=True, workdir="source",
-        env=path_env, command=["jekyll", "build", "--baseurl", "/recettes"]))
+        env=path_env, command="jekyll build --trace --baseurl /recettes"))
     factory.addStep(steps.MasterShellCommand(command="rm -rf {}".format(E.RECETTES_RELEASE_PATH)))
     factory.addStep(steps.DirectoryUpload(workersrc="../source/_site",
         masterdest=E.RECETTES_RELEASE_PATH,