From 1d42f0e1eb176661afbf7fb292a65df1d29c6284 Mon Sep 17 00:00:00 2001 From: Parfait Detchenou Date: Tue, 2 Sep 2025 11:30:39 +0100 Subject: [PATCH 1/3] ci: run checks in ci pipeline --- .github/workflows/ci.yml | 12 ++++++++++++ .pre-commit-config.yaml | 15 ++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 76e73cb7..9b652dd4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,9 +6,21 @@ on: workflow_dispatch: jobs: + lint: + name: Check code style + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v2 + - name: Install precommit + run: pip install pre-commit + - name: Check lint + run: pre-commit run ruff-check --all-files + - name: Check format + run: pre-commit run ruff-format --all-files test: name: CI on python${{ matrix.python }} via ${{ matrix.os }} runs-on: ${{ matrix.os }} + needs: lint strategy: matrix: include: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 60ffefa6..99d5da01 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,18 +7,11 @@ repos: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace -- repo: https://github.com/psf/black - rev: 24.4.2 +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.12.11 hooks: - - id: black -- repo: https://github.com/pycqa/flake8 - rev: 7.0.0 - hooks: - - id: flake8 - additional_dependencies: - - flake8-bugbear - - flake8-comprehensions - - flake8-simplify + - id: ruff-check + - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.10.0 hooks: From 0062af13e67219515fc4c860d843ade4e00c145d Mon Sep 17 00:00:00 2001 From: Parfait Detchenou Date: Fri, 5 Sep 2025 10:27:18 +0100 Subject: [PATCH 2/3] ref: changes to match linting requirements --- ceph_devstack/cli.py | 2 +- ceph_devstack/host.py | 4 +--- ruff.toml | 2 ++ 3 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 ruff.toml diff --git a/ceph_devstack/cli.py b/ceph_devstack/cli.py index 46c0ef58..27bdf132 100644 --- a/ceph_devstack/cli.py +++ b/ceph_devstack/cli.py @@ -9,7 +9,7 @@ from ceph_devstack.resources.ceph import CephDevStack -def main(): +def main(): # noqa: C901 args = parse_args(sys.argv[1:]) config.load(args.config_file) if args.verbose: diff --git a/ceph_devstack/host.py b/ceph_devstack/host.py index cf1cc641..1fcca5f4 100644 --- a/ceph_devstack/host.py +++ b/ceph_devstack/host.py @@ -99,9 +99,7 @@ async def check_selinux_bool(self, name: str): proc = await host.arun(["getsebool", name]) assert proc.stdout is not None out = await proc.stdout.read() - if out.decode().strip() != f"{name} --> on": - return False - return True + return out.decode().strip() != f"{name} --> on" async def get_sysctl_value(self, name: str) -> int: proc = await host.arun(["sysctl", "-b", name]) diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 00000000..c912d6f1 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,2 @@ +[lint] +extend-select = ["B", "C", "SIM"] From 45015b723571de157479e10ecd84210c29bf11c1 Mon Sep 17 00:00:00 2001 From: Parfait Detchenou Date: Tue, 9 Sep 2025 09:28:50 +0100 Subject: [PATCH 3/3] lint: use raise from for traceback --- ceph_devstack/resources/ceph/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ceph_devstack/resources/ceph/utils.py b/ceph_devstack/resources/ceph/utils.py index 7ac2d75c..6f96f5aa 100644 --- a/ceph_devstack/resources/ceph/utils.py +++ b/ceph_devstack/resources/ceph/utils.py @@ -29,8 +29,8 @@ def get_most_recent_run(runs: list[str]) -> str: ) ) return run_name - except StopIteration: - raise FileNotFoundError + except StopIteration as e: + raise FileNotFoundError from e def get_job_id(jobs: list[str]):