Skip to content

Commit fd81008

Browse files
authored
Merge pull request nerc-project#210 from sudoCommit/feature/nerc-project#209
nerc-project#209: add pre-commit hooks
2 parents ac89456 + e3c4a01 commit fd81008

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

.github/workflows/pre-commit.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.12"
20+
21+
- name: Run pre-commit hooks
22+
uses: pre-commit/action@v3.0.1

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-json
8+
- id: check-merge-conflict
9+
- id: check-case-conflict
10+
- id: detect-private-key
11+
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
rev: v0.11.6
14+
hooks:
15+
- id: ruff
16+
args: [--fix]
17+
- id: ruff-format

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,17 @@ following resource allocation attribute types.
153153

154154
By submitting a Resource Allocation Change Request and editing those attributes
155155
a PI can request a change in their quota.
156+
157+
## Pre-commit hooks
158+
```
159+
pip install pre-commit
160+
```
161+
Pre-commit runs tools like:
162+
- [Ruff](https://docs.astral.sh/ruff/) — fast linter and fixer
163+
- Basic checks like trailing whitespace removal, JSON validation, and more.
164+
165+
To set up Git hook locally:
166+
```
167+
pre-commit install
168+
```
169+
After this, every time you make a commit, the hooks will run automatically!

0 commit comments

Comments
 (0)