Skip to content

Commit 65063d5

Browse files
committed
Removing auto-running of pre-commit, move tests to Makefile
This commit changes the harness running ruff and nbstripout from pre-commit to a Makefile. Developers can run `make lint` to run `ruff`, `make nbclean` to run `nbstripout` or `make test` to run both. Signed-off-by: Ali Maredia <[email protected]>
1 parent 1fdc247 commit 65063d5

File tree

4 files changed

+26
-37
lines changed

4 files changed

+26
-37
lines changed
Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Pre-commit checks
1+
name: Formatting Tests
22

33
on:
44
pull_request:
@@ -7,21 +7,19 @@ on:
77
- "**/*.py"
88
- "**/*.ipynb"
99
- ".pre-commit-config.yaml"
10+
- "Makefile"
1011
- "pyproject.toml"
1112
pull_request_target:
1213
types: [closed]
1314
paths:
1415
- "**/*.py"
1516
- "**/*.ipynb"
1617
- ".pre-commit-config.yaml"
18+
- "Makefile"
1719
- "pyproject.toml"
1820

19-
concurrency:
20-
group: pre-commit-${{ github.ref }}z
21-
cancel-in-progress: true
22-
2321
jobs:
24-
pre-commit:
22+
formatting-test:
2523
if: github.event_name != 'pull_request_target' || github.event.pull_request.merged == true
2624
runs-on: ubuntu-latest
2725
permissions:
@@ -38,16 +36,8 @@ jobs:
3836
with:
3937
python-version: "3.12"
4038

41-
- name: Cache pre-commit envs
42-
uses: actions/cache@v4
43-
with:
44-
path: ~/.cache/pre-commit
45-
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
46-
4739
- name: Install pre-commit
48-
run: pip install pre-commit
40+
run: pip install ruff nbstripout
4941

50-
- name: Run pre-commit
51-
uses: pre-commit/[email protected]
52-
with:
53-
extra_args: --all-files --show-diff-on-failure
42+
- name: Run Formatting Tests
43+
run: make test

.pre-commit-config.yaml

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,9 @@ repos:
44
- repo: https://github.com/astral-sh/ruff-pre-commit
55
rev: v0.13.0
66
hooks:
7-
- id: ruff
8-
name: ruff-check
9-
args: [--fix, --show-fixes]
10-
types_or: [python]
117
- id: ruff-format
128
name: ruff-format
139
types_or: [python]
14-
15-
# Import ordering (aligned with Black)
16-
- repo: https://github.com/pycqa/isort
17-
rev: 6.0.1
18-
hooks:
19-
- id: isort
20-
types_or: [python]
21-
22-
# Canonical Python formatter
23-
- repo: https://github.com/psf/black
24-
rev: 24.8.0
25-
hooks:
26-
- id: black
27-
types_or: [python]
28-
2910
# Strip notebook outputs anywhere in repo
3011
- repo: https://github.com/kynan/nbstripout
3112
rev: 0.8.1
@@ -39,4 +20,4 @@ exclude: |
3920
^\.venv/|^venv/|
4021
^\.pytest_cache/|^\.mypy_cache/|
4122
^\.ipynb_checkpoints/
42-
)
23+
)

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.PHONY: lint nbcleanup test
2+
3+
USE_CASES := $(wildcard notebooks/use-cases/*.ipynb)
4+
TUTORIALS := $(wildcard notebooks/tutorials/*.ipynb)
5+
ALL_NOTEBOOKS := $(USE_CASES) $(TUTORIALS)
6+
7+
lint:
8+
@echo "Running ruff format..."
9+
ruff format
10+
11+
nbcleanup:
12+
@echo "Running nbstripout..."
13+
nbstripout $(ALL_NOTEBOOKS)
14+
15+
test: lint nbcleanup
16+
@echo "All test completed successfully :)"

requirements-dev.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ruff
2+
nbstripout

0 commit comments

Comments
 (0)