kind: pipeline type: docker name: quiz-bot-ci steps: - name: install-deps image: python:3.12-slim commands: - echo "๐Ÿ”ง Installing dependencies..." - pip install --upgrade pip - pip install -r requirements.txt - echo "โœ… Dependencies installed" - name: prepare image: alpine/git:latest commands: - echo "๐Ÿš€ Pipeline started for branch ${DRONE_BRANCH}" - echo "๐Ÿ“ Commit: $(echo ${DRONE_COMMIT_SHA} | cut -c1-8)" - echo "๐Ÿ‘ค Author: ${DRONE_COMMIT_AUTHOR}" - echo "๐Ÿ“… Build: ${DRONE_BUILD_NUMBER}" - git --version - name: lint image: python:3.12-slim commands: - echo "๐Ÿ” Installing linting tools..." - pip install flake8 black isort - 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" - name: test image: python:3.12-slim commands: - echo "๐Ÿงช Installing test dependencies..." - pip install -r requirements.txt - pip install pytest - echo "๐Ÿš€ Running tests..." - python -m pytest tests/ -v --tb=short || true - python tests/test_bot.py || true - echo "โœ… Tests completed" - name: security image: python:3.12-slim commands: - echo "๐Ÿ”’ Installing security tools..." - pip install 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" - name: docker_build image: docker:27-cli environment: DOCKER_HOST: tcp://docker:2375 DOCKER_TLS_CERTDIR: "" commands: - echo "๐Ÿณ Docker version info:" - docker version - echo "๐Ÿ”จ Building Docker image..." - docker build -t quiz-bot:${DRONE_COMMIT_SHA} . - docker tag quiz-bot:${DRONE_COMMIT_SHA} quiz-bot:latest - echo "๏ฟฝ๏ฟฝ Docker build completed" - docker images | grep quiz-bot || true when: branch: - main - develop event: - push - pull_request - name: docker_test image: docker:27-cli 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('โœ… Bot import successful')" - docker run --rm quiz-bot:${DRONE_COMMIT_SHA} python -c "import config.config; print('โœ… Config import successful')" - echo "โœ… Docker tests completed" depends_on: - docker_build when: branch: - main - develop event: - push - pull_request - name: 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" - name: deploy image: docker:27-cli 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)" depends_on: - docker_test - quality when: branch: - main event: - push - name: notify image: alpine:latest commands: - echo "๐Ÿ“‹ Pipeline Summary:" - echo "๐ŸŒฟ Branch: ${DRONE_BRANCH}" - echo "๐Ÿ“ Commit: $(echo ${DRONE_COMMIT_SHA} | cut -c1-8)" - echo "๐Ÿ—๏ธ Build: #${DRONE_BUILD_NUMBER}" - echo "๐Ÿ‘ค Author: ${DRONE_COMMIT_AUTHOR}" - echo "โœ… Status: ${DRONE_BUILD_STATUS}" - echo "๐Ÿ•’ Started: ${DRONE_BUILD_STARTED}" - echo "๐ŸŽ‰ All checks passed!" when: status: - success - failure