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>
59 lines
2.0 KiB
Python
59 lines
2.0 KiB
Python
import os
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
import yaml
|
|
|
|
from utils.cache.yaml import load_yaml_any
|
|
from utils.roles.mapping import ROLE_FILE_META_SERVICES
|
|
|
|
|
|
class TestBackupsEnabledIntegrity(unittest.TestCase):
|
|
def setUp(self):
|
|
self.roles_dir = str(
|
|
Path(str(Path(str(Path(__file__).parent)) / "../../../../roles")).resolve()
|
|
)
|
|
|
|
def test_backups_enabled_image_consistency(self):
|
|
"""
|
|
Ensure that if `backups.enabled` is set for any services[*]:
|
|
- it's a boolean value
|
|
- the containing service dict has an `image` entry at the same level
|
|
"""
|
|
for role in os.listdir(self.roles_dir):
|
|
docker_config_path = str(
|
|
Path(self.roles_dir) / role / ROLE_FILE_META_SERVICES
|
|
)
|
|
if not Path(docker_config_path).is_file():
|
|
continue
|
|
|
|
try:
|
|
config = load_yaml_any(docker_config_path) or {}
|
|
except yaml.YAMLError as e:
|
|
self.fail(f"YAML parsing failed for {docker_config_path}: {e}")
|
|
continue
|
|
|
|
services = config if isinstance(config, dict) else {}
|
|
|
|
for service_key, service in services.items():
|
|
if not isinstance(service, dict):
|
|
continue
|
|
|
|
backups_cfg = service.get("backups", {}) or {}
|
|
if "enabled" in backups_cfg:
|
|
with self.subTest(role=role, service=service_key):
|
|
self.assertIsInstance(
|
|
backups_cfg["enabled"],
|
|
bool,
|
|
f"`backups.enabled` in role '{role}', service '{service_key}' must be a boolean.",
|
|
)
|
|
self.assertIn(
|
|
"image",
|
|
service,
|
|
f"`image` is required in role '{role}', service '{service_key}' when `backups.enabled` is defined.",
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|