Skip to content

Commit 089d3fb

Browse files
committed
feat: use prek instead of pre-commit
1 parent 12443c4 commit 089d3fb

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

.github/workflows/pre-commit.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
3333
id: pre-commit-cache
3434
with:
35-
path: ~/.cache/pre-commit
35+
path: ~/.cache/prek
3636
key: ${{ runner.os }}-pre-commit-${{ steps.get-date.outputs.cache_tag }}-${{ hashFiles('.pre-commit-config.yaml') }}
3737
restore-keys: |
3838
${{ runner.os }}-pre-commit-${{ steps.get-date.outputs.cache_tag }}
@@ -53,16 +53,14 @@ jobs:
5353
echo "method=requirements" >> "$GITHUB_OUTPUT"
5454
elif test -f pyproject.toml && grep -q dependency-groups pyproject.toml ; then
5555
echo "method=pep735" >> "$GITHUB_OUTPUT"
56-
elif test -f pyproject.toml && grep -q dependency-groups pyproject.toml ; then
57-
echo "method=pyproject" >> "$GITHUB_OUTPUT"
5856
else
5957
echo "method=uvx" >> "$GITHUB_OUTPUT"
6058
fi
6159
- name: pre-commit (PEP 735)
6260
if: steps.detect.outputs.method == 'pep735'
6361
run: |
64-
uv run --only-group pre-commit pre-commit run --all --show-diff-on-failure
65-
uv run --only-group pre-commit pre-commit gc
62+
uv run --only-group pre-commit prek run --all --show-diff-on-failure
63+
uv run --only-group pre-commit prek cache gc
6664
env:
6765
RUFF_OUTPUT_FORMAT: github
6866
REUSE_OUTPUT_FORMAT: github
@@ -76,15 +74,10 @@ jobs:
7674
RUFF_OUTPUT_FORMAT: github
7775
REUSE_OUTPUT_FORMAT: github
7876
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79-
- name: Install dependencies
77+
- name: pre-commit (requirements)
8078
if: steps.detect.outputs.method == 'requirements'
81-
run: uv pip install --system -r requirements-lint.txt
82-
- name: Install dependencies
83-
if: steps.detect.outputs.method == 'pyproject'
84-
run: uv pip install --system "$(sed -n 's/.*"\(pre-commit==\([^"]*\)\)".*/\1/p' pyproject.toml)"
85-
- name: pre-commit (installed)
86-
if: steps.detect.outputs.method == 'requirements' || steps.detect.outputs.method == 'pyproject'
8779
run: |
80+
uv pip install --system -r requirements-lint.txt
8881
pre-commit run --all --show-diff-on-failure
8982
pre-commit gc
9083
env:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ dev = [
44
{include-group = "pre-commit"}
55
]
66
pre-commit = [
7-
"pre-commit==4.5.1"
7+
"prek==0.2.28"
88
]
99

1010
[project]

repo-fixups

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
sed -i '/# renovate: datasource=pypi depName=uv /D' .github/workflows/*.{yml,yaml}
88

9+
if [ -f pyproject.toml ]; then
10+
sed -i 's/pre-commit==[0-9.]*/prek==0.2.28/' pyproject.toml
11+
fi
12+
913
for file in .github/workflows/*.{yml,yaml}; do
1014
"${ROOT:-.}/update-workflow" "$file"
1115
done

0 commit comments

Comments
 (0)