From 09ab90ed3598fbb2fa255229191b90b74d67505f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Fri, 19 Dec 2025 04:44:55 -0800 Subject: [PATCH] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Use=20prek=20as=20a=20pre-?= =?UTF-8?q?commit=20alternative=20(#14572)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: github-actions[bot] --- .github/workflows/pre-commit.yml | 16 ++++++++++------ requirements.txt | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index fa0574d7d..e628ce541 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -21,14 +21,21 @@ jobs: name: Checkout PR for own repo if: env.IS_FORK == 'false' with: - # To be able to commit it needs more than the last commit + # To be able to commit it needs to fetch the head of the branch, not the + # merge commit ref: ${{ github.head_ref }} + # And it needs the full history to be able to compute diffs + fetch-depth: 0 # A token other than the default GITHUB_TOKEN is needed to be able to trigger CI token: ${{ secrets.PRE_COMMIT }} # pre-commit lite ci needs the default checkout configs to work - uses: actions/checkout@v5 name: Checkout PR for fork if: env.IS_FORK == 'true' + with: + # To be able to commit it needs the head branch of the PR, the remote one + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v6 with: @@ -44,12 +51,9 @@ jobs: run: | uv venv uv pip install -r requirements.txt - - name: Run pre-commit + - name: Run prek - pre-commit id: precommit - run: | - # Fetch the base branch for comparison - git fetch origin ${{ github.base_ref }} - uvx pre-commit run --from-ref origin/${{ github.base_ref }} --to-ref HEAD --show-diff-on-failure + run: uvx prek run --from-ref origin/${GITHUB_BASE_REF} --to-ref HEAD --show-diff-on-failure continue-on-error: true - name: Commit and push changes if: env.IS_FORK == 'false' diff --git a/requirements.txt b/requirements.txt index 1cff1a5a9..3bbab64a4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,6 @@ -r requirements-tests.txt -r requirements-docs.txt -r requirements-translations.txt -pre-commit >=4.5.0,<5.0.0 +prek==0.2.22 # For generating screenshots playwright