diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 7263bb2f..3c3c4f97 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -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: - On which OS you run cmdeploy: +- chatmail/relay version: `git rev-parse HEAD` ## Expected behavior diff --git a/cmdeploy/src/cmdeploy/__init__.py b/cmdeploy/src/cmdeploy/__init__.py index 1755be04..e0fe2330 100644 --- a/cmdeploy/src/cmdeploy/__init__.py +++ b/cmdeploy/src/cmdeploy/__init__.py @@ -7,6 +7,7 @@ import io import shutil import subprocess import sys +from io import StringIO from pathlib import Path 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", 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) diff --git a/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py b/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py index 6c096677..0ecfd8c4 100644 --- a/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py +++ b/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py @@ -1,5 +1,6 @@ import datetime import smtplib +import subprocess import pytest @@ -191,3 +192,18 @@ def test_expunged(remote, chatmail_config): for cmd in find_cmds: for line in remote.iter_output(cmd): 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."