Skip to content

Commit

Permalink
github: verify pre-commit checks for PRs in Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
igrr committed Feb 21, 2022
1 parent f02169b commit df38abf
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 27 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/pre_commit_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Check pre-commit rules

on:
pull_request:

jobs:
pre_commit_check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Fetch head and base refs
# This is necessary for pre-commit to check the changes in the PR branch
run: |
git fetch origin ${GITHUB_BASE_REF}
git fetch origin ${GITHUB_HEAD_REF}
- name: Set up Python environment
uses: actions/setup-python@master
with:
python-version: v3.7
- name: Install python packages
run: |
pip install pre-commit
pre-commit install-hooks
- name: Run pre-commit and check for any changes
run: |
if ! pre-commit run --from-ref "origin/${GITHUB_BASE_REF}" --to-ref "origin/${GITHUB_HEAD_REF}" --show-diff-on-failure ; then
echo ""
echo "::notice::It looks like the commits in this PR have been made without having pre-commit hooks installed."
echo "::notice::Please see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/contribute/install-pre-commit-hook.html for instructions."
echo ""
exit 1
fi
27 changes: 0 additions & 27 deletions .github/workflows/python_lint.yml

This file was deleted.

0 comments on commit df38abf

Please sign in to comment.