From 4e2e04ad44d2701dfb5e95ec36a8e5d5970e6d34 Mon Sep 17 00:00:00 2001 From: Ali Behjati Date: Wed, 13 Sep 2023 10:33:26 +0200 Subject: [PATCH] chore: improve precommit ci --- .github/workflows/pre-commit.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 46e06939..ad6c22bf 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -9,7 +9,10 @@ jobs: pre-commit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + with: + # Need to grab the history of the PR + fetch-depth: 0 - uses: actions/setup-python@v2 - uses: actions-rs/toolchain@v1 with: @@ -21,4 +24,10 @@ jobs: profile: minimal toolchain: nightly-2023-07-23 components: rustfmt, clippy - - uses: pre-commit/action@v2.0.3 + - uses: pre-commit/action@v3.0.0 + if: ${{ github.event_name == 'pull_request' }} + with: + # Run only on files changed in the PR + extra_args: --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }} + - uses: pre-commit/action@v3.0.0 + if: ${{ github.event_name != 'pull_request' }}