+ return factory
+
+def symfony_project_factory(name, repourl, parameters_path="app/config/parameters.yml", other_steps=lambda a : []):
+ master_path_env = {
+ "PATH": os.environ["BUILDBOT_SYMFONY_MASTER_PATH"] + ":${PATH}"
+ }
+ path_env = {
+ "PATH": "/run/current-system/sw/bin"
+ }
+
+ for k, v in os.environ.items():
+ if k.startswith("BUILDBOT_SYMFONY_{}_".format(name)):
+ path_env[k[len("BUILDBOT_SYMFONY_{}_".format(name)):]] = v
+
+ factory = util.BuildFactory()
+ factory.addStep(steps.Git(logEnviron=False, repourl=repourl,
+ submodules=True, sshPrivateKey=open(E.SSH_KEY_PATH).read().rstrip(),
+ sshHostKey=E.SSH_HOST_KEY, mode="full", method="fresh"))
+ if parameters_path is not None:
+ factory.addStep(steps.FileDownload(mastersrc=get_parameters_file.withArgs(name),
+ workerdest=parameters_path))
+ factory.addStep(NixShellCommand(name="build website",
+ logEnviron=False, haltOnFailure=True,
+ env=path_env, command=get_composer_install_command.withArgs(name)))
+ if name in BRANCH_TO_POST_STEP:
+ factory.addStep(NixShellCommand(name="build website post",
+ logEnviron=False, haltOnFailure=True, doStepIf=partial(need_post_step, name),
+ env=path_env, command=get_post_step_command.withArgs(name)))
+ if parameters_path is not None:
+ factory.addStep(steps.ShellCommand(name="Remove parameters.yml",
+ logEnviron=False, haltOnFailure=True,
+ command="rm -f {}".format(parameters_path)))
+ for step in other_steps(path_env):
+ factory.addStep(step)
+ package = util.Interpolate("{}_%(kw:clean_branch)s.tar.gz".format(name), clean_branch=clean_branch)
+ release_file = "{0}/{1}/%(kw:clean_branch)s.tar.gz"
+ package_dest = util.Interpolate(release_file.format("/var/lib/ftp/release.immae.eu/buildbot", name), clean_branch=clean_branch)
+ # Tar doesn’t like creating the tarball in the same directory
+ factory.addStep(steps.ShellCommand(name="Make a tarball 1/2",
+ logEnviron=False, haltOnFailure=True, env=path_env,
+ command=["touch", package]))
+ factory.addStep(steps.ShellCommand(name="Make a tarball 2/2",
+ logEnviron=False, haltOnFailure=True, env=path_env,
+ command=["tar", "--exclude", package, "-czf", package, "."]))
+ factory.addStep(steps.SetPropertyFromCommand(command=get_systemd_service_invocation_command.withArgs(name),
+ property="service_invocation_id", doStepIf=partial(need_follow_systemd, name)))
+ factory.addStep(steps.FileUpload(name="upload package",
+ workersrc=package, masterdest=package_dest, mode=0o644))
+ factory.addStep(steps.MasterShellCommand(command=follow_systemd_command.withArgs(name, util.Property("service_invocation_id")), env=master_path_env, logEnviron=False, doStepIf=partial(need_follow_systemd, name)))
+ return factory