Files
cleveragents-core/robot/helper_action_schema.py
aditya 8da7bd1e56
CI / lint (pull_request) Successful in 16s
CI / typecheck (pull_request) Successful in 26s
CI / security (pull_request) Successful in 22s
CI / quality (pull_request) Successful in 16s
CI / integration_tests (pull_request) Successful in 4m17s
CI / build (pull_request) Successful in 16s
CI / unit_tests (pull_request) Successful in 7m45s
CI / docker (pull_request) Successful in 44s
CI / coverage (pull_request) Successful in 5m38s
docs(action): add action YAML schema and examples
2026-02-13 19:01:55 +05:30

57 lines
1.6 KiB
Python

"""Robot Framework helper for action YAML schema validation.
Provides a CLI-style interface for Robot to invoke schema validation
on action YAML files. Exit code 0 = success, 1 = failure.
Usage:
python robot/helper_action_schema.py validate <yaml_file>
python robot/helper_action_schema.py validate-invalid <yaml_file>
"""
from __future__ import annotations
import sys
from pathlib import Path
# Ensure the src directory is on the import path.
_SRC = str(Path(__file__).resolve().parents[1] / "src")
if _SRC not in sys.path:
sys.path.insert(0, _SRC)
from cleveragents.action.schema import ActionConfigSchema # noqa: E402
def main() -> int:
"""Entry point called by Robot Framework ``Run Process``."""
if len(sys.argv) < 3:
print("Usage: helper_action_schema.py <validate|validate-invalid> <file>")
return 1
command = sys.argv[1]
yaml_path = sys.argv[2]
if command == "validate":
try:
config = ActionConfigSchema.from_yaml_file(yaml_path)
print(f"action-schema-ok: {config.name}")
return 0
except Exception as exc:
print(f"action-schema-fail: {exc}")
return 1
if command == "validate-invalid":
try:
ActionConfigSchema.from_yaml_file(yaml_path)
print("action-schema-unexpected-success")
return 1
except Exception as exc:
print(f"action-schema-expected-fail: {exc}")
return 0
print(f"Unknown command: {command}")
return 1
if __name__ == "__main__":
sys.exit(main())