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.

87 lines
2.2 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: ghcr.io/qmk/qmk_cli
  12. steps:
  13. - name: Disable safe.directory check
  14. run : git config --global --add safe.directory '*'
  15. - uses: actions/checkout@v4
  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@v42
  23. with:
  24. use_rest_api: true
  25. - name: Print info
  26. run: |
  27. git rev-parse --short HEAD
  28. echo ${{ github.event.pull_request.base.sha }}
  29. echo '${{ steps.file_changes.outputs.all_changed_files}}'
  30. - name: Run qmk lint
  31. if: always()
  32. shell: 'bash {0}'
  33. run: |
  34. QMK_CHANGES=$(echo -e '${{ steps.file_changes.outputs.all_changed_files}}' | sed 's/ /\n/g')
  35. QMK_KEYBOARDS=$(qmk list-keyboards)
  36. exit_code=0
  37. for KB in $QMK_KEYBOARDS; do
  38. KEYBOARD_CHANGES=$(echo "$QMK_CHANGES" | grep -E '^(keyboards/'${KB}'/)')
  39. if [[ -z "$KEYBOARD_CHANGES" ]]; then
  40. # skip as no changes for this keyboard
  41. continue
  42. fi
  43. KEYMAP_ONLY=$(echo "$KEYBOARD_CHANGES" | grep -cv /keymaps/)
  44. if [[ $KEYMAP_ONLY -gt 0 ]]; then
  45. echo "linting ${KB}"
  46. qmk lint --keyboard ${KB} && qmk info -l --keyboard ${KB}
  47. exit_code=$(($exit_code + $?))
  48. fi
  49. done
  50. qmk format-text ${{ steps.file_changes.outputs.all_changed_files}} || true
  51. for file in ${{ steps.file_changes.outputs.all_changed_files}}; do
  52. if [[ -f $file ]]; then
  53. if ! git diff --quiet $file; then
  54. echo "File '${file}' Requires Formatting"
  55. echo "::error file=${file}::Requires Formatting"
  56. exit_code=$(($exit_code + 1))
  57. fi
  58. fi
  59. done
  60. if [[ $exit_code -gt 255 ]]; then
  61. exit 255
  62. fi
  63. exit $exit_code
  64. - name: Verify keyboard aliases
  65. if: always()
  66. shell: 'bash {0}'
  67. run: |
  68. git reset --hard
  69. git clean -xfd
  70. qmk ci-validate-aliases