Przeglądaj źródła

feature(ci): Add Ruff linting configuration and GitHub Actions workflow

- Add Ruff configuration to pyproject.toml with PEP 8 compliance
  - Line length: 88 characters
  - Indentation: 4 spaces (PEP 8 standard)
  - Enable comprehensive rule sets (pycodestyle, pyflakes, isort, pylint, etc.)
- Create .github/workflows/codequality-ruff.yaml
  - Runs on PRs to main and pushes to main/release/* branches
  - Checks both linting and formatting (blocking)
- Fix yamllint errors in config.yaml and release workflow
- Remove whitespace from table_display.py

Related to #1318
xcad 4 miesięcy temu
rodzic
commit
b152f55211

+ 36 - 0
.github/workflows/codequality-ruff.yaml

@@ -0,0 +1,36 @@
+---
+name: Code Quality - Ruff
+
+'on':
+  pull_request:
+    branches:
+      - main
+  push:
+    branches:
+      - main
+      - 'release/**'
+
+permissions:
+  contents: read
+
+jobs:
+  ruff:
+    name: Python Linting and Formatting
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v5
+
+      - name: Set up Python
+        uses: actions/setup-python@v5
+        with:
+          python-version: '3.9'
+
+      - name: Install Ruff
+        run: pip install ruff
+
+      - name: Run Ruff Linting
+        run: ruff check .
+
+      - name: Run Ruff Formatting Check
+        run: ruff format --check .

+ 1 - 2
.github/workflows/release-create-cli-release.yaml

@@ -98,10 +98,9 @@ jobs:
         run: |
           # Extract the changelog for this version from CHANGELOG.md
           VERSION="${{ steps.version.outputs.version }}"
-          
+
           # First try to extract the section for this specific version
           CHANGELOG=$(awk -v ver="$VERSION" '/^## \[/{if($0 ~ "\\[" ver "\\]"){flag=1; next} else if(flag){exit}} flag' CHANGELOG.md)
-          
           # If empty, fall back to [Unreleased] section
           if [ -z "$CHANGELOG" ]; then
             CHANGELOG=$(awk '/^## \[Unreleased\]/{flag=1; next} /^## \[/{flag=0} flag' CHANGELOG.md)

+ 0 - 1
cli/core/display/table_display.py

@@ -42,7 +42,6 @@ class TableDisplayManager:
             return
 
         logger.info(f"Listing {len(templates)} templates for module '{module_name}'")
-        
         table = Table()
         table.add_column("ID", style="bold", no_wrap=True)
         table.add_column("Name")

+ 54 - 0
pyproject.toml

@@ -30,3 +30,57 @@ boilerplates = "cli.__main__:run"
 [tool.setuptools.packages.find]
 include = ["cli*"]
 exclude = ["tests*", "scripts*"]
+
+[tool.ruff]
+# PEP 8 compliant line length (88 is Black's default, good balance)
+line-length = 88
+
+# Python 3.9+ as minimum version
+target-version = "py39"
+
+# Exclude common directories
+exclude = [
+    ".git",
+    "__pycache__",
+    ".venv",
+    "venv",
+    "build",
+    "dist",
+    "*.egg-info",
+]
+
+[tool.ruff.lint]
+# Enable rule categories
+select = [
+    "E",      # pycodestyle errors
+    "W",      # pycodestyle warnings
+    "F",      # pyflakes
+    "I",      # isort (import sorting)
+    "N",      # pep8-naming
+    "UP",     # pyupgrade
+    "B",      # flake8-bugbear
+    "C4",     # flake8-comprehensions
+    "PL",     # pylint
+    "SIM",    # flake8-simplify
+    "RUF",    # ruff-specific rules
+]
+
+# Disable specific rules
+ignore = [
+    "E501",   # Line too long (handled by formatter)
+    "PLR0913", # Too many arguments
+]
+
+# Allow auto-fixing for these rules
+fixable = ["ALL"]
+unfixable = []
+
+[tool.ruff.format]
+# Use PEP 8 standard: 4 spaces for indentation
+indent-style = "space"
+
+# Use double quotes (consistent with Python conventions)
+quote-style = "double"
+
+# Unix line endings
+line-ending = "lf"