diff options
| author | Nick Brassel | 2025-09-06 09:55:23 +0200 |
|---|---|---|
| committer | Nick Brassel | 2025-09-06 09:55:23 +0200 |
| commit | 0188038bc0cfecdd6d413086634af4e5806c1ad7 (patch) | |
| tree | 03bdd000530476ef4fc9e1242d62022405df21e7 /lib/python/qmk/cli/ci | |
| parent | 1a58fce043e7f2e2b938dee03945dabc29e48d73 (diff) | |
| parent | 2a4b9f79fd32a41fd157cba83293ece995523b45 (diff) | |
Merge branch 'develop'
Diffstat (limited to 'lib/python/qmk/cli/ci')
| -rw-r--r-- | lib/python/qmk/cli/ci/validate_aliases.py | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/lib/python/qmk/cli/ci/validate_aliases.py b/lib/python/qmk/cli/ci/validate_aliases.py index 7f781d4397..4f2fe6c941 100644 --- a/lib/python/qmk/cli/ci/validate_aliases.py +++ b/lib/python/qmk/cli/ci/validate_aliases.py @@ -2,7 +2,7 @@ """ from milc import cli -from qmk.keyboard import resolve_keyboard, keyboard_folder, keyboard_alias_definitions +from qmk.keyboard import keyboard_folder, keyboard_alias_definitions def _safe_keyboard_folder(target): @@ -17,10 +17,6 @@ def _target_keyboard_exists(target): if not target: return False - # If the target directory existed but there was no rules.mk or rules.mk was incorrectly parsed, then we can't build it. - if not resolve_keyboard(target): - return False - # If the target directory exists but it itself has an invalid alias or invalid rules.mk, then we can't build it either. if not _safe_keyboard_folder(target): return False @@ -29,6 +25,21 @@ def _target_keyboard_exists(target): return True +def _alias_not_self(alias): + """Check if alias points to itself, either directly or within a circular reference + """ + aliases = keyboard_alias_definitions() + + found = set() + while alias in aliases: + found.add(alias) + alias = aliases[alias].get('target', alias) + if alias in found: + return False + + return True + + @cli.subcommand('Validates the list of keyboard aliases.', hidden=True) def ci_validate_aliases(cli): aliases = keyboard_alias_definitions() @@ -36,7 +47,11 @@ def ci_validate_aliases(cli): success = True for alias in aliases.keys(): target = aliases[alias].get('target', None) - if not _target_keyboard_exists(target): + if not _alias_not_self(alias): + cli.log.error(f'Keyboard alias {alias} should not point to itself') + success = False + + elif not _target_keyboard_exists(target): cli.log.error(f'Keyboard alias {alias} has a target that doesn\'t exist: {target}') success = False |