# ---------- DRONE 0.8 CONFIG ---------- # Ограничим сборки по веткам и событиям branches: - main - develop - "feature/*" event: - push - pull_request services: docker: image: docker:27-dind privileged: true command: [ "--host=tcp://0.0.0.0:2375" ] environment: DOCKER_TLS_CERTDIR: "" pipeline: prepare: image: alpine/git:latest environment: DOCKER_HOST: tcp://docker:2375 commands: - echo "Pipeline started for branch ${DRONE_BRANCH}" - echo "Commit: ${DRONE_COMMIT_SHA}" - echo "Author: ${DRONE_COMMIT_AUTHOR}" - git --version lint: image: python:3.12-slim commands: - pip install --no-cache-dir flake8 black isort mypy - echo "Running Black formatter check..." - black --check --diff src/ config/ tools/ tests/ || true - echo "Running isort import sorting check..." - isort --check-only --diff src/ config/ tools/ tests/ || true - echo "Running flake8 linting..." - flake8 src/ config/ tools/ tests/ --max-line-length=88 --extend-ignore=E203,W503 || true - echo "Linting completed" test: image: python:3.12-slim commands: - pip install --no-cache-dir -r requirements.txt - echo "Running pytest tests..." - python -m pytest tests/ -v --tb=short || true - echo "Running integration tests..." - python tests/test_bot.py || true - echo "Testing completed" security: image: python:3.12-slim commands: - pip install --no-cache-dir safety bandit - echo "Running safety check..." - safety check --json || true - echo "Running bandit security check..." - bandit -r src/ -f json || true - echo "Security checks completed" typecheck: image: python:3.12-slim commands: - pip install --no-cache-dir mypy types-requests - echo "Running mypy type checking..." - mypy src/ --ignore-missing-imports || true - echo "Type checking completed" docker_build: image: docker:27 environment: DOCKER_HOST: tcp://docker:2375 DOCKER_TLS_CERTDIR: "" commands: - echo "Building Docker image..." - docker version - docker build -t quiz-bot:${DRONE_COMMIT_SHA} . - docker tag quiz-bot:${DRONE_COMMIT_SHA} quiz-bot:latest - echo "Docker build completed" when: branch: include: [ main, develop ] docker_test: image: docker:27 environment: DOCKER_HOST: tcp://docker:2375 DOCKER_TLS_CERTDIR: "" commands: - echo "Testing Docker image..." - docker run --rm quiz-bot:${DRONE_COMMIT_SHA} python -c "import src.bot; print('Import successful')" - echo "Docker test completed" when: branch: include: [ main, develop ] depends_on: - docker_build quality: image: python:3.12-slim commands: - pip install --no-cache-dir flake8 radon - echo "Calculating code metrics..." - radon cc src/ -s || true - radon mi src/ -s || true - echo "Quality check completed" deploy: image: docker:27 environment: DOCKER_HOST: tcp://docker:2375 DOCKER_TLS_CERTDIR: "" commands: - echo "Deployment preparation..." - docker tag quiz-bot:${DRONE_COMMIT_SHA} quiz-bot:production - echo "Tagged image for production" - echo "Deployment completed (simulation)" when: branch: include: [ main ] event: include: [ push ] depends_on: - docker_test - quality notify_success: image: alpine:latest commands: - echo "Pipeline completed for ${DRONE_BRANCH}" - echo "Build status: SUCCESS" - echo "All checks finished." when: status: success notify_failure: image: alpine:latest commands: - echo "Pipeline completed for ${DRONE_BRANCH}" - echo "Build status: FAILURE" - echo "Check previous steps for errors." when: status: failure