Files
quiz_test/.drone.yml
Andrey K. Choi d84b528ced
Some checks reported errors
continuous-integration/drone/push Build encountered an error
pipeline fix
2025-09-11 08:29:43 +09:00

143 lines
3.7 KiB
YAML

kind: pipeline
type: docker
name: quiz-bot-ci-cd
trigger:
branch:
- main
- develop
- "feature/*"
event:
- push
- pull_request
services:
- name: docker
image: docker:27-dind
privileged: true
command:
- --host=tcp://0.0.0.0:2375
environment:
DOCKER_TLS_CERTDIR: ""
steps:
- name: 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
- name: 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"
- name: 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"
- name: 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"
- name: 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"
- name: docker-build
image: docker:27-cli
environment:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
commands:
- 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"
when:
branch:
- main
- develop
- 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('Import successful')"
- echo "Docker test completed"
depends_on:
- docker-build
when:
branch:
- main
- develop
- 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 completed for $DRONE_BRANCH"
- echo "Build status: ${DRONE_BUILD_STATUS}"
- echo "All checks finished."
when:
status:
- success
- failure