Harden live release workflow #25
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import fcntl
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def test_repo_upgrade_refuses_concurrent_run(tmp_path):
|
||||
script = Path(__file__).parents[1] / "deploy" / "repo-upgrade.sh"
|
||||
lock_path = tmp_path / "repo-upgrade.lock"
|
||||
bin_dir = tmp_path / "bin"
|
||||
bin_dir.mkdir()
|
||||
fake_id = bin_dir / "id"
|
||||
fake_id.write_text("#!/bin/sh\nprintf '0\\n'\n")
|
||||
fake_id.chmod(0o755)
|
||||
|
||||
with lock_path.open("w") as lock:
|
||||
fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
result = subprocess.run(
|
||||
["sh", str(script), "v1.2.3"],
|
||||
env={
|
||||
**os.environ,
|
||||
"PATH": f"{bin_dir}:{os.environ['PATH']}",
|
||||
"IMPORTARR_ENV_FILE": str(tmp_path / "missing.env"),
|
||||
"IMPORTARR_PREFIX": str(tmp_path),
|
||||
},
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
|
||||
assert result.returncode == 1
|
||||
assert "another Importarr upgrade is already running" in result.stderr
|
||||
Reference in New Issue
Block a user