pre_commit_check.yml 1.3 KB

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