From 2f7cbd16db3ce7a5095a31cf5ae077ffbbae73aa Mon Sep 17 00:00:00 2001 From: David Cermak Date: Thu, 30 Mar 2023 12:46:20 +0200 Subject: [PATCH] ci(common): Fix pre-commit manual run --- .github/workflows/pre_commit_check.yml | 16 +++++++++------- .pre-commit-config.yaml | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pre_commit_check.yml b/.github/workflows/pre_commit_check.yml index a2dcb5421..7f2268314 100644 --- a/.github/workflows/pre_commit_check.yml +++ b/.github/workflows/pre_commit_check.yml @@ -12,12 +12,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 + with: + ref: ${{ github.base_ref }} - 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 (and to set origin/HEAD and HEAD refs) run: | - git fetch origin ${{ github.base_ref }}:base_ref - git fetch origin pull/${{ github.event.pull_request.number }}/head:pr_ref + git fetch origin ${{ github.event.pull_request.head.sha }}:pr_ref + git checkout pr_ref + git remote set-head origin --auto - name: Set up Python environment uses: actions/setup-python@master with: @@ -26,13 +29,12 @@ jobs: run: | pip install pre-commit pre-commit install-hooks - pre-commit install --hook-type commit-msg --hook-type pre-push - name: Run pre-commit and check for any changes run: | echo "Commits being checked:" - git log --oneline --no-decorate base_ref..pr_ref + git log --oneline --no-decorate origin/HEAD..HEAD echo "" - if ! pre-commit run --from-ref base_ref --to-ref pr_ref --show-diff-on-failure ; then + if ! pre-commit run --from-ref origin/HEAD --to-ref HEAD --hook-stage manual --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://github.com/espressif/esp-protocols/CONTRIBUTING.md for instructions." diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9fbc575b4..054daf085 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -57,7 +57,7 @@ repos: hooks: - id: commitizen - id: commitizen-branch - stages: [push] + stages: [push, manual] - repo: local hooks: - id: commit message scopes