Skip to content

Commit

Permalink
Add qmk ci-validate-aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
tzarc committed Oct 5, 2023
1 parent 92873cc commit df2c6f2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/python/qmk/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
]

subcommands = [
'qmk.cli.ci.validate_aliases',
'qmk.cli.bux',
'qmk.cli.c2json',
'qmk.cli.cd',
Expand Down
Empty file.
27 changes: 27 additions & 0 deletions lib/python/qmk/cli/ci/validate_aliases.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Validates the list of keyboard aliases.
"""
from pathlib import Path

from milc import cli

from qmk.constants import QMK_FIRMWARE
from qmk.json_schema import json_load
from qmk.keyboard import resolve_keyboard, keyboard_folder


def _safe_keyboard_folder(target):
try:
return keyboard_folder(target)
except Exception:
return None


@cli.subcommand('Validates the list of keyboard aliases.', hidden=True)
def ci_validate_aliases(cli):
aliases = json_load(Path('data/mappings/keyboard_aliases.hjson'))
for alias in aliases.keys():
if alias == 'bm16a':
pass
target = aliases[alias].get('target', None)
if not target or not (QMK_FIRMWARE / 'keyboards' / target).exists() or not resolve_keyboard(target) or not _safe_keyboard_folder(target):
cli.log.error(f'Keyboard alias {alias} has a target that doesn\'t exist: {target}')

0 comments on commit df2c6f2

Please sign in to comment.