diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 789cd46..ef05def 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: "3.12" + cache: 'pip' - name: Install uv uses: astral-sh/setup-uv@v4 @@ -25,12 +26,23 @@ jobs: enable-cache: true cache-dependency-glob: "pyproject.toml" + - name: Cache virtual environment + uses: actions/cache@v4 + with: + path: .venv + key: venv-${{ runner.os }}-${{ hashFiles('pyproject.toml') }} + restore-keys: | + venv-${{ runner.os }}- + - name: Create virtual environment run: uv venv - name: Install dependencies run: uv pip install -e ".[dev]" + - name: Prune uv cache for CI + run: uv cache prune --ci + - name: Run ruff (lint and format check) run: | uv run ruff check . diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 535b047..aa2646c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,6 +19,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: "3.12" + cache: 'pip' - name: Install uv uses: astral-sh/setup-uv@v4 @@ -29,6 +30,9 @@ jobs: - name: Build wheel and sdist run: uvx --from build pyproject-build --installer uv + - name: Prune uv cache for CI + run: uv cache prune --ci + - name: Upload release artifacts to GitHub uses: actions/upload-artifact@v4 with: diff --git a/.gitignore b/.gitignore index 8cf487e..fddd15f 100644 --- a/.gitignore +++ b/.gitignore @@ -64,6 +64,3 @@ clusters.yaml artifacts/ # Development artifacts uv.lock -CLEANUP-QUICKSTART.md -README-CLEANUP.md -cleanup-namespaces.sh diff --git a/tests/test_server.py b/tests/test_server.py index e006ac5..6d76ef2 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -4,16 +4,15 @@ import pytest -from mcp_acp.server import ( - _format_bulk_result, - _format_clusters, - _format_logs, - _format_result, - _format_sessions_list, - _format_whoami, - call_tool, - list_tools, +from mcp_acp.formatters import ( + format_bulk_result, + format_clusters, + format_logs, + format_result, + format_sessions_list, + format_whoami, ) +from mcp_acp.server import call_tool, list_tools class TestServerFormatters: @@ -27,7 +26,7 @@ def test_format_result_dry_run(self) -> None: "session_info": {"name": "test-session", "status": "running"}, } - output = _format_result(result) + output = format_result(result) assert "DRY RUN MODE" in output assert "Would delete session" in output @@ -37,7 +36,7 @@ def test_format_result_normal(self) -> None: """Test formatting normal results.""" result = {"deleted": True, "message": "Successfully deleted session"} - output = _format_result(result) + output = format_result(result) assert "Successfully deleted session" in output @@ -66,7 +65,7 @@ def test_format_sessions_list(self) -> None: ], } - output = _format_sessions_list(result) + output = format_sessions_list(result) assert "Found 2 session(s)" in output assert "session-1" in output @@ -87,7 +86,7 @@ def test_format_bulk_result_delete_dry_run(self) -> None: }, } - output = _format_bulk_result(result, "delete") + output = format_bulk_result(result, "delete") assert "DRY RUN MODE" in output assert "Would delete 2 session(s)" in output @@ -103,7 +102,7 @@ def test_format_bulk_result_delete_normal(self) -> None: "failed": [{"session": "session-3", "error": "Not found"}], } - output = _format_bulk_result(result, "delete") + output = format_bulk_result(result, "delete") assert "Successfully deleted 2 session(s)" in output assert "session-1" in output @@ -126,7 +125,7 @@ def test_format_bulk_result_stop_dry_run(self) -> None: }, } - output = _format_bulk_result(result, "stop") + output = format_bulk_result(result, "stop") assert "DRY RUN MODE" in output assert "Would stop 1 session(s)" in output @@ -142,7 +141,7 @@ def test_format_logs(self) -> None: "lines": 3, } - output = _format_logs(result) + output = format_logs(result) assert "container 'runner'" in output assert "3 lines" in output @@ -153,7 +152,7 @@ def test_format_logs_error(self) -> None: """Test formatting logs with error.""" result = {"error": "Pod not found"} - output = _format_logs(result) + output = format_logs(result) assert "Error: Pod not found" in output @@ -179,7 +178,7 @@ def test_format_clusters(self) -> None: "default_cluster": "test-cluster", } - output = _format_clusters(result) + output = format_clusters(result) assert "test-cluster [DEFAULT]" in output assert "prod-cluster" in output @@ -191,7 +190,7 @@ def test_format_clusters_empty(self) -> None: """Test formatting empty clusters list.""" result = {"clusters": [], "default_cluster": None} - output = _format_clusters(result) + output = format_clusters(result) assert "No clusters configured" in output @@ -205,7 +204,7 @@ def test_format_whoami_authenticated(self) -> None: "token_valid": True, } - output = _format_whoami(result) + output = format_whoami(result) assert "Authenticated: Yes" in output assert "User: testuser" in output @@ -223,7 +222,7 @@ def test_format_whoami_not_authenticated(self) -> None: "token_valid": False, } - output = _format_whoami(result) + output = format_whoami(result) assert "Authenticated: No" in output assert "not authenticated" in output