diff --git a/.drone.yml b/.drone.yml index 39b580a..fbfd352 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,106 +1,43 @@ kind: pipeline type: docker -name: quiz-bot-ci +name: multibot-ci + +trigger: + branch: + - main + - develop + - "feature/*" + event: + - push + - pull_request steps: - name: install-deps - image: python:3.12-slim + image: python:3.11-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 + image: python:3.11-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" + - pip install flake8 + - flake8 . - name: docker-build - image: docker:dind - volumes: - - name: dockersock - path: /var/run/docker.sock - commands: - - echo "Docker version info:" - - docker version - - echo "Building Docker image..." - - docker build -t ${DRONE_REPO_NAME}:latest . - - docker tag ${DRONE_REPO_NAME}:latest quiz-bot:${DRONE_COMMIT_SHA} - - echo "Docker build completed" - - docker images | grep -E "${DRONE_REPO_NAME}|quiz-bot" || true + image: plugins/docker:27 + settings: + repo: ${DRONE_REPO} # или ${DRONE_REPO_NAMESPACE}/${DRONE_REPO_NAME} + tags: + - latest + - ${DRONE_COMMIT_SHA} + dockerfile: Dockerfile + # Если не хочешь пушить — добавь: + # dry_run: true - name: docker-test - image: docker:dind - volumes: - - name: dockersock - path: /var/run/docker.sock + image: docker:27-cli commands: - - echo "Testing Docker image..." - - docker run --rm ${DRONE_REPO_NAME}:latest python -c "import src.bot; print('Bot import successful')" || true - - docker run --rm ${DRONE_REPO_NAME}:latest python -c "import config.config; print('Config import successful')" || true - - echo "Docker tests completed" - - - name: quality - image: python:3.12-slim - commands: - - echo "Installing quality tools..." - - pip install flake8 radon - - echo "Calculating code metrics..." - - radon cc src/ -s || true - - radon mi src/ -s || true - - echo "Quality check completed" - - - 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 "Quiz Bot CI Pipeline completed!" - -volumes: - - name: dockersock - host: - path: /var/run/docker.sock + - docker run --rm ${DRONE_REPO_NAME}:${DRONE_COMMIT_SHA} python -c "print('image ok')" + depends_on: + - docker-build