Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 6 additions & 22 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,33 +72,17 @@ jobs:

lint:
runs-on: ubuntu-latest
container:
image: ubuntu:24.04
name: Lint

steps:
- name: Install base tooling
run: |
apt-get update
apt-get install -y --no-install-recommends git python3 python3-venv python3-pip

- name: Create Python virtual environment
run: |
python3 -m venv /opt/venv
/opt/venv/bin/pip install --no-cache-dir --upgrade pip

- name: Check out source code
uses: actions/checkout@v4
with:
fetch-depth: 32 # This is necessary to get the commits

- name: Install linting dependencies
run: |
/opt/venv/bin/pip install --no-cache-dir ruff
- name: Install ruff
run: pip install ruff

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

- name: Run ruff lint check (E/W/F/I + complexity policy)
run: |
/opt/venv/bin/ruff check --line-length 110 --select E,W,F,I,C901 --ignore E203 api tests
- name: Ruff format
run: ruff format --check --diff .
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.5
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
10 changes: 10 additions & 0 deletions api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1703,9 +1703,19 @@ async def patch_node(

# State transition checks
if new_state is not None:
<<<<<<< HEAD
is_valid, message = specialized_node.validate_node_state_transition(new_state)
if not is_valid:
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=message)
=======
is_valid, message = specialized_node.validate_node_state_transition(
new_state
)
if not is_valid:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST, detail=message
)
>>>>>>> 7df261e (api: Implement PATCH endpoint for node)
if new_state != new_node_def.state:
new_node_def.processed_by_kcidb_bridge = False
new_node_def.state = new_state
Expand Down
4 changes: 2 additions & 2 deletions docker/api/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-r requirements-tests.txt
pycodestyle==2.8.0
pylint==4.0.4
ruff>=0.9.0
pre-commit>=4.0.0
22 changes: 20 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ tests = [
]
dev = [
"kernelci-api[tests]",
"pycodestyle == 2.8.0",
"pylint == 4.0.4",
"ruff >= 0.9.0",
"pre-commit >= 4.0.0",
]

[project.urls]
Expand All @@ -64,3 +64,21 @@ scripts = ["*"]
"api.static.css" = ["*.css"]
"api.static.js" = ["*.js"]
migrations = ["*.py"]

# Ruff — used by CI and pre-commit hooks
[tool.ruff]
target-version = "py310"
# Soft limit for formatter wrapping
line-length = 80

[tool.ruff.lint]
# Ruff defaults (E, F, W) plus import sorting and complexity checking
select = ["E", "F", "W", "I", "C901"]

[tool.ruff.lint.pycodestyle]
# Hard limit — lines beyond this are errors regardless of formatter
max-line-length = 110

[tool.ruff.lint.per-file-ignores]
# Legacy high-complexity entrypoint, to be refactored incrementally
"api/main.py" = ["C901"]
2 changes: 1 addition & 1 deletion tests/e2e_tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from cloudevents.http import from_json

from .listen_handler import create_listen_task
from .test_node_handler import create_node, get_node_by_id, update_node
from .test_node_handler import create_node, get_node_by_id, patch_node, update_node


@pytest.mark.dependency(
Expand Down
Loading