Add GitHub Pages success documentation #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: [3.9, 3.10, 3.11] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Cache pip dependencies | |
| uses: actions/cache@v3 | |
| 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 -r requirements.txt | |
| pip install pytest-cov pytest-xdist | |
| - name: Lint with flake8 | |
| run: | | |
| pip install flake8 | |
| # Stop the build if there are Python syntax errors or undefined names | |
| flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
| # Exit-zero treats all errors as warnings | |
| flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
| - name: Type checking with mypy | |
| run: | | |
| pip install mypy | |
| mypy --ignore-missing-imports --no-strict-optional . | |
| - name: Run unit tests | |
| run: | | |
| pytest tests/ -v --cov=. --cov-report=xml --cov-report=html -x | |
| - name: Run performance tests | |
| run: | | |
| pytest tests/test_performance_optimization.py -v -x | |
| - name: Run integration tests | |
| run: | | |
| pytest tests/test_service_integration.py -v -x | |
| - name: Run end-to-end tests | |
| run: | | |
| pytest tests/test_end_to_end.py -v -x | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: ./coverage.xml | |
| flags: unittests | |
| name: codecov-umbrella | |
| security-scan: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.9 | |
| - name: Install security tools | |
| run: | | |
| pip install bandit safety | |
| - name: Run Bandit security scan | |
| run: | | |
| bandit -r . -f json -o bandit-report.json || true | |
| - name: Run Safety check | |
| run: | | |
| safety check --json --output safety-report.json || true | |
| - name: Upload security reports | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: security-reports | |
| path: | | |
| bandit-report.json | |
| safety-report.json | |
| load-test: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.9 | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run load tests | |
| run: | | |
| pytest tests/test_load_testing.py -v --tb=short | |
| - name: Generate performance report | |
| run: | | |
| python -c " | |
| from utils.performance_monitor import performance_monitor | |
| import json | |
| stats = performance_monitor.get_stats() | |
| with open('performance-report.json', 'w') as f: | |
| json.dump(stats, f, indent=2, default=str) | |
| " | |
| - name: Upload performance report | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: performance-report | |
| path: performance-report.json | |
| docker-build: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image | |
| run: | | |
| docker build -t llm-optimization-platform:${{ github.sha }} . | |
| - name: Test Docker image | |
| run: | | |
| docker run --rm -d --name test-container -p 5000:5000 llm-optimization-platform:${{ github.sha }} | |
| sleep 10 | |
| curl -f http://localhost:5000/api/v1/health || exit 1 | |
| docker stop test-container | |
| - name: Login to Docker Hub | |
| if: github.ref == 'refs/heads/main' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Push to Docker Hub | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| docker tag llm-optimization-platform:${{ github.sha }} ${{ secrets.DOCKER_USERNAME }}/llm-optimization-platform:latest | |
| docker tag llm-optimization-platform:${{ github.sha }} ${{ secrets.DOCKER_USERNAME }}/llm-optimization-platform:${{ github.sha }} | |
| docker push ${{ secrets.DOCKER_USERNAME }}/llm-optimization-platform:latest | |
| docker push ${{ secrets.DOCKER_USERNAME }}/llm-optimization-platform:${{ github.sha }} | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: [test, docker-build] | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Deploy to staging | |
| run: | | |
| echo "Deploying to staging environment..." | |
| # Add actual deployment commands here | |
| # Example: kubectl apply -f k8s/staging/ | |
| - name: Run smoke tests | |
| run: | | |
| echo "Running smoke tests..." | |
| # Add smoke test commands here | |
| - name: Deploy to production | |
| if: success() | |
| run: | | |
| echo "Deploying to production environment..." | |
| # Add production deployment commands here | |
| # Example: kubectl apply -f k8s/production/ | |
| notify: | |
| runs-on: ubuntu-latest | |
| needs: [test, security-scan, load-test, docker-build, deploy] | |
| if: always() | |
| steps: | |
| - name: Notify on success | |
| if: ${{ needs.test.result == 'success' && needs.docker-build.result == 'success' }} | |
| run: | | |
| echo "✅ CI/CD pipeline completed successfully!" | |
| # Add notification logic (Slack, email, etc.) | |
| - name: Notify on failure | |
| if: ${{ needs.test.result == 'failure' || needs.docker-build.result == 'failure' }} | |
| run: | | |
| echo "❌ CI/CD pipeline failed!" | |
| # Add failure notification logic |