pre_commit_check.yml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. name: Check pre-commit rules
  2. on:
  3. pull_request:
  4. types: [opened, reopened, synchronize]
  5. permissions:
  6. contents: read
  7. jobs:
  8. pre_commit_check:
  9. runs-on: ubuntu-latest
  10. env:
  11. SKIP: "cleanup-ignore-lists" # Comma-separated string of ignored pre-commit check IDs
  12. steps:
  13. - name: Checkout
  14. uses: actions/checkout@v3
  15. - name: Fetch head and base refs
  16. # This is necessary for pre-commit to check the changes in the PR branch
  17. run: |
  18. git fetch origin ${{ github.base_ref }}:base_ref
  19. git fetch origin pull/${{ github.event.pull_request.number }}/head:pr_ref
  20. - name: Set up Python environment
  21. uses: actions/setup-python@master
  22. with:
  23. python-version: v3.8
  24. - name: Install python packages
  25. run: |
  26. pip install pre-commit
  27. pre-commit install-hooks
  28. - name: Run pre-commit and check for any changes
  29. run: |
  30. echo "Commits being checked:"
  31. git log --oneline --no-decorate base_ref..pr_ref
  32. echo ""
  33. if ! pre-commit run --from-ref base_ref --to-ref pr_ref --show-diff-on-failure ; then
  34. echo ""
  35. echo "::notice::It looks like the commits in this PR have been made without having pre-commit hooks installed."
  36. echo "::notice::Please see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/contribute/install-pre-commit-hook.html for instructions."
  37. echo ""
  38. exit 1
  39. fi