Skip to content

Commit 3a35d42

Browse files
authored
feat: integrate pre-commit tool (#70)
1 parent 8c71200 commit 3a35d42

6 files changed

Lines changed: 188 additions & 20 deletions

File tree

.ort.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ excludes:
99
comment: "Packages for testing only."
1010
resolutions:
1111
rule_violations:
12+
- message: ".*PyPI::setuptools:78\\.1\\.1.*"
13+
reason: "CANT_FIX_EXCEPTION"
14+
comment: "BSD 3-Clause New or Revised License: https://github.com/pypa/setuptools/blob/v78.1.1/LICENSE"
1215
- message: ".*PyPI::httpcore:1\\.0\\.9.*"
1316
reason: "CANT_FIX_EXCEPTION"
1417
comment: "BSD 3-Clause New or Revised License: https://github.com/encode/httpcore/blob/1.0.9/LICENSE.md"

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: make-format
5+
name: Make Format
6+
pass_filenames: false
7+
entry: make format
8+
language: system
9+
stages: [pre-push]
10+
11+
- id: make-lint
12+
name: Make Lint
13+
pass_filenames: false
14+
entry: make lint
15+
language: system
16+
stages: [pre-push]

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ clean:
2222
$(POETRY) run clean
2323
$(POETRY) env remove --all
2424

25+
install_git_hooks: install
26+
$(VENV_DIR)/bin/pre-commit install
27+
2528
lint: install
2629
$(POETRY) run nox -s lint
2730

@@ -44,6 +47,7 @@ help:
4447
@echo '===================='
4548
@echo 'install - install virtual env and dependencies'
4649
@echo 'clean - clean virtual env and build artifacts'
50+
@echo 'install_git_hooks - install the git hooks'
4751
@echo '-- LINTING --'
4852
@echo 'format - run code formatters'
4953
@echo 'lint - run linters'

README.md

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
- [Pre-requisites](#pre-requisites)
4747
- [Setup](#setup)
4848
- [Main commands](#main-commands)
49+
- [Git hooks](#git-hooks)
4950

5051
## Usage
5152

@@ -789,16 +790,28 @@ The following tools are required to work with the project:
789790
make install
790791
```
791792

793+
### Git hooks
794+
795+
You may optionally install Git hooks that will automatically run the linting step on Git push. You only need to do it once for the given repository.
796+
797+
```sh
798+
make install_git_hooks
799+
```
800+
801+
> [!IMPORTANT]
802+
> This command doesn't work if you have already installed Git hooks locally or globally.
803+
792804
### Main commands
793805
794-
| Command | Description |
795-
|-------------------------|-----------------------------------------------|
796-
| `make install` | Install virtual environment and dependencies |
797-
| `make build` | Build the package |
798-
| `make clean` | Clean virtual environment and build artifacts |
799-
| `make lint` | Run linters |
800-
| `make format` | Run code formatters |
801-
| `make test` | Run tests (e.g., `make test PYTHON=3.12`) |
802-
| `make integration_test` | Run integration tests |
803-
| `make coverage` | Generate test coverage report |
804-
| `make help` | Show available commands |
806+
| Command | Description |
807+
|---------------------------|-----------------------------------------------|
808+
| `make install` | Install virtual environment and dependencies |
809+
| `make build` | Build the package |
810+
| `make clean` | Clean virtual environment and build artifacts |
811+
| `make install_git_hooks` | Install the git hooks |
812+
| `make lint` | Run linters |
813+
| `make format` | Run code formatters |
814+
| `make test` | Run tests (e.g., `make test PYTHON=3.12`) |
815+
| `make integration_test` | Run integration tests |
816+
| `make coverage` | Generate test coverage report |
817+
| `make help` | Show available commands |

0 commit comments

Comments
 (0)