diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2021-06-26 14:18:04 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2021-06-26 14:18:04 +0200 |
commit | 6b017278cb0dff04fc6cde863a1bffa012ed5f59 (patch) | |
tree | d7030c44a8ed562de79350b5ff75225aebc73e62 /modules/private/buildbot | |
parent | ecd9a3060bdcc4309e4fad6c046b72b880618774 (diff) | |
download | Nix-6b017278cb0dff04fc6cde863a1bffa012ed5f59.tar.gz Nix-6b017278cb0dff04fc6cde863a1bffa012ed5f59.tar.zst Nix-6b017278cb0dff04fc6cde863a1bffa012ed5f59.zip |
Add a NixShellCommand step to buildbot
Diffstat (limited to 'modules/private/buildbot')
-rw-r--r-- | modules/private/buildbot/common/build_helpers.py | 23 | ||||
-rw-r--r-- | modules/private/buildbot/projects/immaeEu/__init__.py | 4 |
2 files changed, 24 insertions, 3 deletions
diff --git a/modules/private/buildbot/common/build_helpers.py b/modules/private/buildbot/common/build_helpers.py index ed7ada3..acea905 100644 --- a/modules/private/buildbot/common/build_helpers.py +++ b/modules/private/buildbot/common/build_helpers.py | |||
@@ -1,10 +1,11 @@ | |||
1 | from buildbot.plugins import util, steps, schedulers | 1 | from buildbot.plugins import util, steps, schedulers |
2 | from buildbot_buildslist import BuildsList | 2 | from buildbot_buildslist import BuildsList |
3 | from shutil import which | ||
3 | 4 | ||
4 | __all__ = [ | 5 | __all__ = [ |
5 | "force_scheduler", "deploy_scheduler", "hook_scheduler", | 6 | "force_scheduler", "deploy_scheduler", "hook_scheduler", |
6 | "clean_branch", "package_and_upload", "SlackStatusPush", | 7 | "clean_branch", "package_and_upload", "SlackStatusPush", |
7 | "XMPPStatusPush" | 8 | "XMPPStatusPush", "NixShellCommand" |
8 | ] | 9 | ] |
9 | 10 | ||
10 | # Small helpers" | 11 | # Small helpers" |
@@ -30,6 +31,26 @@ def package_and_upload(package, package_dest, package_url): | |||
30 | command=["rm", "-f", package]), | 31 | command=["rm", "-f", package]), |
31 | ] | 32 | ] |
32 | 33 | ||
34 | # Steps | ||
35 | class NixShellCommand(steps.ShellCommand): | ||
36 | def __init__(self, command=None, pure=True, nixfile=None, **kwargs): | ||
37 | assert(isinstance(command, str)) | ||
38 | oldpath = kwargs.get("env", {}).get("PATH", None) | ||
39 | if which("nix-shell", path=oldpath) is None: | ||
40 | kwargs["env"] = kwargs.get("env", {}) | ||
41 | if isinstance(oldpath, str): | ||
42 | kwargs["env"]["PATH"] = "/run/current-system/sw/bin:" + oldpath | ||
43 | elif isinstance(oldpath, list): | ||
44 | kwargs["env"]["PATH"] = ["/run/current-system/sw/bin"] + oldpath | ||
45 | nixcommand = ["nix-shell"] | ||
46 | if pure: | ||
47 | nixcommand.append("--pure") | ||
48 | nixcommand.append("--run") | ||
49 | nixcommand.append(command) | ||
50 | if nixfile is not None: | ||
51 | nixcommand.append(nixfile) | ||
52 | super().__init__(command=nixcommand, **kwargs) | ||
53 | |||
33 | # Schedulers | 54 | # Schedulers |
34 | def force_scheduler(name, builders): | 55 | def force_scheduler(name, builders): |
35 | return schedulers.ForceScheduler(name=name, | 56 | return schedulers.ForceScheduler(name=name, |
diff --git a/modules/private/buildbot/projects/immaeEu/__init__.py b/modules/private/buildbot/projects/immaeEu/__init__.py index dfe684c..f119b4f 100644 --- a/modules/private/buildbot/projects/immaeEu/__init__.py +++ b/modules/private/buildbot/projects/immaeEu/__init__.py | |||
@@ -147,9 +147,9 @@ def recettes_factory(): | |||
147 | factory.addStep(steps.Git(logEnviron=False, repourl=E.RECETTES_GIT_URL, | 147 | factory.addStep(steps.Git(logEnviron=False, repourl=E.RECETTES_GIT_URL, |
148 | submodules=True, sshPrivateKey=open(E.SSH_KEY_PATH).read().rstrip(), | 148 | submodules=True, sshPrivateKey=open(E.SSH_KEY_PATH).read().rstrip(), |
149 | sshHostKey=E.SSH_HOST_KEY, mode="full", method="copy")) | 149 | sshHostKey=E.SSH_HOST_KEY, mode="full", method="copy")) |
150 | factory.addStep(steps.ShellCommand(name="build website", | 150 | factory.addStep(NixShellCommand(name="build website", |
151 | logEnviron=False, haltOnFailure=True, workdir="source", | 151 | logEnviron=False, haltOnFailure=True, workdir="source", |
152 | env=path_env, command=["jekyll", "build", "--baseurl", "/recettes"])) | 152 | env=path_env, command="jekyll build --trace --baseurl /recettes")) |
153 | factory.addStep(steps.MasterShellCommand(command="rm -rf {}".format(E.RECETTES_RELEASE_PATH))) | 153 | factory.addStep(steps.MasterShellCommand(command="rm -rf {}".format(E.RECETTES_RELEASE_PATH))) |
154 | factory.addStep(steps.DirectoryUpload(workersrc="../source/_site", | 154 | factory.addStep(steps.DirectoryUpload(workersrc="../source/_site", |
155 | masterdest=E.RECETTES_RELEASE_PATH, | 155 | masterdest=E.RECETTES_RELEASE_PATH, |