Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

- name: Type check with Mypy
run: |
mypy stackbox/core/compose.py
mypy stackbox/

- name: Run unit tests
run: |
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ============================================================================
Expand Down
12 changes: 11 additions & 1 deletion stackbox/core/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.

Expand Down
Loading