Skip to content

Self-improving AI Employees for everyone

fix(ci): read the test CLI's version through a public installer helper

trohitg449bfb6c360c
diff --git a/.github/workflows/predeploy.yml b/.github/workflows/predeploy.yml
index cc3d60ea..8d630b69 100644
--- a/.github/workflows/predeploy.yml
+++ b/.github/workflows/predeploy.yml
@@ -95,7 +95,7 @@ jobs:
working-directory: server
shell: bash
run: |
- uv run python -c "import os; from pathlib import Path; from services.temporal._install import cli_pin, _binary_versions; cli = Path(os.environ['TEMPORAL_TEST_CLI']); assert cli.is_file(); assert _binary_versions(cli)['cli_version'] == cli_pin()['version']"
+ uv run python -c "import os; from pathlib import Path; from services.temporal._install import cli_pin, binary_versions; cli = Path(os.environ['TEMPORAL_TEST_CLI']); assert cli.is_file(); assert binary_versions(cli)['cli_version'] == cli_pin()['version']"
uv run pytest tests/temporal/test_replay_corpus.py tests/temporal/test_workflow_identity_golden.py tests/temporal/test_run_graph_replay.py -v -p no:cacheprovider
- name: pytest
working-directory: server
diff --git a/server/services/temporal/_install.py b/server/services/temporal/_install.py
index 7691af20..0d6f4593 100644
--- a/server/services/temporal/_install.py
+++ b/server/services/temporal/_install.py
@@ -32,6 +32,7 @@ import platform
import re
import shutil
import stat
+import subprocess
from datetime import datetime, timezone
from pathlib import Path
from typing import Any
@@ -86,6 +87,15 @@ def binary_installed() -> bool:
return root.is_dir() and any(p.is_file() for p in root.rglob(_binary_name()))
+def binary_versions(binary: Path) -> dict[str, str]:
+ """The CLI and server versions a ``temporal`` binary reports (CI checks its test CLI with it)."""
+ output = subprocess.run([str(binary), "--version"], capture_output=True, text=True, check=True, timeout=15).stdout
+ match = re.search(r"(?:temporal CLI|temporal version)\s+(\d+\.\d+\.\d+)\s+\(Server\s+(\d+\.\d+\.\d+)", output, re.I)
+ if match is None:
+ raise RuntimeError(f"Cannot read the Temporal CLI and server versions of {binary}: {output.strip()!r}")
+ return {"cli_version": match[1], "server_version": match[2]}
+
+
_cached: dict[str, Path] | None = None
_lock = asyncio.Lock()
@@ -238,7 +248,7 @@ def _server_minor(version: object) -> str | None:
return ".".join(version.split(".")[:2]) if re.fullmatch(r"\d+\.\d+\.\d+", version) else None
-__all__ = ["binary_installed", "cli_pin", "ensure_temporal_binaries", "marker_path", "prepare_database"]
+__all__ = ["binary_installed", "binary_versions", "cli_pin", "ensure_temporal_binaries", "marker_path", "prepare_database"]
def _main() -> int:
diff --git a/server/tests/temporal/test_cli_pin.py b/server/tests/temporal/test_cli_pin.py
index bbdcb217..9b0fec4d 100644
--- a/server/tests/temporal/test_cli_pin.py
+++ b/server/tests/temporal/test_cli_pin.py
@@ -15,6 +15,8 @@ import re
from pathlib import Path
from types import SimpleNamespace
+import pytest
+
from services.temporal import _install, _runtime
@@ -136,6 +138,20 @@ def test_fetch_verifies_the_pinned_archive_into_its_versioned_folder(tmp_path, m
assert binary == tmp_path / pin["version"] / f"{asset['file']}.untar" / "temporal"
+def test_binary_versions_reads_the_cli_and_server_it_reports(monkeypatch):
+ outputs = iter(["temporal version 1.9.1 (Server 1.32.0, UI 2.54.1)\n", "unexpected\n"])
+
+ def fake_run(argv, **kwargs):
+ assert argv[1:] == ["--version"]
+ return SimpleNamespace(stdout=next(outputs))
+
+ monkeypatch.setattr(_install.subprocess, "run", fake_run)
+
+ assert _install.binary_versions(Path("temporal")) == {"cli_version": "1.9.1", "server_version": "1.32.0"}
+ with pytest.raises(RuntimeError, match="Cannot read"):
+ _install.binary_versions(Path("temporal"))
+
+
def test_only_the_pinned_cli_counts_as_installed(tmp_path, monkeypatch):
monkeypatch.setattr(_install, "_cache_dir", lambda: tmp_path)
unpinned = tmp_path / "temporal_cli_latest_windows_amd64.zip.unzip"