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.

74 lines
1.9 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. - name: Disable safe.directory check
  14. run : git config --global --add safe.directory '*'
  15. - uses: actions/checkout@v3
  16. with:
  17. fetch-depth: 0
  18. - name: Install dependencies
  19. run: pip3 install -r requirements-dev.txt
  20. - name: Get changed files
  21. id: file_changes
  22. uses: tj-actions/changed-files@v35
  23. - name: Print info
  24. run: |
  25. git rev-parse --short HEAD
  26. echo ${{ github.event.pull_request.base.sha }}
  27. echo '${{ steps.file_changes.outputs.all_changed_files}}'
  28. - name: Run qmk lint
  29. shell: 'bash {0}'
  30. run: |
  31. QMK_CHANGES=$(echo -e '${{ steps.file_changes.outputs.all_changed_files}}' | sed 's/ /\n/g')
  32. QMK_KEYBOARDS=$(qmk list-keyboards)
  33. exit_code=0
  34. for KB in $QMK_KEYBOARDS; do
  35. KEYBOARD_CHANGES=$(echo "$QMK_CHANGES" | grep -E '^(keyboards/'${KB}'/)')
  36. if [[ -z "$KEYBOARD_CHANGES" ]]; then
  37. # skip as no changes for this keyboard
  38. continue
  39. fi
  40. KEYMAP_ONLY=$(echo "$KEYBOARD_CHANGES" | grep -cv /keymaps/)
  41. if [[ $KEYMAP_ONLY -gt 0 ]]; then
  42. echo "linting ${KB}"
  43. qmk lint --keyboard ${KB} && qmk info -l --keyboard ${KB}
  44. exit_code=$(($exit_code + $?))
  45. fi
  46. done
  47. qmk format-text ${{ steps.file_changes.outputs.all_changed_files}} || true
  48. for file in ${{ steps.file_changes.outputs.all_changed_files}}; do
  49. if ! git diff --quiet $file; then
  50. echo "File '${file}' Requires Formatting"
  51. echo "::error file=${file}::Requires Formatting"
  52. exit_code=$(($exit_code + 1))
  53. fi
  54. done
  55. if [[ $exit_code -gt 255 ]]; then
  56. exit 255
  57. fi
  58. exit $exit_code