name: CI pipeline on: push: branches: [ 'dev-*', 'feature/**' ] workflow_dispatch: inputs: action: description: 'Action to perform' required: true type: choice jobs: test: runs-on: ubuntu-latest name: Test & Code Quality steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Python 3.11 uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r tests/infra/requirements-test.txt pip install flake8 black isort mypy || true - name: Code formatting check (Black) run: | echo "🔍 Checking code formatting with Black..." black --check . || (echo "❌ Code formatting issues found. Run 'black .' to fix." && exit 1) - name: Import sorting check (isort) run: | echo "🔍 Checking import sorting with isort..." isort --check-only . || (echo "❌ Import sorting issues found. Run 'isort .' to fix." && exit 1) - name: Linting (flake8) - Critical errors run: | echo "🔍 Running flake8 linter (critical errors only)..." flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - name: Linting (flake8) - Warnings run: | echo "🔍 Running flake8 linter (warnings)..." flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics || true continue-on-error: true - name: Run infrastructure tests run: | python -m pytest tests/infra/ -v --tb=short - name: Validate Prometheus config run: | python -m pytest tests/infra/test_prometheus_config.py -v - name: Send test success notification if: success() uses: appleboy/telegram-action@v1.0.0 with: to: ${{ secrets.TELEGRAM_CHAT_ID }} token: ${{ secrets.TELEGRAM_BOT_TOKEN }} message: | ✅ CI Tests Passed 📦 Repository: prod 🌿 Branch: ${{ github.ref_name }} 📝 Commit: ${{ github.sha }} 👤 Author: ${{ github.actor }} ✅ All tests passed! Code quality checks completed successfully. 🔗 View details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} continue-on-error: true - name: Send test failure notification if: failure() uses: appleboy/telegram-action@v1.0.0 with: to: ${{ secrets.TELEGRAM_CHAT_ID }} token: ${{ secrets.TELEGRAM_BOT_TOKEN }} message: | ❌ CI Tests Failed 📦 Repository: prod 🌿 Branch: ${{ github.ref_name }} 📝 Commit: ${{ github.sha }} 👤 Author: ${{ github.actor }} ❌ Tests failed! Deployment blocked. Please fix the issues and try again. 🔗 View details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} continue-on-error: true