Files
LangBot/sdk/tests/cli/test_examples.py
0d84c334ba feat(sdk): move the plugin SDK into the monorepo with independent releases (LANG-420) (#2993)
* chore(sdk): import langbot-plugin-sdk v0.7.24 snapshot into sdk/ (LANG-420)

Snapshot of langbot-app/langbot-plugin-sdk at 76443bb8 (tag v0.7.24),
without history. The repository's .github/ workflows are not imported;
they are replaced by sdk-*.yml workflows in the next commit. The root
.gitignore keeps the template .vscode/launch.json.example tracked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>

* feat(sdk): move the plugin SDK into the monorepo with independent releases (LANG-420)

- CI: sdk-tests.yml / sdk-box-docker.yml run the SDK suite from sdk/ in
  its own environment (Python 3.10-3.12); run-tests.yml gains a
  "Core with in-tree SDK" job that overlays sdk/ on Core's venv.
- Releases: sdk-publish.yml publishes langbot-plugin from sdk/vX.Y.Z tag
  pushes and never creates a GitHub Release. Core release workflows now
  only accept v* tags, and scripts/check_sdk_release_pin.py blocks a Core
  PyPI/Docker release whose langbot-plugin pin differs from the released,
  unchanged sdk/.
- Packaging: Core still installs the PyPI pin. Core wheel/sdist, git
  export, Docker context, release ZIP and fnOS package exclude sdk/.
- Generator/tests: generate_plugin_workspace_api.py writes sdk/ directly;
  the SDK's generator drift tests now run instead of skipping.
- Docs: AGENTS/ARCHITECTURE, sdk/ guides (+ RELEASING.md, SOURCE.json),
  agent skills and lbs probes, public docs (zh/en/ja) and dev-docs
  point at sdk/ instead of the sibling langbot-plugin-sdk checkout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
2026-11-11 23:12:53 +08:00

56 lines
1.8 KiB
Python

from __future__ import annotations
import zipfile
from pathlib import Path
import pytest
from langbot_plugin.cli.commands import buildplugin
from langbot_plugin.cli.utils.page_components import discover_plugin_components
from langbot_plugin.utils.packaging import load_plugin_manifest
EXAMPLES_DIR = Path(__file__).resolve().parents[2] / "examples"
EXAMPLE_DIRS = sorted(
[
p
for p in EXAMPLES_DIR.iterdir()
if p.is_dir() and (p / "manifest.yaml").is_file()
],
key=lambda p: p.name,
)
def test_examples_directory_contains_plugins():
assert EXAMPLES_DIR.is_dir(), f"examples directory not found at {EXAMPLES_DIR}"
assert len(EXAMPLE_DIRS) >= 1, f"No example plugins found in {EXAMPLES_DIR}"
@pytest.mark.parametrize("example_dir", EXAMPLE_DIRS, ids=lambda p: p.name)
def test_example_plugin_manifest_discovery(
example_dir: Path, monkeypatch: pytest.MonkeyPatch
):
monkeypatch.chdir(example_dir)
discovery_engine, plugin_manifest = load_plugin_manifest(str(example_dir))
components = discover_plugin_components(plugin_manifest, discovery_engine)
assert len(components) >= 1
@pytest.mark.parametrize("example_dir", EXAMPLE_DIRS, ids=lambda p: p.name)
def test_example_plugin_build(
example_dir: Path, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
):
monkeypatch.chdir(example_dir)
monkeypatch.setattr(buildplugin, "cli_print", lambda *args, **kwargs: None)
dist_dir = tmp_path / "dist"
package_path = buildplugin.build_plugin_process(str(dist_dir))
assert package_path is not None
assert package_path.endswith(".lbpkg")
assert Path(package_path).is_file()
with zipfile.ZipFile(package_path) as package:
names = set(package.namelist())
assert "manifest.yaml" in names
assert "main.py" in names