2022-02-20 15:57:17 -05:00
|
|
|
name: Check pre-commit rules
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
2022-03-01 13:18:02 -05:00
|
|
|
types: [opened, reopened, synchronize]
|
2022-02-20 15:57:17 -05:00
|
|
|
|
2022-07-02 20:58:46 -04:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
2022-02-20 15:57:17 -05:00
|
|
|
jobs:
|
|
|
|
pre_commit_check:
|
|
|
|
runs-on: ubuntu-latest
|
2023-10-05 01:20:20 -04:00
|
|
|
env:
|
|
|
|
SKIP: "cleanup-ignore-lists" # Comma-separated string of ignored pre-commit check IDs
|
2022-02-20 15:57:17 -05:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2023-10-30 04:13:10 -04:00
|
|
|
uses: actions/checkout@v3
|
2022-02-20 15:57:17 -05:00
|
|
|
- name: Fetch head and base refs
|
|
|
|
# This is necessary for pre-commit to check the changes in the PR branch
|
|
|
|
run: |
|
2022-03-01 13:18:02 -05:00
|
|
|
git fetch origin ${{ github.base_ref }}:base_ref
|
|
|
|
git fetch origin pull/${{ github.event.pull_request.number }}/head:pr_ref
|
2022-02-20 15:57:17 -05:00
|
|
|
- name: Set up Python environment
|
|
|
|
uses: actions/setup-python@master
|
|
|
|
with:
|
2023-07-11 07:25:56 -04:00
|
|
|
python-version: v3.8
|
2022-02-20 15:57:17 -05:00
|
|
|
- name: Install python packages
|
|
|
|
run: |
|
|
|
|
pip install pre-commit
|
|
|
|
pre-commit install-hooks
|
|
|
|
- name: Run pre-commit and check for any changes
|
|
|
|
run: |
|
2022-03-01 13:18:02 -05:00
|
|
|
echo "Commits being checked:"
|
|
|
|
git log --oneline --no-decorate base_ref..pr_ref
|
|
|
|
echo ""
|
|
|
|
if ! pre-commit run --from-ref base_ref --to-ref pr_ref --show-diff-on-failure ; then
|
2022-02-20 15:57:17 -05:00
|
|
|
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
|
2024-04-30 06:36:00 -04:00
|
|
|
# Run pre-commit for PowerShell scripts check
|
|
|
|
pre-commit run --hook-stage manual check-powershell-scripts --from-ref base_ref --to-ref pr_ref --show-diff-on-failure
|