You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.8 KiB

  1. name: PR Lint keyboards
  2. permissions:
  3. contents: read
  4. on:
  5. pull_request:
  6. paths:
  7. - 'keyboards/**'
  8. jobs:
  9. lint:
  10. runs-on: ubuntu-latest
  11. container: qmkfm/qmk_cli
  12. steps:
  13. - uses: actions/checkout@v3
  14. with:
  15. fetch-depth: 0
  16. - name: Install dependencies
  17. run: pip3 install -r requirements-dev.txt
  18. - name: Get changed files
  19. id: file_changes
  20. uses: tj-actions/changed-files@v35
  21. - name: Print info
  22. run: |
  23. git rev-parse --short HEAD
  24. echo ${{ github.event.pull_request.base.sha }}
  25. echo '${{ steps.file_changes.outputs.all_changed_files}}'
  26. - name: Run qmk lint
  27. shell: 'bash {0}'
  28. run: |
  29. QMK_CHANGES=$(echo -e '${{ steps.file_changes.outputs.all_changed_files}}' | sed 's/ /\n/g')
  30. QMK_KEYBOARDS=$(qmk list-keyboards)
  31. exit_code=0
  32. for KB in $QMK_KEYBOARDS; do
  33. KEYBOARD_CHANGES=$(echo "$QMK_CHANGES" | grep -E '^(keyboards/'${KB}'/)')
  34. if [[ -z "$KEYBOARD_CHANGES" ]]; then
  35. # skip as no changes for this keyboard
  36. continue
  37. fi
  38. KEYMAP_ONLY=$(echo "$KEYBOARD_CHANGES" | grep -cv /keymaps/)
  39. if [[ $KEYMAP_ONLY -gt 0 ]]; then
  40. echo "linting ${KB}"
  41. qmk lint --keyboard ${KB} && qmk info -l --keyboard ${KB}
  42. exit_code=$(($exit_code + $?))
  43. fi
  44. done
  45. qmk format-text ${{ steps.file_changes.outputs.all_changed_files}} || true
  46. for file in ${{ steps.file_changes.outputs.all_changed_files}}; do
  47. if ! git diff --quiet $file; then
  48. echo "File '${file}' Requires Formatting"
  49. echo "::error file=${file}::Requires Formatting"
  50. exit_code=$(($exit_code + 1))
  51. fi
  52. done
  53. if [[ $exit_code -gt 255 ]]; then
  54. exit 255
  55. fi
  56. exit $exit_code