phase1: automatically setup shared work directory symlink
authorJo-Philipp Wich <jo@mein.io>
Tue, 16 Jul 2019 17:12:29 +0000 (19:12 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 16 Jul 2019 17:12:29 +0000 (19:12 +0200)
Until now, the shared work directory symlinks had to be provisioned
manually, this commits automates the setup when work directory sharing
is enabled for the slave.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
phase1/master.cfg

index a8abbc607ef51a05fc10f2d7ab2f453be288c02e..ff2f3e23b39fc1b790e06af2e694d7ec61090fae 100644 (file)
@@ -251,9 +251,11 @@ def IsMakeCleanRequested(pattern):
 
        return CheckCleanProperty
 
+def IsSharedWorkdir(step):
+       return bool(step.getProperty("shared_wd"))
+
 def IsCleanupRequested(step):
-       shared_wd = step.getProperty("shared_wd")
-       if shared_wd:
+       if IsSharedWorkdir(step):
                return False
        do_cleanup = step.getProperty("do_cleanup")
        if do_cleanup:
@@ -262,8 +264,7 @@ def IsCleanupRequested(step):
                return False
 
 def IsExpireRequested(step):
-       shared_wd = step.getProperty("shared_wd")
-       if shared_wd:
+       if IsSharedWorkdir(step):
                return False
        else:
                return not IsCleanupRequested(step)
@@ -464,6 +465,15 @@ for target in targets:
 
        factory = BuildFactory()
 
+       # setup shared work directory if required
+       factory.addStep(ShellCommand(
+               name = "sharedwd",
+               description = "Setting up shared work directory",
+               command = 'test -L "$PWD" || (mkdir -p "../shared-workdir" && rm -rf "$PWD" && ln -s shared-workdir "$PWD")',
+               workdir = ".",
+               haltOnFailure = True,
+               doStepIf = IsSharedWorkdir))
+
        # find number of cores
        factory.addStep(SetPropertyFromCommand(
                name = "nproc",