mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 02:54:26 +00:00
3529 invalid comments in 528 files, grandfathered in while the linter only saw the working-tree diff. Removal ran through the linter's own collectors, so detection and deletion cannot drift: a comment whose opener line is blank before it and whose closer line is blank after it loses all its lines, anything else loses only the comment region, and a line left holding a bare delimiter goes with it. Five files keep their comments behind a nocheck marker instead. Four are upstream configs whose inline docs are upstream's own (mautrix, systemd journald, nextcloud-oidc-login, MediaWiki). In littlejs the commented-out entries ARE the deactivation mechanism for an example tile, so deleting them would delete configuration. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
73 lines
2.4 KiB
Python
73 lines
2.4 KiB
Python
import os
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from utils.cache.yaml import load_yaml_str
|
|
from utils.roles.mapping import ROLE_FILE_META_MAIN
|
|
|
|
from . import PROJECT_ROOT
|
|
|
|
|
|
class TestAnsibleRolesMetadata(unittest.TestCase):
|
|
ROOT_DIR = str(PROJECT_ROOT)
|
|
ROLES_DIR = str(PROJECT_ROOT / "roles")
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
all_dirs = os.listdir(cls.ROLES_DIR)
|
|
cls.roles = [
|
|
d
|
|
for d in all_dirs
|
|
if (Path(str(Path(cls.ROLES_DIR) / d)).is_dir() and d != "__pycache__")
|
|
]
|
|
|
|
def test_each_role_has_valid_meta(self):
|
|
"""
|
|
Ensure each Ansible role has a valid meta/main.yml
|
|
with the fields that Sphinx generators expect.
|
|
"""
|
|
for role in self.roles:
|
|
with self.subTest(role=role):
|
|
role_path = str(Path(self.ROLES_DIR) / role)
|
|
meta_file = str(Path(role_path) / ROLE_FILE_META_MAIN)
|
|
self.assertTrue(
|
|
Path(meta_file).exists(),
|
|
msg=f"Missing meta/main.yml in role '{role}'",
|
|
)
|
|
|
|
with Path(meta_file).open(encoding="utf-8") as f:
|
|
raw = f.read()
|
|
meta_data = load_yaml_str(raw) or {}
|
|
|
|
self.assertIsInstance(
|
|
meta_data, dict, msg=f"Meta data for role '{role}' is not a dict"
|
|
)
|
|
|
|
galaxy_info = meta_data.get("galaxy_info") or {}
|
|
self.assertIsInstance(
|
|
galaxy_info,
|
|
dict,
|
|
msg=f"'galaxy_info' missing or not a dict in meta for role '{role}'",
|
|
)
|
|
|
|
self.assertIn(
|
|
"description",
|
|
galaxy_info,
|
|
msg=f"'description' missing in galaxy_info for role '{role}'",
|
|
)
|
|
self.assertTrue(
|
|
galaxy_info["description"],
|
|
msg=f"'description' is empty in galaxy_info for role '{role}'",
|
|
)
|
|
|
|
for key, value in galaxy_info.items():
|
|
self.assertTrue(key, msg=f"Empty galaxy_info key in role '{role}'")
|
|
self.assertIsNotNone(
|
|
value,
|
|
msg=f"None value for galaxy_info['{key}'] in role '{role}'",
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|