Skip to content

Commit 9f24788

Browse files
committed
Added pre-commit GitHub workflow
1 parent 741bded commit 9f24788

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

.github/workflows/pre-commit.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
name: pre-commit
3+
4+
on:
5+
push:
6+
branches:
7+
- "master"
8+
pull_request:
9+
10+
jobs:
11+
hooks:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
# Get the code
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
# Set up Python with built-in pip caching
20+
- name: Set up Python
21+
id: python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.13"
25+
cache: "pip"
26+
27+
# Cache pre-commit’s virtual envs + hook repos
28+
- name: Cache pre-commit envs
29+
uses: actions/cache@v4
30+
with:
31+
path: ~/.cache/pre-commit
32+
key: >
33+
${{ format('pre-commit-{0}-{1}',
34+
steps.python.outputs.python-version,
35+
hashFiles('.pre-commit-config.yaml')) }}
36+
37+
# Install the tool itself
38+
- name: Install pre-commit
39+
run: |
40+
pip install --upgrade pip pre-commit
41+
pre-commit install
42+
43+
# Run all hooks not already handled by other workflows
44+
- name: Run hooks
45+
run: |
46+
pre-commit run --all-files --show-diff-on-failure --color=always

0 commit comments

Comments
 (0)