format.yml 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. name: PR Lint Format
  2. permissions:
  3. contents: read
  4. on:
  5. pull_request:
  6. paths:
  7. - 'drivers/**'
  8. - 'lib/arm_atsam/**'
  9. - 'lib/lib8tion/**'
  10. - 'lib/python/**'
  11. - 'platforms/**'
  12. - 'quantum/**'
  13. - 'tests/**'
  14. - 'tmk_core/**'
  15. jobs:
  16. lint:
  17. runs-on: ubuntu-latest
  18. container: ghcr.io/qmk/qmk_cli
  19. steps:
  20. - name: Disable safe.directory check
  21. run : git config --global --add safe.directory '*'
  22. - uses: actions/checkout@v4
  23. with:
  24. fetch-depth: 0
  25. - name: Install dependencies
  26. run: |
  27. pip3 install -r requirements-dev.txt
  28. - name: Get changed files
  29. id: file_changes
  30. uses: tj-actions/changed-files@v39
  31. - name: Run qmk formatters
  32. shell: 'bash {0}'
  33. run: |
  34. echo '${{ steps.file_changes.outputs.added_files}}' '${{ steps.file_changes.outputs.modified_files}}' > ~/files_changed.txt
  35. qmk format-c --core-only $(< ~/files_changed.txt) || true
  36. qmk format-python $(< ~/files_changed.txt) || true
  37. qmk format-text $(< ~/files_changed.txt) || true
  38. - name: Fail when formatting required
  39. run: |
  40. git diff
  41. for file in $(git diff --name-only); do
  42. echo "File '${file}' Requires Formatting"
  43. echo "::error file=${file}::Requires Formatting"
  44. done
  45. test -z "$(git diff --name-only)"