kind: pipeline type: docker name: test-and-deploy trigger: event: [push, pull_request] steps: - name: checks image: python:3.12-slim environment: BOT_TOKEN: "123456:TEST_TOKEN_FOR_ISOLATED_TESTS" commands: - apt-get update && apt-get install -y --no-install-recommends git - pip install --upgrade pip - pip install -r requirements-dev.txt - python -m compileall -q src main.py scripts migrations - ruff check src main.py scripts tests migrations - python scripts/check_secrets.py - pip-audit -r requirements.txt - python -m pytest -q - name: postgres-tests image: python:3.12-slim environment: BOT_TOKEN: "123456:TEST_TOKEN_FOR_ISOLATED_TESTS" DATABASE_URL: "postgresql+asyncpg://lottery_test:lottery_test@postgres:5432/lottery_test" TEST_DATABASE_URL: "postgresql+asyncpg://lottery_test:lottery_test@postgres:5432/lottery_test" TEST_REDIS_URL: "redis://redis:6379/15" commands: - pip install -r requirements-dev.txt - python scripts/wait_database.py - alembic upgrade head - python scripts/check_schema.py - python -m pytest -q - name: package image: python:3.12-slim commands: - python scripts/build_release.py - name: deploy image: python:3.12-slim environment: DEPLOY_HOST: "192.168.40.112" DEPLOY_USER: from_secret: lottery_deploy_user DEPLOY_SSH_KEY: from_secret: lottery_deploy_ssh_key DEPLOY_KNOWN_HOSTS: from_secret: lottery_deploy_known_hosts DEPLOY_PATH: from_secret: lottery_deploy_path LOTTERY_ENV: from_secret: lottery_env commands: - apt-get update && apt-get install -y --no-install-recommends openssh-client - python scripts/drone_deploy.py when: branch: [master] event: [push] status: [success] services: - name: redis image: redis:7-alpine - name: postgres image: postgres:16-alpine environment: POSTGRES_USER: lottery_test POSTGRES_PASSWORD: lottery_test POSTGRES_DB: lottery_test