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
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Python CI

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

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.11"

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

- name: Syntax check
run: python -m py_compile $(find . -name "*.py")
30 changes: 30 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Docker Build & Push

on:
push:
branches: [ "main" ]
workflow_dispatch:

jobs:
docker:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build & Push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: aryansharma04/systemmonitoring:latest
cache-from: type=registry,ref=aryansharma04/systemmonitoring:cache
cache-to: type=registry,ref=aryansharma04/systemmonitoring:cache,mode=max
44 changes: 0 additions & 44 deletions .github/workflows/docker-image.yml

This file was deleted.

30 changes: 15 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
# Use full Python image (not slim) to avoid missing system libs
FROM python:3.11
# ---------- Stage 1: Build dependencies ----------
FROM python:3.11-slim AS builder

# Set working directory
WORKDIR /app

# Install required system dependencies for pandas & scikit-learn
RUN apt-get update && apt-get install -y \
gcc \
g++ \
make \
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libopenblas-dev \
liblapack-dev \
gfortran \
&& rm -rf /var/lib/apt/lists/*

# Copy requirements first to leverage Docker cache
COPY req.txt .

# Upgrade pip and install Python dependencies
RUN pip install --upgrade pip setuptools wheel --no-cache-dir \
&& pip install --no-cache-dir -r req.txt
RUN pip install --upgrade pip \
&& pip install --no-cache-dir -r req.txt \
&& pip install --no-cache-dir uvicorn

# Copy application files
# ---------- Stage 2: Final lightweight image ----------
FROM python:3.11-slim

WORKDIR /app

# Copy only installed packages (fast!)
COPY --from=builder /usr/local /usr/local

# Copy app code
COPY . .

# Expose FastAPI port
EXPOSE 8000

# Run FastAPI app
CMD ["uvicorn", "apps:app", "--host", "0.0.0.0", "--port", "8000"]
1 change: 1 addition & 0 deletions SystemMonitoring
Submodule SystemMonitoring added at 93769c
Binary file added __pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file added __pycache__/apps.cpython-312.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import os
import sys

# Get the parent directory of tests (project root)
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, project_root)
4 changes: 4 additions & 0 deletions tests/test_data_processing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def test_sample_data():
data = [1, 2, 3]
result = sum(data)
assert result == 6
17 changes: 17 additions & 0 deletions tests/test_endpoints.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from fastapi.testclient import TestClient
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from apps import app

client = TestClient(app)

def test_root_endpoint():
response = client.get("/")
assert response.status_code == 200
assert response.json() == {"message": "Hello World"} # matches your code

def test_health_endpoint():
response = client.get("/health")
assert response.status_code == 200
assert response.json() == {"status": "ok"} # matches your code
4 changes: 4 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def test_integration_example():
x = 5
y = 10
assert x + y == 15
Loading