format.yml 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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@v44
  31. with:
  32. use_rest_api: true
  33. - name: Run qmk formatters
  34. shell: 'bash {0}'
  35. run: |
  36. echo '${{ steps.file_changes.outputs.added_files}}' '${{ steps.file_changes.outputs.modified_files}}' > ~/files_changed.txt
  37. qmk format-c --core-only $(< ~/files_changed.txt) || true
  38. qmk format-python $(< ~/files_changed.txt) || true
  39. qmk format-text $(< ~/files_changed.txt) || true
  40. - name: Fail when formatting required
  41. run: |
  42. git diff
  43. for file in $(git diff --name-only); do
  44. echo "File '${file}' Requires Formatting"
  45. echo "::error file=${file}::Requires Formatting"
  46. done
  47. test -z "$(git diff --name-only)"