This commit is contained in:
2026-10-10 14:32:07 +07:00
parent 6a198f2e2c
commit 3efdb52c3c
12 changed files with 524 additions and 105 deletions
+3 -48
View File
@@ -1,52 +1,7 @@
"""Check first, offline and update runs without Docker or production writes."""
"""Check the unified HTTPS deployment without Docker or production writes."""
from pathlib import Path
import os
import shutil
import subprocess
import tempfile
import sys
source = Path(__file__).resolve().parents[2] / "venue" / "deploy.sh"
for name, cold, update in [("first", True, False), ("offline", False, False), ("update", False, True)]:
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
venue = root / "venue"
venue.mkdir()
shutil.copy(source, venue / "deploy.sh")
log = root / "commands.log"
bin_dir = root / "bin"
bin_dir.mkdir()
for command in ["docker", "make", "npm"]:
stub = bin_dir / command
stub.write_text(
'#!/bin/sh\n'
'echo "$(basename "$0") $*" >> "$TEST_LOG"\n'
'if [ "$1 $2" = "image inspect" ] && [ "$TEST_COLD" = 1 ]; then exit 1; fi\n'
)
stub.chmod(0o755)
if not cold:
(venue / "migrations").mkdir()
(venue / ".env").write_text("EXISTING_SECRET=unchanged\n")
for artifact in ["backend/evening_detective_server", "backend/goose", "backend/dev-user.sql", "frontend/dist/index.html"]:
path = venue / artifact
path.parent.mkdir(parents=True, exist_ok=True)
path.touch()
env = {**os.environ, "PATH": str(bin_dir) + os.pathsep + os.environ["PATH"], "TEST_LOG": str(log), "TEST_COLD": str(int(cold))}
subprocess.run(["bash", str(venue / "deploy.sh"), *(["--build"] if update else [])], env=env, check=True, capture_output=True)
commands = log.read_text()
assert "volume create evening-detective-local_postgres_data" in commands, name
assert "volume create evening-detective-local_rustfs_data" in commands, name
assert "compose up -d --no-build --pull never" in commands, name
assert "compose --profile setup run --rm bootstrap" in commands, name
assert ("make -C .. build" in commands) == (cold or update), name
assert ("compose pull" in commands) == (cold or update), name
assert ("compose build --pull=false" in commands) == (cold or update), name
if cold:
config = dict(line.split("=", 1) for line in (venue / ".env").read_text().splitlines())
assert len(config["JWT_SECRET"]) == 64
assert len(config["VENUE_USER_PASSWORD"]) == 16
assert (venue / ".env").stat().st_mode & 0o777 == 0o600
else:
assert (venue / ".env").read_text() == "EXISTING_SECRET=unchanged\n", name
print("PASS: automatic first setup, offline reuse, explicit update and preserved secrets")
subprocess.run([sys.executable, str(Path(__file__).with_name("https.py"))], check=True)