pre_commit_check.yml 1.2 KB

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