4b6817381b
Benchmark image — build + push to ECR (any adapter) / build + push (push) Waiting to run
CI / quality (ubuntu-latest) (push) Waiting to run
CI / test (tools-runtime) (push) Waiting to run
CI / test (e2e-general) (push) Waiting to run
CI / test (cli-runtime) (push) Waiting to run
CI / test (e2e-provider-and-openclaw) (push) Waiting to run
CI / test (integrations-and-misc) (push) Waiting to run
CI / coverage-report (push) Blocked by required conditions
CI / test-kubernetes (push) Waiting to run
CI / should-run-thorough (push) Waiting to run
CI / test-thorough (cloudwatch-demo) (push) Blocked by required conditions
CI / test-thorough (flink-ecs) (push) Blocked by required conditions
CI / test-thorough (upstream-lambda) (push) Blocked by required conditions
CI / test-thorough (prefect-ecs-fargate) (push) Blocked by required conditions
CodeQL / Analyze (python) (push) Waiting to run
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Blocked by required conditions
Release / publish-release (push) Blocked by required conditions
Release / publish-main-release (push) Blocked by required conditions
Release / prepare (push) Waiting to run
Release / verify (push) Blocked by required conditions
Release / build-python-dist (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Blocked by required conditions
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Waiting to run
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Waiting to run
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Waiting to run
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
68 lines
2.3 KiB
Python
68 lines
2.3 KiB
Python
"""Architecture guards for external-system package boundaries."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import ast
|
|
import subprocess
|
|
import tomllib
|
|
from pathlib import Path
|
|
|
|
from config.constants.paths import REPO_ROOT
|
|
|
|
ROOT = REPO_ROOT
|
|
FORBIDDEN_TOP_LEVEL_PACKAGES = frozenset({"services", "vendors"})
|
|
|
|
|
|
def _tracked_files(*pathspecs: str) -> list[Path]:
|
|
result = subprocess.run(
|
|
["git", "ls-files", "--", *pathspecs],
|
|
cwd=ROOT,
|
|
check=True,
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
return [path for line in result.stdout.splitlines() if (path := ROOT / line).exists()]
|
|
|
|
|
|
def _forbidden_imports(path: Path) -> set[str]:
|
|
tree = ast.parse(path.read_text(encoding="utf-8"), filename=str(path))
|
|
imports: set[str] = set()
|
|
for node in ast.walk(tree):
|
|
if isinstance(node, ast.Import):
|
|
imports.update(alias.name for alias in node.names)
|
|
elif isinstance(node, ast.ImportFrom) and node.level == 0 and node.module:
|
|
imports.add(node.module)
|
|
return {module for module in imports if module.split(".", 1)[0] in FORBIDDEN_TOP_LEVEL_PACKAGES}
|
|
|
|
|
|
def test_no_tracked_python_imports_from_removed_external_packages() -> None:
|
|
leaks = {
|
|
str(path.relative_to(ROOT)): sorted(_forbidden_imports(path))
|
|
for path in _tracked_files("*.py")
|
|
if _forbidden_imports(path)
|
|
}
|
|
assert leaks == {}
|
|
|
|
|
|
def test_removed_external_packages_have_no_tracked_files() -> None:
|
|
assert _tracked_files("services", "services/**", "vendors", "vendors/**") == []
|
|
|
|
|
|
def test_tools_registry_does_not_scan_removed_external_packages() -> None:
|
|
registry_source = (ROOT / "tools/registry.py").read_text(encoding="utf-8")
|
|
assert '"vendors"' not in registry_source
|
|
assert '"services"' not in registry_source
|
|
assert "'vendors'" not in registry_source
|
|
assert "'services'" not in registry_source
|
|
|
|
|
|
def test_pyproject_does_not_package_removed_external_packages() -> None:
|
|
pyproject = tomllib.loads((ROOT / "pyproject.toml").read_text(encoding="utf-8"))
|
|
package_includes = set(pyproject["tool"]["setuptools"]["packages"]["find"]["include"])
|
|
vulture_paths = set(pyproject["tool"]["vulture"]["paths"])
|
|
|
|
assert "services*" not in package_includes
|
|
assert "vendors*" not in package_includes
|
|
assert "services" not in vulture_paths
|
|
assert "vendors" not in vulture_paths
|