devops #1

Merged
trevor merged 11 commits from devops into main 2025-09-10 23:41:22 +00:00
40 changed files with 2326 additions and 409 deletions
Showing only changes of commit 47b2a4d849 - Show all commits

View File

@@ -1,14 +1,3 @@
# ---------- DRONE 0.8 CONFIG ----------
# Ограничим сборки по веткам и событиям
branches:
- main
- develop
event:
- push
- pull_request
services:
docker:
image: docker:27-dind
@@ -33,41 +22,29 @@ pipeline:
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
@@ -75,14 +52,12 @@ pipeline:
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 ]
branch: [ main, develop ]
event: [ push, pull_request ]
docker_test:
image: docker:27
@@ -90,23 +65,17 @@ pipeline:
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
branch: [ main, develop ]
event: [ push, pull_request ]
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
@@ -114,25 +83,17 @@ pipeline:
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
branch: [ main ]
event: [ push ]
notify_success:
image: alpine:latest
commands:
- echo "Pipeline completed for ${DRONE_BRANCH}"
- echo "Build status: SUCCESS"
- echo "All checks finished."
when:
status: success
@@ -141,6 +102,5 @@ pipeline:
commands:
- echo "Pipeline completed for ${DRONE_BRANCH}"
- echo "Build status: FAILURE"
- echo "Check previous steps for errors."
when:
status: failure
status: failure