DEVX-144: fix: bake promtool into ci-full image, add download timeout, speed up tests
Post-merge / release-and-maintain (push) Waiting to run
Post-merge / detect-and-configure (push) Waiting to run

This commit was merged in pull request #226.
This commit is contained in:
2026-07-17 02:10:17 +00:00
parent c7351a495a
commit d743ba93eb
4 changed files with 24 additions and 10 deletions
+3 -2
View File
@@ -20,5 +20,6 @@ COPY . /tmp/devx
RUN pip install --no-cache-dir /tmp/devx[release,molecule,deploy] \ RUN pip install --no-cache-dir /tmp/devx[release,molecule,deploy] \
&& rm -rf /tmp/devx && rm -rf /tmp/devx
# Install git-cliff (changelog generator for release job) and OpenTofu (for infra deploy jobs) # Install git-cliff (changelog generator for release job), OpenTofu (for infra deploy jobs),
RUN python3 -m devx.tools.install_tools --tool git-cliff --tool tofu # and promtool (Prometheus rule validator — used by every infra CI run for alert validation)
RUN python3 -m devx.tools.install_tools --tool git-cliff --tool tofu --tool promtool
+1 -1
View File
@@ -309,7 +309,7 @@ devx-lint: devx-lint-ruff devx-lint-format devx-typecheck devx-lint-bandit devx-
# ── Testing ─────────────────────────────────────────────────────────────────── # ── Testing ───────────────────────────────────────────────────────────────────
devx-test-unit: devx-test-unit:
@$(DEVX_BIN)/pytest $(DEVX_TEST_PATHS) -q --no-cov @$(DEVX_BIN)/pytest $(DEVX_TEST_PATHS) -q --no-cov -n 8
devx-pytest-cov: devx-pytest-cov:
@$(DEVX_BIN)/pytest $(DEVX_TEST_PATHS) -n auto --cov=$(DEVX_COV_PKG) --cov-report=term-missing --cov-fail-under=100 @$(DEVX_BIN)/pytest $(DEVX_TEST_PATHS) -n auto --cov=$(DEVX_COV_PKG) --cov-report=term-missing --cov-fail-under=100
+3 -2
View File
@@ -65,8 +65,9 @@ def _ensure_target_dir() -> Path:
def _download(url: str, dest: Path) -> None: def _download(url: str, dest: Path) -> None:
"""Download a file from ``url`` to ``dest``.""" """Download a file from ``url`` to ``dest`` with a 60s timeout."""
urllib.request.urlretrieve(url, dest) # nosec B310 with urllib.request.urlopen(url, timeout=60) as resp, open(dest, "wb") as f: # nosec B310
shutil.copyfileobj(resp, f)
def _download_and_extract_tarball(url: str, binary_name: str) -> Path: def _download_and_extract_tarball(url: str, binary_name: str) -> Path:
+17 -5
View File
@@ -47,13 +47,25 @@ class TestDownload:
def test_download(self, tmp_path: Path) -> None: def test_download(self, tmp_path: Path) -> None:
dest = tmp_path / "file.bin" dest = tmp_path / "file.bin"
def _write_file(url: str, path: Path) -> tuple[str, None]: class _FakeResponse:
Path(path).write_bytes(b"data") def __init__(self) -> None:
return str(path), None self._sent = False
with patch("urllib.request.urlretrieve", side_effect=_write_file) as mock_retrieve: def __enter__(self) -> _FakeResponse:
return self
def __exit__(self, *args: object) -> None:
pass
def read(self, n: int = -1) -> bytes:
if self._sent:
return b""
self._sent = True
return b"data"
with patch("urllib.request.urlopen", return_value=_FakeResponse()) as mock_urlopen:
install_tools._download("https://example.com/file", dest) install_tools._download("https://example.com/file", dest)
mock_retrieve.assert_called_once() mock_urlopen.assert_called_once()
assert dest.read_bytes() == b"data" assert dest.read_bytes() == b"data"