Skip to content

Fix linting errors: ruff, black, isort #2

Fix linting errors: ruff, black, isort

Fix linting errors: ruff, black, isort #2

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
env:
PYTHON_VERSION: "3.11"
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
jobs:
# ============================================
# Linting and Code Quality
# ============================================
lint:
name: Lint & Format 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: ${{ env.PYTHON_VERSION }}
- name: Install linting tools
run: |
pip install ruff black isort
- name: Run Ruff (linter)
run: ruff check app/ tests/ --ignore E501
- name: Check Black formatting
run: black --check app/ tests/
- name: Check import sorting
run: isort --check-only app/ tests/
# ============================================
# Unit Tests
# ============================================
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
- name: Run unit tests
run: |
pytest tests/unit/ -v --tb=short -m "unit or not integration and not e2e and not evaluation"
env:
GOOGLE_API_KEY: "test-api-key"
# ============================================
# Integration Tests
# ============================================
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
needs: unit-tests
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
- name: Run integration tests
run: |
pytest tests/integration/ -v --tb=short -m "integration"
env:
GOOGLE_API_KEY: "test-api-key"
# ============================================
# End-to-End Tests
# ============================================
e2e-tests:
name: E2E Tests
runs-on: ubuntu-latest
needs: integration-tests
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
- name: Run E2E tests
run: |
pytest tests/e2e/ -v --tb=short -m "e2e"
env:
GOOGLE_API_KEY: "test-api-key"
# ============================================
# RAG Evaluation Tests
# ============================================
evaluation-tests:
name: RAG Evaluation Tests
runs-on: ubuntu-latest
needs: e2e-tests
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
- name: Run evaluation tests
run: |
pytest tests/evaluation/ -v --tb=short -m "evaluation" --ignore-glob="*slow*"
env:
GOOGLE_API_KEY: "test-api-key"
# ============================================
# Full Test Suite with Coverage
# ============================================
coverage:
name: Test Coverage
runs-on: ubuntu-latest
needs: [unit-tests, integration-tests]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests with coverage
run: |
pytest tests/ -v --cov=app --cov-report=xml --cov-report=html --cov-fail-under=60
env:
GOOGLE_API_KEY: "test-api-key"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./coverage.xml
fail_ci_if_error: false
# ============================================
# Docker Build
# ============================================
docker-build:
name: Docker Build
runs-on: ubuntu-latest
needs: [e2e-tests]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
push: false
tags: agentic-rag:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
# ============================================
# Security Scan
# ============================================
security:
name: Security Scan
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install safety
run: pip install safety bandit
- name: Run safety check
run: safety check -r requirements.txt || true
- name: Run bandit security scan
run: bandit -r app/ -ll || true
# ============================================
# Deploy (only on main)
# ============================================
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: [docker-build, coverage, security]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Deploy notification
run: |
echo "🚀 Ready for deployment!"
echo "Commit: ${{ github.sha }}"
echo "Branch: ${{ github.ref_name }}"
# Add your deployment steps here:
# - Push to container registry
# - Deploy to cloud platform
# - Update Kubernetes manifests