Skip to content

fix: apply Black and isort formatting fixes #23

fix: apply Black and isort formatting fixes

fix: apply Black and isort formatting fixes #23

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
env:
PYTHON_VERSION: "3.13"
jobs:
code-quality:
name: Code Quality Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache pip dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Code formatting with Black
run: black --check --line-length 120 app/ tests/
- name: Import sorting with isort
run: isort --check-only --profile black app/ tests/
- name: Linting with flake8
run: flake8 app/ tests/ --max-line-length=120 --extend-ignore=E203,W503
- name: Type checking with mypy
run: mypy app/ --ignore-missing-imports
test-ubuntu:
name: Tests (Ubuntu - PyTorch Backend)
runs-on: ubuntu-latest
needs: code-quality
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run unit tests
env:
BACKEND: torch
LOG_LEVEL: DEBUG
run: |
pytest tests/ -v --cov=app --cov-report=xml --cov-report=html
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
test-macos:
name: Tests (macOS - MLX + PyTorch)
runs-on: macos-latest
needs: code-quality
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache pip dependencies
uses: actions/cache@v4
with:
path: ~/Library/Caches/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev,mlx]"
- name: Run tests with auto backend selection
env:
BACKEND: auto
LOG_LEVEL: DEBUG
run: |
pytest tests/ -v --cov=app --cov-report=xml
- name: Run MLX-specific tests
env:
BACKEND: mlx
LOG_LEVEL: DEBUG
run: |
pytest tests/test_backends.py::test_mlx_backend -v
- name: Run PyTorch MPS tests
env:
BACKEND: torch
LOG_LEVEL: DEBUG
run: |
pytest tests/test_backends.py::test_torch_backend -v
integration-tests:
name: API Integration Tests
runs-on: ubuntu-latest
needs: [test-ubuntu, test-macos]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run API integration tests
env:
BACKEND: torch
run: |
pytest tests/test_integration.py -v
- name: Run performance benchmarks
env:
BACKEND: torch
CI: true
run: |
timeout 120s python -m app.utils.benchmark --quick --ci || echo "Benchmark timed out or failed, continuing..."
security-scan:
name: Security Scanning
runs-on: ubuntu-latest
needs: code-quality
steps:
- uses: actions/checkout@v4
- name: Run Bandit security scanner
run: |
pip install bandit[toml]
bandit -r app/ -f json -o bandit-report.json
- name: Run Safety dependency scanner
run: |
pip install safety
safety check --json --output safety-report.json
- name: Upload security reports
uses: actions/upload-artifact@v4
if: always()
with:
name: security-reports
path: |
bandit-report.json
safety-report.json
build-test:
name: Build Test
runs-on: ubuntu-latest
needs: [integration-tests, security-scan]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Test application startup
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
# Test that the application can start
timeout 60s python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 &
APP_PID=$!
sleep 15
# Check if the health endpoint responds
if curl -f --max-time 10 http://localhost:8000/health/ ; then
echo "Health check passed"
else
echo "Health check failed"
kill $APP_PID 2>/dev/null || true
exit 1
fi
# Clean up
kill $APP_PID 2>/dev/null || true
- name: Build wheel
run: |
pip install build
python -m build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/