Skip to content

Commit 2d01668

Browse files
committed
ci: Set linting according to discussion
Ref: kernelci/kernelci-project#566 Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
1 parent 5607897 commit 2d01668

6 files changed

Lines changed: 47 additions & 27 deletions

File tree

.github/workflows/main.yml

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -72,33 +72,17 @@ jobs:
7272
7373
lint:
7474
runs-on: ubuntu-latest
75-
container:
76-
image: ubuntu:24.04
7775
name: Lint
7876

7977
steps:
80-
- name: Install base tooling
81-
run: |
82-
apt-get update
83-
apt-get install -y --no-install-recommends git python3 python3-venv python3-pip
84-
85-
- name: Create Python virtual environment
86-
run: |
87-
python3 -m venv /opt/venv
88-
/opt/venv/bin/pip install --no-cache-dir --upgrade pip
89-
9078
- name: Check out source code
9179
uses: actions/checkout@v4
92-
with:
93-
fetch-depth: 32 # This is necessary to get the commits
9480

95-
- name: Install linting dependencies
96-
run: |
97-
/opt/venv/bin/pip install --no-cache-dir ruff
81+
- name: Install ruff
82+
run: pip install ruff
9883

99-
- name: Run ruff format check (line-length policy)
100-
run: /opt/venv/bin/ruff format --check --diff --line-length 110 api tests
84+
- name: Ruff lint
85+
run: ruff check .
10186

102-
- name: Run ruff lint check (E/W/F/I + complexity policy)
103-
run: |
104-
/opt/venv/bin/ruff check --line-length 110 --select E,W,F,I,C901 --ignore E203 api tests
87+
- name: Ruff format
88+
run: ruff format --check --diff .

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: LGPL-2.1-or-later
2+
repos:
3+
- repo: https://github.com/astral-sh/ruff-pre-commit
4+
rev: v0.11.5
5+
hooks:
6+
- id: ruff
7+
args: [--fix, --exit-non-zero-on-fix]
8+
- id: ruff-format

api/main.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,9 +1703,19 @@ async def patch_node(
17031703

17041704
# State transition checks
17051705
if new_state is not None:
1706+
<<<<<<< HEAD
17061707
is_valid, message = specialized_node.validate_node_state_transition(new_state)
17071708
if not is_valid:
17081709
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=message)
1710+
=======
1711+
is_valid, message = specialized_node.validate_node_state_transition(
1712+
new_state
1713+
)
1714+
if not is_valid:
1715+
raise HTTPException(
1716+
status_code=status.HTTP_400_BAD_REQUEST, detail=message
1717+
)
1718+
>>>>>>> 7df261e (api: Implement PATCH endpoint for node)
17091719
if new_state != new_node_def.state:
17101720
new_node_def.processed_by_kcidb_bridge = False
17111721
new_node_def.state = new_state

docker/api/requirements-dev.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
-r requirements-tests.txt
2-
pycodestyle==2.8.0
3-
pylint==4.0.4
2+
ruff>=0.9.0
3+
pre-commit>=4.0.0

pyproject.toml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ tests = [
4646
]
4747
dev = [
4848
"kernelci-api[tests]",
49-
"pycodestyle == 2.8.0",
50-
"pylint == 4.0.4",
49+
"ruff >= 0.9.0",
50+
"pre-commit >= 4.0.0",
5151
]
5252

5353
[project.urls]
@@ -64,3 +64,21 @@ scripts = ["*"]
6464
"api.static.css" = ["*.css"]
6565
"api.static.js" = ["*.js"]
6666
migrations = ["*.py"]
67+
68+
# Ruff — used by CI and pre-commit hooks
69+
[tool.ruff]
70+
target-version = "py310"
71+
# Soft limit for formatter wrapping
72+
line-length = 80
73+
74+
[tool.ruff.lint]
75+
# Ruff defaults (E, F, W) plus import sorting and complexity checking
76+
select = ["E", "F", "W", "I", "C901"]
77+
78+
[tool.ruff.lint.pycodestyle]
79+
# Hard limit — lines beyond this are errors regardless of formatter
80+
max-line-length = 110
81+
82+
[tool.ruff.lint.per-file-ignores]
83+
# Legacy high-complexity entrypoint, to be refactored incrementally
84+
"api/main.py" = ["C901"]

tests/e2e_tests/test_pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from cloudevents.http import from_json
1111

1212
from .listen_handler import create_listen_task
13-
from .test_node_handler import create_node, get_node_by_id, update_node
13+
from .test_node_handler import create_node, get_node_by_id, patch_node, update_node
1414

1515

1616
@pytest.mark.dependency(

0 commit comments

Comments
 (0)