From 2bd8e43256059f2bd69639f2e5e135c653b1f124 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Sun, 5 Apr 2026 06:38:40 +0100 Subject: [PATCH] Enhance checks for invalid keyboard build targets (#26122) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: フィルターペーパー <76888457+filterpaper@users.noreply.github.com> --- .github/workflows/lint.yml | 18 +----------- lib/python/qmk/cli/__init__.py | 1 + .../qmk/cli/ci/validate_keyboard_targets.py | 28 +++++++++++++++++++ 3 files changed, 30 insertions(+), 17 deletions(-) create mode 100644 lib/python/qmk/cli/ci/validate_keyboard_targets.py diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 342b8907c6..840f55228e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -89,23 +89,7 @@ jobs: if: always() shell: 'bash {0}' run: | - exit_code=0 - - for file in $(find keyboards/ -name rules.mk | grep -v /keymaps/ | grep -v /common/ | grep -v /lib/); do - dir=$(dirname $file) - - $(find $dir -name keyboard.json -exec false {} +) - if [[ $? == 0 ]]; then - echo "$dir::Legacy target detected" - - ((++exit_code)) - fi - done - - if [[ $exit_code -gt 255 ]]; then - exit 255 - fi - exit $exit_code + qmk ci-validate-keyboard-targets - name: Verify keyboard aliases if: always() diff --git a/lib/python/qmk/cli/__init__.py b/lib/python/qmk/cli/__init__.py index dc2e4726a5..ca816ba0b7 100644 --- a/lib/python/qmk/cli/__init__.py +++ b/lib/python/qmk/cli/__init__.py @@ -56,6 +56,7 @@ safe_commands = [ subcommands = [ 'qmk.cli.ci.validate_aliases', + 'qmk.cli.ci.validate_keyboard_targets', 'qmk.cli.bux', 'qmk.cli.c2json', 'qmk.cli.cd', diff --git a/lib/python/qmk/cli/ci/validate_keyboard_targets.py b/lib/python/qmk/cli/ci/validate_keyboard_targets.py new file mode 100644 index 0000000000..173eb8a8e7 --- /dev/null +++ b/lib/python/qmk/cli/ci/validate_keyboard_targets.py @@ -0,0 +1,28 @@ +"""Validates the list of keyboard targets. +""" +from milc import cli + +from pathlib import Path + + +@cli.subcommand('Validates the list of keyboard targets.', hidden=True) +def ci_validate_keyboard_targets(cli): + errors = set() + + for rules_mk in Path('keyboards').glob('**/rules.mk'): + if any({'keymaps', 'common', 'lib'} & set(rules_mk.parts)): + continue + + folder = rules_mk.parent + if not any(folder.glob('**/keyboard.json')): + errors.add(folder) + + for keymap in Path('keyboards').glob('**/keymaps/'): + folder = keymap.parent + if not any(folder.glob('**/keyboard.json')): + errors.add(folder) + + for error in errors: + print(f"{error}::Legacy target detected") + + exit(min(len(errors), 255))