Merge branch 'bugfix/gh_pre_commit' into 'master'

github: fix pre-commit failure for PRs from forks

See merge request espressif/esp-idf!17310
pull/8500/head
Ivan Grokhotkov 2022-03-03 23:04:52 +08:00
commit e8dda89247
1 zmienionych plików z 7 dodań i 3 usunięć

Wyświetl plik

@ -2,6 +2,7 @@ name: Check pre-commit rules
on: on:
pull_request: pull_request:
types: [opened, reopened, synchronize]
jobs: jobs:
pre_commit_check: pre_commit_check:
@ -12,8 +13,8 @@ jobs:
- name: Fetch head and base refs - name: Fetch head and base refs
# This is necessary for pre-commit to check the changes in the PR branch # This is necessary for pre-commit to check the changes in the PR branch
run: | run: |
git fetch origin ${GITHUB_BASE_REF} git fetch origin ${{ github.base_ref }}:base_ref
git fetch origin ${GITHUB_HEAD_REF} git fetch origin pull/${{ github.event.pull_request.number }}/head:pr_ref
- name: Set up Python environment - name: Set up Python environment
uses: actions/setup-python@master uses: actions/setup-python@master
with: with:
@ -24,7 +25,10 @@ jobs:
pre-commit install-hooks pre-commit install-hooks
- name: Run pre-commit and check for any changes - name: Run pre-commit and check for any changes
run: | run: |
if ! pre-commit run --from-ref "origin/${GITHUB_BASE_REF}" --to-ref "origin/${GITHUB_HEAD_REF}" --show-diff-on-failure ; then 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
echo "" echo ""
echo "::notice::It looks like the commits in this PR have been made without having pre-commit hooks installed." 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 "::notice::Please see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/contribute/install-pre-commit-hook.html for instructions."