Skip to content

Commit 576e5c2

Browse files
Refactor pre-commit hooks
1 parent 1f57c1e commit 576e5c2

2 files changed

Lines changed: 63 additions & 2 deletions

File tree

.github/workflows/pull_request.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,38 @@ concurrency:
77
cancel-in-progress: true
88

99
jobs:
10+
lint-code:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: '3.12'
20+
21+
- name: Install Poetry
22+
uses: snok/install-poetry@v1
23+
with:
24+
version: latest
25+
virtualenvs-create: true
26+
virtualenvs-in-project: true
27+
28+
- name: Load cached venv
29+
id: cached-poetry-dependencies
30+
uses: actions/cache@v3
31+
with:
32+
path: .venv
33+
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
34+
35+
- name: Install dependencies
36+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
37+
run: poetry install --no-root
38+
39+
- name: Run pre-commit hooks
40+
run: poetry run pre-commit run --all-files
41+
1042
unit-test:
1143
runs-on: ubuntu-latest
1244
env:

.pre-commit-config.yaml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
11
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
exclude: ^(docker-compose/test.yml|environment/.*)$
9+
- id: check-added-large-files
10+
args:
11+
- --maxkb=2000
12+
- id: check-ast
13+
- id: check-case-conflict
14+
- id: check-merge-conflict
15+
- id: debug-statements
16+
17+
- repo: https://github.com/python-poetry/poetry
18+
rev: 2.0.1
19+
hooks:
20+
- id: poetry-check
21+
- id: poetry-lock
22+
23+
- repo: https://github.com/pre-commit/mirrors-mypy
24+
rev: v1.15.0
25+
hooks:
26+
- id: mypy
27+
pass_filenames: false
28+
229
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.12.3
30+
rev: v0.9.7
431
hooks:
532
- id: ruff
6-
args: ["."]
33+
args:
34+
- --fix
35+
- id: ruff-format

0 commit comments

Comments
 (0)