fix(ci): stabilize and speed up CI (#5145)

This commit is contained in:
chengyongru
2026-07-28 22:55:59 +08:00
committed by GitHub
parent 9070d7489a
commit 393d429e0a
9 changed files with 328 additions and 26 deletions
+63 -2
View File
@@ -5,8 +5,69 @@ from __future__ import annotations
import sys
from collections.abc import Sequence
from nanobot.channels.plugin import ChannelPlugin
from nanobot.channels.registry import discover_plugins
from nanobot.optional_features import ensure_enabled_channel_dependencies
from nanobot.optional_features import (
ensure_enabled_channel_dependencies,
extra_installed,
install_args_for_extra,
install_extra,
)
_DEPENDENCY_FAILURE = "Channel dependencies could not be installed. Check gateway logs."
def ensure_repository_channel_dependencies(
names: set[str],
plugins: dict[str, ChannelPlugin],
) -> dict[str, str]:
"""Batch repository dependency installs, then verify every channel independently."""
requirements_by_name: dict[str, list[str]] = {}
pending: dict[str, list[str]] = {}
install_args: list[str] = []
seen_args: set[str] = set()
for name in sorted(names):
plugin = plugins.get(name)
if plugin is None:
continue
dependencies = list(plugin.dependencies)
if not dependencies:
continue
requirements_by_name[name] = dependencies
if extra_installed(name, dependencies):
continue
pending[name] = dependencies
channel_args, _label = install_args_for_extra(name, dependencies)
for requirement in channel_args:
if requirement not in seen_args:
seen_args.add(requirement)
install_args.append(requirement)
if not pending:
return {}
if install_args:
result = install_extra("channel-dependencies", install_args)
if result.ok:
unresolved = {
name
for name, dependencies in requirements_by_name.items()
if not extra_installed(name, dependencies)
}
else:
unresolved = set(requirements_by_name)
else:
unresolved = set(requirements_by_name)
if not unresolved:
return {}
failures = ensure_enabled_channel_dependencies(unresolved, plugins)
for name, dependencies in requirements_by_name.items():
if name not in failures and not extra_installed(name, dependencies):
failures[name] = _DEPENDENCY_FAILURE
return failures
def main(argv: Sequence[str] | None = None) -> int:
@@ -26,7 +87,7 @@ def main(argv: Sequence[str] | None = None) -> int:
print(f"Unknown channels: {', '.join(unknown)}", file=sys.stderr)
return 2
failures = ensure_enabled_channel_dependencies(names, plugins)
failures = ensure_repository_channel_dependencies(names, plugins)
for name, message in sorted(failures.items()):
print(f"{name}: {message}", file=sys.stderr)
return 1 if failures else 0