name: CI pipeline on: push: branches: [ 'dev-*', 'feature-*', 'fix-*' ] pull_request: branches: [ 'dev-*', 'feature-*', 'fix-*', '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 requirements.txt pip install -r requirements-dev.txt - name: Code style check (isort + Black, one order โ€” no conflict) run: | echo "๐Ÿ” Applying isort then black (pyproject.toml: isort profile=black)..." python -m isort . python -m black . echo "๐Ÿ” Checking that repo is already formatted (no diff after isort+black)..." git diff --exit-code || ( echo "โŒ Code style drift. From THIS repo root (telegram-helper-bot) run:" echo " python -m isort . && python -m black . && 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 || true - 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 tests run: | echo "๐Ÿงช Running tests..." python -m pytest tests/ -v --tb=short - 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: telegram-helper-bot ๐ŸŒฟ 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: telegram-helper-bot ๐ŸŒฟ 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