name: CI/CD on: push: branches: [main, develop] pull_request: branches: [main] jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.11' - name: Install dependencies run: | python -m pip install --upgrade pip pip install flake8 pytest pip install -r requirements.txt - name: Lint with flake8 run: | flake8 src/ --count --select=E9,F63,F7,F82 --show-source --statistics flake8 src/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.11' - name: Install dependencies run: | python -m pip install --upgrade pip pip install pytest pytest-cov pip install -r requirements.txt - name: Test with pytest run: pytest tests/ --cov=src --cov-report=xml build: needs: [lint, test] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build Docker image run: | docker build -t atm-anomaly-detection:${{ github.sha }} . docker tag atm-anomaly-detection:${{ github.sha }} atm-anomaly-detection:latest - name: Test Docker image run: | docker run --rm atm-anomaly-detection:${{ github.sha }} python -c "import src.models.anomaly_detector; print('Import OK')" deploy: needs: build runs-on: ubuntu-latest if: github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v4 - name: Deploy to production run: | echo "Deploying to production server..." # Add your deployment commands here # Example: ssh user@server "cd /app && docker-compose pull && docker-compose up -d"