Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Derbit Client workflow

on:
push:
branches:
- "**"
pull_request:

jobs:
lint:
name: Lint & Tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Upgrade pip
run: python -m pip install --upgrade pip

- name: Install dependencies
run: pip install -r requirements.txt

- name: Black check
run: black --check .

- name: Isort check
run: isort --check-only .

- name: Flake8 check
run: flake8 .

- name: Run pytest
run: pytest -v
12 changes: 0 additions & 12 deletions app/core/database.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine
from sqlalchemy.orm import DeclarativeBase

from app.core.config import settings

engine = create_async_engine(settings.database_url, future=True)

async_session = async_sessionmaker(engine, expire_on_commit=False)


class Base(DeclarativeBase):
pass


async def get_session():
async with async_session() as session:
yield session
12 changes: 12 additions & 0 deletions app/core/session.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine

from app.core.config import settings

engine = create_async_engine(settings.database_url, future=True)

async_session = async_sessionmaker(engine, expire_on_commit=False)


async def get_session():
async with async_session() as session:
yield session
2 changes: 1 addition & 1 deletion app/routers/prices.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from fastapi import APIRouter, Depends, HTTPException, Query
from sqlalchemy.ext.asyncio import AsyncSession

from app.core.database import get_session
from app.core.session import get_session
from app.crud.price_crud import CRUDPrice
from app.schemas.prices import PriceReadSchema

Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
aiohappyeyeballs==2.6.1
aiohttp==3.13.3
aiosignal==1.4.0
aiosqlite==0.22.1
alembic==1.18.1
amqp==5.3.1
annotated-doc==0.0.4
Expand All @@ -15,6 +16,7 @@ click==8.3.1
click-didyoumean==0.3.1
click-plugins==1.1.1.2
click-repl==0.3.0
coverage==7.13.1
fastapi==0.128.0
flake8==7.3.0
frozenlist==1.8.0
Expand Down Expand Up @@ -43,6 +45,7 @@ pydantic_core==2.41.5
pyflakes==3.4.0
Pygments==2.19.2
pytest==9.0.2
pytest-asyncio==1.3.0
python-dateutil==2.9.0.post0
python-dotenv==1.2.1
pytokens==0.3.0
Expand Down
2 changes: 2 additions & 0 deletions tests/test_crud_price.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ async def session():
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.drop_all)

await engine.dispose()


@pytest.mark.asyncio
async def test_save_price(session):
Expand Down