Skip to content

refactor: Add comprehensive type annotations to CassandraManager #24

refactor: Add comprehensive type annotations to CassandraManager

refactor: Add comprehensive type annotations to CassandraManager #24

Workflow file for this run

name: CI/CD Pipeline
on:
pull_request:
branches: [ main, develop ]
push:
branches: [ main, develop ]
tags: [ 'v*' ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --with dev
- name: Install project
run: poetry install --no-interaction
- name: Install Kubernetes dependencies
run: poetry add kubernetes structlog
- name: Install Playwright browsers
run: poetry run playwright install chromium
- name: Run code quality checks
run: |
poetry run black --check src/ tests/
poetry run isort --check-only src/ tests/
poetry run flake8 src/ tests/
poetry run mypy src/
- name: Run security checks
run: |
poetry run safety check
poetry run bandit -r src/ -f json
- name: Run tests
run: |
poetry run pytest tests/ -v --tb=short
- name: Validate orchestrator
run: |
poetry run python -c "from src.orchestrator import BatchOrchestrator, OrchestratorConfig; print('✅ Orchestrator imports successfully')"
- name: Validate Kubernetes manifests
run: |
# Install yamllint for YAML syntax validation
pip install yamllint
# Check YAML syntax
echo "🔍 Validating YAML syntax..."
yamllint deployment/kubernetes/*.yaml || echo "⚠️ YAML lint warnings found"
# Install kubectl for manifest validation
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
# Validate manifests syntax (offline validation)
echo "🔍 Validating Kubernetes manifests..."
for file in deployment/kubernetes/*.yaml; do
echo "Validating $file..."
kubectl apply --dry-run=client --validate=false -f "$file" || echo "⚠️ Validation failed for $file"
done
echo "✅ Kubernetes manifest validation completed"
docker-build:
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
security-scan:
needs: docker-build
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
permissions:
contents: read
security-events: write
steps:
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest'
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: 'trivy-results.sarif'
deploy-staging:
needs: [test, docker-build]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop'
steps:
- name: Deploy to staging
run: |
echo "🚀 Deploying to staging environment"
echo "Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:develop"
# Add actual deployment commands here
deploy-production:
needs: [test, docker-build, security-scan]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Deploy to production
run: |
echo "🚀 Deploying to production environment"
echo "Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}"
# Add actual deployment commands here