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
18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ py-modules = []
[project.optional-dependencies]
dev = [
# Pinned past v0.1.0 to a specific commit (not a new tag -- this repo's
# own CHANGELOG: no routine version bumps pre-1.0). f44873fc is plugin-sdk
# #50 (tool effect classes): the AI_TOOLS `effect`, `idempotent`,
# per-argument `sensitivity` and `hosts` fields, which `minder-plugin
# validate` checks (errors on invalid values, warnings on a missing or
# contradicted effect). It builds on plugin-sdk #43 (platform context,
# contract v2: self.ctx / bind_context, the CONTRACT_VERSION / MANAGES /
# EGRESS / TIMESERIES declarations, FakePlatformContext) and still carries
# the package-style plugin validate/inspect fix `network` needs (#26).
"minder-plugin-sdk @ git+https://github.com/minderhq/plugin-sdk@f44873fcada50f17cc38d26089837d4d1a6227ec",
# own CHANGELOG: no routine version bumps pre-1.0). 0919ce8c is plugin-sdk
# #52 (manifest schemas): the declarative connector schema
# tests/test_manifest_schemas.py checks every manifest.yml against, and
# the full manifest-plugin trigger/action set. It builds on #50 (tool
# effect classes: AI_TOOLS `effect`, `idempotent`, `sensitivity`, `hosts`,
# checked by `minder-plugin validate`), #43 (platform context, contract
# v2) and the package-style plugin validate/inspect fix `network` needs
# (#26). The jsonschema/yaml extras give full schema validation.
"minder-plugin-sdk[jsonschema,yaml] @ git+https://github.com/minderhq/plugin-sdk@0919ce8ca4a01934bbcabe3cddf000b00d60b5e9",
"httpx>=0.27",
"defusedxml>=0.7",
"pytest>=8",
Expand Down
46 changes: 46 additions & 0 deletions tests/test_manifest_schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""Every plugin manifest in the catalog validates against the plugin SDK's
schema: a declarative connector (``spec.runtime.kind: declarative``) against
the declarative connector schema, any other manifest against the manifest
plugin schema. This is what ``minder-plugin validate`` checks, and Minder
validates against the same schemas.

Files without ``apiVersion`` (e.g. telegraf's bundle-claim ``manifest.yml``)
are not plugin manifests and are skipped.
"""

from pathlib import Path

import pytest
import yaml
from minder_plugin_sdk import validate_manifest

ROOT = Path(__file__).resolve().parent.parent


def _load(path: Path):
return yaml.safe_load(path.read_text(encoding="utf-8"))


MANIFESTS = sorted(
p
for p in ROOT.glob("*/manifest.*")
if p.suffix in (".yml", ".yaml", ".json")
and isinstance(_load(p), dict)
and "apiVersion" in _load(p)
)


def test_the_catalog_has_declarative_manifests():
names = {p.parent.name for p in MANIFESTS}
assert {"arxiv", "frankfurter", "openlibrary", "wikipedia"} <= names


@pytest.mark.parametrize("path", MANIFESTS, ids=lambda p: p.parent.name)
def test_manifest_matches_the_sdk_schema(path):
validate_manifest(_load(path)) # raises ManifestError with every problem


@pytest.mark.parametrize("path", MANIFESTS, ids=lambda p: p.parent.name)
def test_manifest_name_matches_its_directory(path):
# Minder's runner refuses a manifest that names another directory.
assert _load(path)["metadata"]["name"] == path.parent.name
Loading