Install and start the server only together with the web app

./install builds the web app and the server before replacing either, and
fails without Docker or on a failed build, leaving the old pair in place.
The supervisor and start refuse to run the server when the web app is not
installed.
This commit is contained in:
2026-10-31 19:08:25 +00:00
parent 24956266d8
commit 53be2e5334
4 changed files with 118 additions and 26 deletions
+37 -6
View File
@@ -49,7 +49,7 @@ def fake_ntfy_serve(command, **kwargs):
class Recorder:
def __init__(self, token=TOKEN, volumes=(), image="pipelines-pipelines:latest",
fail_create=False, fail_copy=False, fail_volume_ls=False, fail_build=False,
fail_create=False, fail_copy=False, fail_volume_ls=False, fail_build=False, fail_web=False,
host_model="fixture/host-default"):
self.calls = []
self.token = token
@@ -59,6 +59,7 @@ class Recorder:
self.fail_copy = fail_copy
self.fail_volume_ls = fail_volume_ls
self.fail_build = fail_build
self.fail_web = fail_web
self.host_model = host_model
self._module_cache = None
self.kwargs = []
@@ -95,6 +96,11 @@ class Recorder:
stdout = self.image + "\n" if self.image else ""
elif command[1] == "create" and self.fail_create:
code = 1
elif command[1] == "run" and "pipelines-app-build" in command:
# The fake app build writes its output to the /out mount.
out = next(v for v in command if v.endswith(":/out")).rsplit(":", 1)[0]
if not self.fail_web:
(Path(out) / "index.html").write_text("app")
elif command[1] == "cp":
if self.fail_copy:
code = 1
@@ -106,12 +112,11 @@ class Recorder:
if self.fail_build:
code = 1
elif "-o" in command:
# Only the ntfy build is inspected by the installer; its output
# is created so the atomic install has a real file to move.
# Every build output is created so the atomic installs have real
# files to move.
output = Path(command[command.index("-o") + 1])
if output.name == "ntfy":
output.write_bytes(b"#!/bin/sh\n")
output.chmod(0o755)
output.write_bytes(b"#!/bin/sh\n")
output.chmod(0o755)
if command[0].endswith("ntfy") and "token" in command:
stdout = f"token {self.token} created for pipeline-publisher\n"
return subprocess.CompletedProcess(command, code, stdout=stdout, stderr="")
@@ -728,6 +733,32 @@ class SetupNativeTests(unittest.TestCase):
self.assertFalse(any("start" in call for call in recorder.calls))
self.assertNotIn("Native Pipelines installed", output.getvalue())
def test_install_is_all_or_nothing_with_the_web_app(self):
cases = {"no docker": dict(docker=False), "web build fails": dict(fail_web=True),
"server build fails": dict(fail_build=True)}
for name, case in cases.items():
with self.subTest(case=name), tempfile.TemporaryDirectory() as directory:
recorder = Recorder(fail_web=case.get("fail_web", False),
fail_build=case.get("fail_build", False))
installer = self.installer(directory, recorder)
prefix = installer.resolve_prefix()
(prefix / "bin").mkdir(parents=True)
(prefix / "bin/pipelines-server").write_text("old")
(prefix / "lib/app-web").mkdir(parents=True)
(prefix / "lib/app-web/index.html").write_text("old")
with patch.object(setup_native.shutil, "which", side_effect=self.which_all()), \
patch.object(setup_native.app_build, "docker_available",
return_value=case.get("docker", True)), \
patch.object(setup_native.lan, "detect_lan", return_value="192.168.1.20"), \
redirect_stdout(io.StringIO()):
with self.assertRaises(ValueError):
installer.run(setup_native.arguments([]))
# Neither half was replaced and nothing claims an install.
self.assertEqual((prefix / "bin/pipelines-server").read_text(), "old")
self.assertEqual((prefix / "lib/app-web/index.html").read_text(), "old")
self.assertFalse((prefix / setup_native.MARKER).exists())
self.assertFalse((prefix / "bin/.next").exists())
def test_picker_cancellation_or_unsaved_models_never_claim_configuration_complete(self):
for returncode in (0, 1):
with self.subTest(returncode=returncode), tempfile.TemporaryDirectory() as directory: