name: CI pipeline on: push: branches: [ 'dev-*', 'feature/**' ] pull_request: branches: [ 'main' ] workflow_dispatch: 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 "black>=24.0,<25" "isort>=5.13,<6" flake8 mypy || true - name: Code quality (Black + isort) — те же команды, что make code-quality run: | make format-check import-check || (echo "" && echo "❌ Code style drift. Locally run: make import-fix && make format && git add -A && git commit -m 'style: isort + black'" && 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