Skip to content

Commit 0b8a88b

Browse files
committed
ci: add pre-commit configuration and workflow
- Add `.pre-commit-config.yaml` to configure hooks for: - Standard file checks (trailing whitespace, EOF fixer, YAML check, large files) - `nbstripout` for Jupyter notebooks - `ruff` for linting - `black` for formatting - Add `.github/workflows/pre-commit.yml` to enforce checks on push and pull requests.
1 parent 5f52c3f commit 0b8a88b

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

.github/workflows/pre-commit.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Pre-commit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main, master]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: '3.12'
16+
- uses: pre-commit/action@v3.0.1

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.6.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
12+
- repo: https://github.com/kynan/nbstripout
13+
rev: 0.8.1
14+
hooks:
15+
- id: nbstripout
16+
files: \.ipynb$
17+
18+
- repo: https://github.com/astral-sh/ruff-pre-commit
19+
rev: v0.3.4
20+
hooks:
21+
- id: ruff
22+
args: [ --fix ]
23+
24+
- repo: https://github.com/psf/black
25+
rev: 26.1.0
26+
hooks:
27+
- id: black

0 commit comments

Comments
 (0)