Skip to content

Commit fe5bd3c

Browse files
committed
Completed Task B16
1 parent 95d132e commit fe5bd3c

7 files changed

Lines changed: 888 additions & 105 deletions

File tree

.github/workflows/ci.yml

Lines changed: 78 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,17 @@ jobs:
2828
working-directory: ./frontend
2929
run: npm run type-check
3030

31-
- name: Run frontend tests
31+
- name: Run frontend tests with coverage
3232
working-directory: ./frontend
33-
run: npm run test
33+
run: npm run test -- --coverage --watchAll=false
34+
35+
- name: Upload frontend coverage
36+
uses: codecov/codecov-action@v3
37+
if: always()
38+
with:
39+
file: ./frontend/coverage/lcov.info
40+
flags: frontend
41+
name: frontend-coverage
3442

3543
- name: Build frontend
3644
working-directory: ./frontend
@@ -67,13 +75,23 @@ jobs:
6775
working-directory: ./backend
6876
run: isort --check-only --diff .
6977

70-
- name: Run backend tests
78+
- name: Run backend tests with coverage
7179
working-directory: ./backend
72-
run: pytest --cov=. --cov-report=xml
80+
run: |
81+
pytest --cov=. --cov-report=xml --cov-report=term --cov-fail-under=75
82+
coverage report --fail-under=75
7383
env:
7484
TESTING: true
7585
DATABASE_URL: ${{ secrets.DATABASE_URL || 'sqlite:///test.db' }}
7686
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY || 'test-key' }}
87+
88+
- name: Upload coverage reports
89+
uses: codecov/codecov-action@v3
90+
if: always()
91+
with:
92+
file: ./backend/coverage.xml
93+
flags: backend
94+
name: backend-coverage
7795

7896
# Integration Tests
7997
integration:
@@ -95,6 +113,29 @@ jobs:
95113
--health-retries 5
96114
ports:
97115
- 5432:5432
116+
117+
redis:
118+
image: redis:7-alpine
119+
options: >-
120+
--health-cmd "redis-cli ping"
121+
--health-interval 10s
122+
--health-timeout 5s
123+
--health-retries 5
124+
ports:
125+
- 6379:6379
126+
127+
minio:
128+
image: minio/minio:latest
129+
env:
130+
MINIO_ROOT_USER: test-access-key
131+
MINIO_ROOT_PASSWORD: test-secret-key
132+
options: >-
133+
--health-cmd "curl -f http://localhost:9000/minio/health/live || exit 1"
134+
--health-interval 30s
135+
--health-timeout 20s
136+
--health-retries 3
137+
ports:
138+
- 9000:9000
98139

99140
steps:
100141
- name: Checkout code
@@ -123,14 +164,34 @@ jobs:
123164
python -m pip install --upgrade pip
124165
pip install -r requirements-dev.txt
125166
167+
- name: Setup MinIO
168+
run: |
169+
# Wait for MinIO to be ready and create test bucket
170+
timeout 60 bash -c 'until curl -f http://localhost:9000/minio/health/live; do sleep 2; done'
171+
# Install MinIO client
172+
curl -fsSL https://dl.min.io/client/mc/release/linux-amd64/mc -o mc
173+
chmod +x mc
174+
sudo mv mc /usr/local/bin/
175+
# Configure MinIO client
176+
mc alias set minio http://localhost:9000 test-access-key test-secret-key
177+
# Create test bucket
178+
mc mb minio/smartquery-files || echo "Bucket already exists"
179+
126180
- name: Start backend server
127181
working-directory: ./backend
128182
run: |
129183
uvicorn main:app --host 0.0.0.0 --port 8000 &
130-
sleep 10
184+
sleep 15
131185
env:
132186
DATABASE_URL: postgresql://postgres:test@localhost:5432/smartquery_test
187+
REDIS_URL: redis://localhost:6379
188+
MINIO_ENDPOINT: localhost:9000
189+
MINIO_ACCESS_KEY: test-access-key
190+
MINIO_SECRET_KEY: test-secret-key
191+
MINIO_BUCKET_NAME: smartquery-files
192+
MINIO_SECURE: "false"
133193
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY || 'test-key' }}
194+
TESTING: true
134195

135196
- name: Run integration tests
136197
working-directory: ./frontend
@@ -140,7 +201,19 @@ jobs:
140201

141202
- name: Health check
142203
run: |
204+
# Check backend API
143205
curl -f http://localhost:8000/health || exit 1
206+
207+
# Check PostgreSQL
208+
pg_isready -h localhost -p 5432 -U postgres || exit 1
209+
210+
# Check Redis
211+
redis-cli -h localhost -p 6379 ping || exit 1
212+
213+
# Check MinIO
214+
curl -f http://localhost:9000/minio/health/live || exit 1
215+
216+
echo "All services are healthy!"
144217
145218
# Security Checks
146219
security:

backend/api/chat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
SendMessageRequest,
1717
SendMessageResponse,
1818
)
19-
from services.project_service import get_project_service
2019
from services.langchain_service import langchain_service
20+
from services.project_service import get_project_service
2121

2222
router = APIRouter(prefix="/chat", tags=["chat"])
2323
project_service = get_project_service()

0 commit comments

Comments
 (0)