cmdeploy: upload chatmail/relay version to /etc

This commit is contained in:
missytake
2025-05-15 14:38:01 +02:00
parent 6c27eaa506
commit 30b6df20a9
3 changed files with 26 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ Please fill out as much of this form as you can (leaving out stuff that is not a
- Server OS (Operating System) - preferably Debian 12: - Server OS (Operating System) - preferably Debian 12:
- On which OS you run cmdeploy: - On which OS you run cmdeploy:
- chatmail/relay version: `git rev-parse HEAD`
## Expected behavior ## Expected behavior

View File

@@ -7,6 +7,7 @@ import io
import shutil import shutil
import subprocess import subprocess
import sys import sys
from io import StringIO
from pathlib import Path from pathlib import Path
from chatmaild.config import Config, read_config from chatmaild.config import Config, read_config
@@ -757,5 +758,13 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None:
name="Ensure cron is installed", name="Ensure cron is installed",
packages=["cron"], packages=["cron"],
) )
git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode()
git_diff = subprocess.check_output(["git", "diff"]).decode()
files.put(
name="Upload chatmail relay version",
src=StringIO(git_hash + git_diff),
dest="/etc/chatmail-version",
mode="700",
)
deploy_mtail(config) deploy_mtail(config)

View File

@@ -1,5 +1,6 @@
import datetime import datetime
import smtplib import smtplib
import subprocess
import pytest import pytest
@@ -191,3 +192,18 @@ def test_expunged(remote, chatmail_config):
for cmd in find_cmds: for cmd in find_cmds:
for line in remote.iter_output(cmd): for line in remote.iter_output(cmd):
assert not line assert not line
def test_deployed_state(remote):
git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode()
git_diff = subprocess.check_output(["git", "diff"]).decode()
git_status = [git_hash.strip()]
for line in git_diff.splitlines():
git_status.append(line.strip().lower())
remote_version = []
for line in remote.iter_output("cat /etc/chatmail-version"):
print(line)
remote_version.append(line)
# assert len(git_status) == len(remote_version) # for some reason, we only get 11 lines from remote.iter_output()
for i in range(len(remote_version)):
assert git_status[i] == remote_version[i], "You have undeployed changes."