Skip to content

Commit

Permalink
refactor and basic ci and pytests install
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishankoradia committed Dec 2, 2024
1 parent efb5aac commit b2f368e
Show file tree
Hide file tree
Showing 19 changed files with 100 additions and 3 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Python package

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: ai_plat
POSTGRES_PASSWORD: password
POSTGRES_DB: ai_plat
ports:
- 5432:5432
options: --health-cmd "pg_isready -U ai_plat" --health-interval 10s --health-timeout 5s --health-retries 5

strategy:
matrix:
python-version: ["3.10"]
redis-version: [6]

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Run pre-commit
run: pre-commit run --all-files

- name: Start Redis
uses: supercharge/[email protected]
with:
redis-version: ${{ matrix.redis-version }}

- name: Test with pytest
run: |
pytest tests
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ greenlet==3.1.1
h11==0.14.0
identify==2.6.3
idna==3.10
iniconfig==2.0.0
mypy-extensions==1.0.0
nodeenv==1.9.1
packaging==24.2
platformdirs==4.3.6
pluggy==1.5.0
pre_commit==4.0.1
psutil==5.9.8
pydantic==2.10.2
pydantic-settings==2.6.1
pydantic_core==2.27.1
pytest==8.3.4
pytest-asyncio==0.24.0
python-dotenv==1.0.1
PyYAML==6.0.2
sniffio==1.3.1
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/controllers/auth_controller.py → src/auth/controller.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from fastapi import APIRouter, HTTPException, UploadFile, Form
from fastapi import APIRouter

from src.schemas.auth_schema import LoginPayload, LoginResponse
from src.auth.schemas import LoginPayload, LoginResponse

router = APIRouter()
logger = logging.getLogger(__name__)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions src/document_manager/controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import logging
from fastapi import APIRouter

router = APIRouter()
logger = logging.getLogger(__name__)


@router.get("/")
async def boilerplate():
"""
Boilerplate
"""
return {"success": 1}
File renamed without changes.
File renamed without changes.
Empty file.
Empty file added src/llm/__init__.py
Empty file.
13 changes: 13 additions & 0 deletions src/llm/controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import logging
from fastapi import APIRouter

router = APIRouter()
logger = logging.getLogger(__name__)


@router.get("/")
async def boilerplate():
"""
Boilerplate
"""
return {"success": 1}
Empty file added src/llm/models.py
Empty file.
Empty file added src/llm/schemas.py
Empty file.
Empty file added src/middlewares/__init__.py
Empty file.
8 changes: 7 additions & 1 deletion src/routes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
from fastapi import APIRouter
from src.controllers.auth_controller import router as auth_router
from src.auth.controller import router as auth_router
from src.llm.controller import router as llm_router
from src.document_manager.controller import router as document_manager_router

internal_router = APIRouter()

# mount all api endpoints here
internal_router.include_router(auth_router, prefix="/auth", tags=["Authentication"])
internal_router.include_router(llm_router, prefix="/llm", tags=["LLM"])
internal_router.include_router(
document_manager_router, prefix="/document", tags=["Document Manager"]
)
Empty file added src/utils/__init__.py
Empty file.
9 changes: 9 additions & 0 deletions tests/test_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pytest

# from httpx import AsyncClient
from main import app


@pytest.mark.asyncio
async def test_read_root():
assert True

0 comments on commit b2f368e

Please sign in to comment.