import os

try:
    import yaml

    _HAS_YAML = True
except Exception:
    _HAS_YAML = False


def test_mindmodel_workflow_exists_and_parses():
    path = os.path.join(".github", "workflows", "mindmodel-validation.yml")
    assert os.path.exists(path), f"Workflow file {path} does not exist"

    # Minimal parse: if PyYAML is available, try safe_load; otherwise do a token check
    with open(path, "r", encoding="utf-8") as f:
        content = f.read()

    if _HAS_YAML:
        data = yaml.safe_load(content)
        assert data is not None and isinstance(data, dict)
        assert "on" in data or "name" in data
    else:
        # fall back to simple checks to avoid introducing new deps
        assert "name:" in content
        assert "on:" in content
