init commit

This commit is contained in:
2025-12-18 05:55:32 +09:00
commit a6817e487e
72 changed files with 13847 additions and 0 deletions

110
.github/workflows/tests.yml vendored Normal file
View File

@@ -0,0 +1,110 @@
name: Tests
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: test_db
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis:7-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov pytest-asyncio python-dotenv
- name: Create .env file
run: |
cat > .env << EOF
TELEGRAM_BOT_TOKEN=test_token
TELEGRAM_API_ID=123456
TELEGRAM_API_HASH=test_hash
ADMIN_ID=123456789
DB_HOST=localhost
DB_PORT=5432
DB_USER=test
DB_PASSWORD=test
DB_NAME=test_db
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_DB=0
TG_WORKER_COUNT=1
LOG_LEVEL=INFO
EOF
- name: Run tests
run: |
pytest tests/ -v --cov=app --cov-report=xml
continue-on-error: true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: always()
with:
files: ./coverage.xml
fail_ci_if_error: false
- name: Lint with flake8
run: |
pip install flake8
flake8 app/ --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 app/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
continue-on-error: true
- name: Type check with mypy
run: |
pip install mypy
mypy app/ --ignore-missing-imports
continue-on-error: true
- name: Format check with black
run: |
pip install black
black --check app/
continue-on-error: true
- name: Import sort check with isort
run: |
pip install isort
isort --check-only app/
continue-on-error: true