From 4d33d72975f2d63c7b6ff6fd4aa7e0f4c4347583 Mon Sep 17 00:00:00 2001 From: Zach White Date: Sat, 7 Nov 2020 09:56:08 -0800 Subject: New command: qmk lint (#10761) * Basic qmk lint command * check for keymap readme * change the workflow from qmk info to qmk lint * add a strict mode * parsing -> parse * document qmk lint * small info logging cleanup * Apply suggestions from code review Co-authored-by: Ryan * honor --strict in more places * change the job name to lint Co-authored-by: Ryan --- .github/workflows/info.yml | 54 ---------------------------------------------- .github/workflows/lint.yml | 51 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 54 deletions(-) delete mode 100644 .github/workflows/info.yml create mode 100644 .github/workflows/lint.yml (limited to '.github') diff --git a/.github/workflows/info.yml b/.github/workflows/info.yml deleted file mode 100644 index bb3a508477..0000000000 --- a/.github/workflows/info.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: PR Lint keyboards - -on: - pull_request: - paths: - - 'keyboards/**' - -jobs: - info: - runs-on: ubuntu-latest - - container: qmkfm/base_container - - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - uses: trilom/file-changes-action@v1.2.4 - id: file_changes - with: - output: '\n' - - - name: Print info - run: | - git rev-parse --short HEAD - echo ${{ github.event.pull_request.base.sha }} - echo '${{ steps.file_changes.outputs.files}}' - - - name: Run qmk info - shell: 'bash {0}' - run: | - QMK_CHANGES=$(echo -e '${{ steps.file_changes.outputs.files}}') - QMK_KEYBOARDS=$(qmk list-keyboards) - - exit_code=0 - for KB in $QMK_KEYBOARDS; do - KEYBOARD_CHANGES=$(echo "$QMK_CHANGES" | grep -E '^(keyboards/'${KB}'/)') - if [[ -z "$KEYBOARD_CHANGES" ]]; then - # skip as no changes for this keyboard - continue - fi - - KEYMAP_ONLY=$(echo "$KEYBOARD_CHANGES" | grep -cv /keymaps/) - if [[ $KEYMAP_ONLY -gt 0 ]]; then - echo "linting ${KB}" - - # TODO: info info always returns 0 - right now the only way to know failure is to inspect log lines - qmk info -l -kb ${KB} 2>&1 | tee /tmp/$$ - !(grep -cq ☒ /tmp/$$) - : $((exit_code = $exit_code + $?)) - fi - done - exit $exit_code diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000000..1aa347a1b2 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,51 @@ +name: PR Lint keyboards + +on: + pull_request: + paths: + - 'keyboards/**' + +jobs: + lint: + runs-on: ubuntu-latest + + container: qmkfm/base_container + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - uses: trilom/file-changes-action@v1.2.4 + id: file_changes + with: + output: '\n' + + - name: Print info + run: | + git rev-parse --short HEAD + echo ${{ github.event.pull_request.base.sha }} + echo '${{ steps.file_changes.outputs.files}}' + + - name: Run qmk lint + shell: 'bash {0}' + run: | + QMK_CHANGES=$(echo -e '${{ steps.file_changes.outputs.files}}') + QMK_KEYBOARDS=$(qmk list-keyboards) + + exit_code=0 + for KB in $QMK_KEYBOARDS; do + KEYBOARD_CHANGES=$(echo "$QMK_CHANGES" | grep -E '^(keyboards/'${KB}'/)') + if [[ -z "$KEYBOARD_CHANGES" ]]; then + # skip as no changes for this keyboard + continue + fi + + KEYMAP_ONLY=$(echo "$KEYBOARD_CHANGES" | grep -cv /keymaps/) + if [[ $KEYMAP_ONLY -gt 0 ]]; then + echo "linting ${KB}" + + qmk lint --keyboard ${KB} + fi + done + exit $exit_code -- cgit v1.2.3