From c393021f0e82761756d72ae70b249f001655e8ba Mon Sep 17 00:00:00 2001 From: Abhishek Bongale Date: Tue, 19 May 2026 15:27:33 +0100 Subject: [PATCH] Fixes: Github Actions and mypy bugs. - fixed docker compose --version command that has been depricated in the ci and pre-commit.yml - fixed mypy found type error in the compose.py - Fixed no tests still CI fails. Fixes: #28 Signed-off-by: Abhishek Bongale --- .github/workflows/ci.yml | 4 ++-- .github/workflows/pre-commit.yml | 2 +- pyproject.toml | 21 +++++++++++++++++++++ stackbox/core/compose.py | 12 +++++++++++- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce26c92..cbb1b51 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,7 @@ jobs: - name: Type check with Mypy run: | - mypy stackbox/core/compose.py + mypy stackbox/ - name: Run unit tests run: | @@ -84,7 +84,7 @@ jobs: - name: Check Docker is running run: | docker --version - docker-compose --version + docker compose version docker ps - name: Run integration tests diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 7b1cf09..63ba05c 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -39,7 +39,7 @@ jobs: - name: Mypy - Type Checking run: | echo "::group::Mypy Type Checking" - mypy stackbox/core/compose.py + mypy stackbox/ echo "::endgroup::" - name: Comment on PR if checks fail diff --git a/pyproject.toml b/pyproject.toml index 60028f3..b8e098d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -113,6 +113,27 @@ norecursedirs = [ ".venv", ] +# ============================================================================ +# Coverage.py - Code Coverage +# ============================================================================ +[tool.coverage.run] +source = ["stackbox"] +omit = [ + "stackbox/cli/*", # Stub commands - no implementation yet (Issue #3) + "stackbox/jobs/*", # Not yet implemented +] + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "def __repr__", + "if __name__ == .__main__.:", + "raise AssertionError", + "raise NotImplementedError", + "if TYPE_CHECKING:", + "@abstractmethod", +] + # ============================================================================ # Tool Configurations # ============================================================================ diff --git a/stackbox/core/compose.py b/stackbox/core/compose.py index b3411aa..25de69b 100644 --- a/stackbox/core/compose.py +++ b/stackbox/core/compose.py @@ -3,11 +3,21 @@ import contextlib from pathlib import Path import subprocess +from typing import TypedDict from jinja2 import Template import yaml +class ValidationResult(TypedDict): + """Result from validate_environment().""" + + docker_running: bool + ports_available: bool + unavailable_ports: list[int] + kvm_available: bool + + def generate_compose_file(output_path: Path, config: dict[str, str] | None = None) -> Path: """ Generate docker-compose.yml from Jinja2 template. @@ -109,7 +119,7 @@ def _check_kvm_available() -> bool: return kvm_device.exists() and kvm_device.is_char_device() -def validate_environment() -> dict[str, bool | list[int]]: +def validate_environment() -> ValidationResult: """ Run pre-flight checks for infrastructure requirements.