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
56 changes: 56 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Lint & Format Check

on:
push:
branches: [main, develop, "feature/**"]
paths:
- "backend/**/*.py"
- ".github/workflows/lint.yml"
pull_request:
branches: [main, develop]
paths:
- "backend/**/*.py"

jobs:
lint:
name: Code Quality Check
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"

- name: Install linting dependencies
run: |
python -m pip install --upgrade pip
pip install black>=23.0.0 flake8>=7.0.0 isort>=5.13.0

- name: Format code with Black
run: |
cd backend
black src/ --line-length=100

- name: Sort imports with isort
run: |
cd backend
isort src/ --profile=black --line-length=100

- name: Lint with Flake8
run: |
cd backend
flake8 src/ --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 src/ --count --max-complexity=10 --max-line-length=100 --statistics

- name: Summary
if: success()
run: |
echo "= All code quality checks passed!"
echo "- Black formatting: ✓"
echo "- Import sorting (isort): ✓"
echo "- Linting (flake8): ✓"
32 changes: 19 additions & 13 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ target-version = ['py311']
include = '\.pyi?$'
extend-exclude = '''
/(
\.eggs
# directories
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
| alembic/versions
)/
'''

Expand All @@ -17,16 +24,15 @@ profile = "black"
line_length = 100
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
skip_gitignore = true
skip = ["alembic/versions"]

[tool.mypy]
python_version = "3.11"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
plugins = ["pydantic.mypy"]

[tool.pylint.messages_control]
disable = "C0330, C0326"

[tool.pylint.format]
max-line-length = "100"
[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = "test_*.py"
python_classes = "Test*"
python_functions = "test_*"
addopts = "-v --cov=src --cov-report=html --cov-report=term-missing --cov-fail-under=75"
15 changes: 7 additions & 8 deletions backend/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
CodeGuard AI - Backend Entry Point
FastAPI Application
"""

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

Expand All @@ -11,7 +12,7 @@
description="Multi-Agent Code Review System",
version="1.0.0",
docs_url="/docs",
redoc_url="/redoc"
redoc_url="/redoc",
)

# CORS
Expand All @@ -23,20 +24,18 @@
allow_headers=["*"],
)


@app.get("/health")
async def health_check():
"""Health check endpoint"""
return {
"status": "healthy",
"version": "1.0.0",
"service": "CodeGuard AI Backend"
}
return {"status": "healthy", "version": "1.0.0", "service": "CodeGuard AI Backend"}


@app.get("/")
async def root():
"""Root endpoint"""
return {
"message": "CodeGuard AI - Multi-Agent Code Review System",
"docs": "/docs",
"health": "/health"
}
"health": "/health",
}