Skip to content

Commit 1ebf334

Browse files
authored
✨ feat: Add CI configuration, testing setup, and initial test cases (#130)
* ✨ feat: Add CI configuration, testing setup, and initial test cases * ✨ feat: Add 'dummy' vector store mode for testing and development * ✨ feat: Update CI configuration and remove dummy vector store mode * ✨ feat: Improve error handling for invalid mode in store_factory.py * ✨ feat: Refactor project structure and implement new vector store services * ✨ feat: Add request validation error handling and implement main application logic * ✨ fix: Ensure newline at end of file in main.py * ✨ feat: Implement main application logic with FastAPI and document handling endpoints * ✨ refactor: Clean up and organize imports in main.py; enhance document routes with improved error handling * ✨ refactor: Streamline health check logic and improve document deletion handling; add health utility module * ✨ feat: Add initial test suite for application components; include tests for configuration, database, document loading, health checks, middleware, and models * ✨ test: Add configuration for testing environment and implement dummy vector store for unit tests * ✨ test: Add configuration for testing environment and implement dummy vector store for unit tests * ✨ refactor: Remove redundant health check test; streamline test suite * ✨ feat: Implement asynchronous vector store classes for PostgreSQL and MongoDB; enhance document handling and retrieval
1 parent 19d8f4d commit 1ebf334

37 files changed

+1352
-970
lines changed

.github/workflows/ci.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
8+
jobs:
9+
build-and-test:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Python 3.12
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: '3.12'
20+
21+
- name: Cache pip dependencies
22+
uses: actions/cache@v4
23+
with:
24+
path: ~/.cache/pip
25+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt', 'test_requirements.txt') }}
26+
restore-keys: |
27+
${{ runner.os }}-pip-
28+
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install -r requirements.txt
33+
pip install -r test_requirements.txt
34+
35+
- name: Run tests and generate report
36+
env:
37+
OPENAI_API_KEY: test_key
38+
run: |
39+
pytest --maxfail=1 --disable-warnings --junitxml=test-results.xml
40+
41+
- name: Upload test results
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: test-results
45+
path: test-results.xml

app/__init__.py

Whitespace-only changes.

config.py renamed to app/config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# config.py
1+
# app/config.py
22
import os
33
import json
44
import boto3
@@ -7,7 +7,8 @@
77
from datetime import datetime
88
from dotenv import find_dotenv, load_dotenv
99
from starlette.middleware.base import BaseHTTPMiddleware
10-
from store_factory import get_vector_store
10+
11+
from app.services.vector_store.factory import get_vector_store
1112

1213
load_dotenv(find_dotenv())
1314

constants.py renamed to app/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# app/constants.py
12
from enum import Enum
23

34

middleware.py renamed to app/middleware.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
# app/middleware.py
12
import os
3+
import jwt
4+
from jwt import PyJWTError
25
from fastapi import Request
36
from datetime import datetime, timezone
47
from fastapi.responses import JSONResponse
5-
from config import logger
6-
7-
import jwt
8-
from jwt import PyJWTError
8+
from app.config import logger
99

1010

1111
async def security_middleware(request: Request, call_next):
@@ -54,4 +54,4 @@ async def next_middleware_call():
5454
status_code=401, content={"detail": f"Invalid token: {str(e)}"}
5555
)
5656

57-
return await next_middleware_call()
57+
return await next_middleware_call()

models.py renamed to app/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# app/models.py
12
import hashlib
23
from enum import Enum
34
from pydantic import BaseModel

app/routes/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)