Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
100 changes: 100 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: CI Pipeline

on:
push:
<<<<<<< HEAD
branches: [ develop, feature/** ]
pull_request:
branches: [ main ]
=======
branches:
- develop
- feature/**
pull_request:
branches:
- main
>>>>>>> 9b0ad7e257c8a7a075c4dab0a3aba57ec30bbcd7

jobs:
build-and-test:
runs-on: ubuntu-latest

<<<<<<< HEAD
services:
postgres:
image: postgres:13
env:
POSTGRES_DB: test
POSTGRES_USER: test
POSTGRES_PASSWORD: test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

=======
>>>>>>> 9b0ad7e257c8a7a075c4dab0a3aba57ec30bbcd7
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
<<<<<<< HEAD
python-version: '3.12'
=======
python-version: '3.10'

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
>>>>>>> 9b0ad7e257c8a7a075c4dab0a3aba57ec30bbcd7

- name: Install backend dependencies
run: |
cd backend
<<<<<<< HEAD
python -m venv venv
source venv/bin/activate
=======
python -m pip install --upgrade pip
>>>>>>> 9b0ad7e257c8a7a075c4dab0a3aba57ec30bbcd7
pip install -r requirements.txt

- name: Run backend tests
run: |
cd backend
<<<<<<< HEAD
source venv/bin/activate
pytest tests/

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
=======
PYTHONPATH=. pytest
>>>>>>> 9b0ad7e257c8a7a075c4dab0a3aba57ec30bbcd7

- name: Install frontend dependencies
run: |
cd frontend
npm install

<<<<<<< HEAD
- name: Run frontend build (to validate)
run: |
cd frontend
npm run build
=======
- name: Build frontend
run: |
cd frontend
npm run build

>>>>>>> 9b0ad7e257c8a7a075c4dab0a3aba57ec30bbcd7
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
.next/
5 changes: 5 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
__pycache__/
*.pyc
*.pyo
*.pyd
.env
13 changes: 13 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Stage 1: Build
FROM python:3.12-slim AS builder
WORKDIR /app
COPY requirements.txt .
RUN pip install --upgrade pip && pip install --user -r requirements.txt

# Stage 2: Run
FROM python:3.12-slim
WORKDIR /app
COPY --from=builder /root/.local /root/.local
COPY app/ ./app/
ENV PATH=/root/.local/bin:$PATH
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
Binary file added backend/app/__pycache__/main.cpython-312.pyc
Binary file not shown.
4 changes: 4 additions & 0 deletions backend/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# backend/pytest.ini
[pytest]
pythonpath = .

4 changes: 4 additions & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ fastapi==0.104.1
uvicorn==0.24.0
pydantic==2.4.2
python-dotenv==1.0.0
pytest
httpx==0.27.0
starlette==0.27.0

Binary file added backend/tests/.test_main.py.swp
Binary file not shown.
Binary file not shown.
Binary file not shown.
17 changes: 17 additions & 0 deletions backend/tests/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from fastapi.testclient import TestClient
from app.main import app

client = TestClient(app)

def test_health_check():
response = client.get("/api/health")
assert response.status_code == 200
assert response.json() == {
"status": "healthy",
"message": "Backend is running successfully"
}

def test_message_endpoint():
response = client.get("/api/message")
assert response.status_code == 200
assert "message" in response.json()
Loading