fixed drone.yml
Some checks failed
continuous-integration/drone/push Build encountered an error

This commit is contained in:
2026-01-18 20:23:19 +06:00
parent d8f7f108c7
commit e66ecbf178

View File

@@ -1,83 +1,82 @@
---
kind: pipeline kind: pipeline
type: docker type: docker
name: code-quality name: code-quality
trigger: trigger:
event: event:
- push
- pull_request
steps:
- name: python-lint
image: python:3.11-slim
commands:
- cd backend
- pip install --no-cache-dir flake8 black isort
- echo "Running flake8 linting..."
- flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
- echo "Checking code formatting with black..."
- black --check --diff . || echo "WARNING Code formatting issues found"
- echo "Checking import sorting..."
- isort --check-only --diff . || echo "WARNING Import sorting issues found"
- echo "SUCCESS Python checks completed"
- name: frontend-lint
image: node:20-alpine
commands:
- cd frontend
- npm ci --silent
- echo "Running TypeScript compilation check..."
- npx tsc --noEmit || echo "WARNING TypeScript errors found"
- echo "Running ESLint..."
- npm run lint || echo "WARNING ESLint warnings found (non-blocking)"
- echo "SUCCESS Frontend checks completed"
- name: python-tests
image: python:3.11-slim
commands:
- cd backend
- pip install --no-cache-dir -r requirements.txt pytest pytest-asyncio pytest-cov
- echo "Running Python tests..."
- python -m pytest tests/ -v --cov=. --cov-report=term-missing || echo "WARNING Some tests failed (non-blocking)"
- echo "SUCCESS Python tests completed"
when:
event:
- push - push
- pull_request - pull_request
steps: - name: frontend-tests
- name: python-lint image: node:20-alpine
image: python:3.11-slim commands:
commands: - cd frontend
- cd backend - npm ci --silent
- pip install --no-cache-dir flake8 black isort - echo "Running frontend tests..."
- echo "Running flake8 linting..." - npm test -- --run --reporter=verbose || echo "WARNING Some frontend tests failed (non-blocking)"
- flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - echo "SUCCESS Frontend tests completed"
- echo "Checking code formatting with black..." when:
- black --check --diff . || echo "WARNING Code formatting issues found" event:
- echo "Checking import sorting..." - push
- isort --check-only --diff . || echo "WARNING Import sorting issues found" - pull_request
- echo "SUCCESS Python checks completed"
- name: frontend-lint - name: python-security
image: node:20-alpine image: python:3.11-slim
commands: commands:
- cd frontend - cd backend
- npm ci --silent - pip install --no-cache-dir safety bandit
- echo "Running TypeScript compilation check..." - echo "Checking for known security vulnerabilities..."
- npx tsc --noEmit || echo "WARNING TypeScript errors found" - safety check --file=requirements.txt --exit-zero || echo "WARNING Security warnings found"
- echo "Running ESLint..." - echo "Running bandit security analysis..."
- npm run lint || echo "WARNING ESLint warnings found (non-blocking)" - bandit -r . -f json -o bandit-report.json || echo "WARNING Security issues found"
- echo "SUCCESS Frontend checks completed" - echo "SUCCESS Security checks completed"
- name: python-tests - name: frontend-security
image: python:3.11-slim image: node:20-alpine
commands: commands:
- cd backend - cd frontend
- pip install --no-cache-dir -r requirements.txt pytest pytest-asyncio pytest-cov - npm ci --silent
- echo "Running Python tests..." - echo "Running npm audit..."
- python -m pytest tests/ -v --cov=. --cov-report=term-missing || echo "WARNING Some tests failed (non-blocking)" - npm audit --audit-level=moderate || echo "WARNING Security warnings found"
- echo "SUCCESS Python tests completed" - echo "SUCCESS Frontend security checks completed"
when:
event:
- push
- pull_request
- name: frontend-tests
image: node:20-alpine
commands:
- cd frontend
- npm ci --silent
- echo "Running frontend tests..."
- npm test -- --run --reporter=verbose || echo "WARNING Some frontend tests failed (non-blocking)"
- echo "SUCCESS Frontend tests completed"
when:
event:
- push
- pull_request
- name: python-security
image: python:3.11-slim
commands:
- cd backend
- pip install --no-cache-dir safety bandit
- echo "Checking for known security vulnerabilities..."
- safety check --file=requirements.txt --exit-zero || echo "WARNING Security warnings found"
- echo "Running bandit security analysis..."
- bandit -r . -f json -o bandit-report.json || echo "WARNING Security issues found"
- echo "SUCCESS Security checks completed"
- name: frontend-security
image: node:20-alpine
commands:
- cd frontend
- npm ci --silent
- echo "Running npm audit..."
- npm audit --audit-level=moderate || echo "WARNING Security warnings found"
- echo "SUCCESS Frontend security checks completed"
--- ---
kind: pipeline kind: pipeline
@@ -86,84 +85,84 @@ name: build-and-publish
trigger: trigger:
event: event:
- push - push
- tag - tag
branch: branch:
- main - main
- master - master
- develop - develop
depends_on: depends_on:
- code-quality - code-quality
steps: steps:
- name: build-and-push - name: build-and-push
image: plugins/docker image: plugins/docker
settings: settings:
registry: registry.nevetime.ru registry: registry.nevetime.ru
repo: registry.nevetime.ru/mc-panel repo: registry.nevetime.ru/mc-panel
tags: tags:
- latest - latest
- ${DRONE_COMMIT_SHA:0:8} - ${DRONE_COMMIT_SHA:0:8}
- ${DRONE_BRANCH} - ${DRONE_BRANCH}
auto_tag: true auto_tag: true
dockerfile: Dockerfile dockerfile: Dockerfile
context: . context: .
username: username:
from_secret: docker_username from_secret: docker_username
password: password:
from_secret: docker_password from_secret: docker_password
build_args: build_args:
- BUILD_DATE=${DRONE_BUILD_CREATED} - BUILD_DATE=${DRONE_BUILD_CREATED}
- VCS_REF=${DRONE_COMMIT_SHA} - VCS_REF=${DRONE_COMMIT_SHA}
- VERSION=${DRONE_TAG:-${DRONE_BRANCH}-${DRONE_BUILD_NUMBER}} - VERSION=${DRONE_TAG:-${DRONE_BRANCH}-${DRONE_BUILD_NUMBER}}
when: when:
event: event:
- push - push
- tag - tag
- name: test-image - name: test-image
image: docker:dind image: docker:dind
volumes: volumes:
- name: docker-sock - name: docker-sock
path: /var/run/docker.sock path: /var/run/docker.sock
commands: commands:
- echo "Testing built Docker image..." - echo "Testing built Docker image..."
- docker run --rm -d --name mc-panel-test -p 8001:8000 registry.nevetime.ru/mc-panel:${DRONE_COMMIT_SHA:0:8} - docker run --rm -d --name mc-panel-test -p 8001:8000 registry.nevetime.ru/mc-panel:${DRONE_COMMIT_SHA:0:8}
- sleep 30 - sleep 30
- echo "Checking if application is responding..." - echo "Checking if application is responding..."
- docker exec mc-panel-test curl -f http://localhost:8000/ || echo "WARNING Health check failed" - docker exec mc-panel-test curl -f http://localhost:8000/ || echo "WARNING Health check failed"
- docker stop mc-panel-test - docker stop mc-panel-test
- echo "SUCCESS Image test completed" - echo "SUCCESS Image test completed"
when: when:
event: event:
- push - push
- tag - tag
depends_on: depends_on:
- build-and-push - build-and-push
- name: scan-image - name: scan-image
image: aquasec/trivy:latest image: aquasec/trivy:latest
environment: environment:
TRIVY_USERNAME: TRIVY_USERNAME:
from_secret: docker_username from_secret: docker_username
TRIVY_PASSWORD: TRIVY_PASSWORD:
from_secret: docker_password from_secret: docker_password
commands: commands:
- echo "Scanning image for vulnerabilities..." - echo "Scanning image for vulnerabilities..."
- trivy image --exit-code 0 --severity HIGH,CRITICAL --format table --username $TRIVY_USERNAME --password $TRIVY_PASSWORD registry.nevetime.ru/mc-panel:${DRONE_COMMIT_SHA:0:8} - trivy image --exit-code 0 --severity HIGH,CRITICAL --format table --username $TRIVY_USERNAME --password $TRIVY_PASSWORD registry.nevetime.ru/mc-panel:${DRONE_COMMIT_SHA:0:8}
- echo "SUCCESS Security scan completed" - echo "SUCCESS Security scan completed"
when: when:
event: event:
- push - push
- tag - tag
depends_on: depends_on:
- build-and-push - build-and-push
volumes: volumes:
- name: docker-sock - name: docker-sock
host: host:
path: /var/run/docker.sock path: /var/run/docker.sock
--- ---
kind: pipeline kind: pipeline
@@ -172,35 +171,35 @@ name: deploy-staging
trigger: trigger:
event: event:
- push - push
branch: branch:
- develop - develop
depends_on: depends_on:
- build-and-publish - build-and-publish
steps: steps:
- name: deploy-to-staging - name: deploy-to-staging
image: alpine:latest image: alpine:latest
environment: environment:
STAGING_HOST: STAGING_HOST:
from_secret: staging_host from_secret: staging_host
STAGING_USER: STAGING_USER:
from_secret: staging_user from_secret: staging_user
STAGING_KEY: STAGING_KEY:
from_secret: staging_ssh_key from_secret: staging_ssh_key
commands: commands:
- apk add --no-cache openssh-client - apk add --no-cache openssh-client
- echo "Deploying to staging environment..." - echo "Deploying to staging environment..."
- echo "$STAGING_KEY" | base64 -d > /tmp/ssh_key - echo "$STAGING_KEY" | base64 -d > /tmp/ssh_key
- chmod 600 /tmp/ssh_key - chmod 600 /tmp/ssh_key
- ssh -o StrictHostKeyChecking=no -i /tmp/ssh_key $STAGING_USER@$STAGING_HOST "docker pull registry.nevetime.ru/mc-panel:${DRONE_COMMIT_SHA:0:8} && docker-compose -f /opt/mc-panel/docker-compose.staging.yml up -d" - ssh -o StrictHostKeyChecking=no -i /tmp/ssh_key $STAGING_USER@$STAGING_HOST "docker pull registry.nevetime.ru/mc-panel:${DRONE_COMMIT_SHA:0:8} && docker-compose -f /opt/mc-panel/docker-compose.staging.yml up -d"
- echo "SUCCESS Staging deployment completed" - echo "SUCCESS Staging deployment completed"
when: when:
event: event:
- push - push
branch: branch:
- develop - develop
--- ---
kind: pipeline kind: pipeline
@@ -209,33 +208,33 @@ name: deploy-production
trigger: trigger:
event: event:
- tag - tag
ref: ref:
- refs/tags/v* - refs/tags/v*
depends_on: depends_on:
- build-and-publish - build-and-publish
steps: steps:
- name: deploy-to-production - name: deploy-to-production
image: alpine:latest image: alpine:latest
environment: environment:
PROD_HOST: PROD_HOST:
from_secret: production_host from_secret: production_host
PROD_USER: PROD_USER:
from_secret: production_user from_secret: production_user
PROD_KEY: PROD_KEY:
from_secret: production_ssh_key from_secret: production_ssh_key
commands: commands:
- apk add --no-cache openssh-client - apk add --no-cache openssh-client
- echo "Deploying to production environment..." - echo "Deploying to production environment..."
- echo "$PROD_KEY" | base64 -d > /tmp/ssh_key - echo "$PROD_KEY" | base64 -d > /tmp/ssh_key
- chmod 600 /tmp/ssh_key - chmod 600 /tmp/ssh_key
- ssh -o StrictHostKeyChecking=no -i /tmp/ssh_key $PROD_USER@$PROD_HOST "docker pull registry.nevetime.ru/mc-panel:${DRONE_TAG} && docker-compose -f /opt/mc-panel/docker-compose.prod.yml up -d" - ssh -o StrictHostKeyChecking=no -i /tmp/ssh_key $PROD_USER@$PROD_HOST "docker pull registry.nevetime.ru/mc-panel:${DRONE_TAG} && docker-compose -f /opt/mc-panel/docker-compose.prod.yml up -d"
- echo "SUCCESS Production deployment completed" - echo "SUCCESS Production deployment completed"
when: when:
event: event:
- tag - tag
--- ---
kind: pipeline kind: pipeline
@@ -244,40 +243,40 @@ name: notify
trigger: trigger:
event: event:
- push - push
- tag - tag
- pull_request - pull_request
status: status:
- success - success
- failure - failure
depends_on: depends_on:
- code-quality - code-quality
- build-and-publish - build-and-publish
steps: steps:
- name: notify-telegram - name: notify-telegram
image: appleboy/drone-telegram image: appleboy/drone-telegram
settings: settings:
token: token:
from_secret: telegram_bot_token from_secret: telegram_bot_token
to: to:
from_secret: telegram_chat_id from_secret: telegram_chat_id
format: markdown format: markdown
message: > message: >
{{#success build.status}} {{#success build.status}}
SUCCESS **MC Panel Build Success** SUCCESS **MC Panel Build Success**
{{else}} {{else}}
ERROR **MC Panel Build Failed** ERROR **MC Panel Build Failed**
{{/success}} {{/success}}
**Repository:** {{repo.name}} **Repository:** {{repo.name}}
**Branch:** {{build.branch}} **Branch:** {{build.branch}}
**Commit:** {{build.commit}} **Commit:** {{build.commit}}
**Author:** {{build.author}} **Author:** {{build.author}}
**Message:** {{build.message}} **Message:** {{build.message}}
**Build:** [#{{build.number}}]({{build.link}}) **Build:** [#{{build.number}}]({{build.link}})
when: when:
status: status:
- success - success
- failure - failure