Skip to content
Closed
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
8 changes: 4 additions & 4 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v4.2.2

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
uses: docker/login-action@v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push backend
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6.9.0
with:
context: ./backend
push: true
Expand All @@ -35,7 +35,7 @@ jobs:
ghcr.io/crms-devops/crms-backend:${{ github.sha }}

- name: Build and push frontend
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6.9.0
with:
context: ./frontend
push: true
Expand Down
21 changes: 11 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v4.2.2

- name: Set up Python 3.13
uses: actions/setup-python@v5
uses: actions/setup-python@v5.3.0
with:
python-version: "3.13"

- name: Cache pip packages
uses: actions/cache@v4
uses: actions/cache@v4.2.0
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('backend/requirements.txt') }}
Expand All @@ -54,20 +54,21 @@ jobs:
SECRET_KEY: test-secret-key
ALGORITHM: HS256
ACCESS_TOKEN_EXPIRE_MINUTES: 60
PYTHONPATH: /home/runner/work/crms/crms/backend
run: |
cd backend
pytest tests/ -v --tb=short
python -m pytest tests/ -v --tb=short

frontend-lint:
name: Frontend — ESLint
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v4.2.2

- name: Set up Node 20
uses: actions/setup-node@v4
uses: actions/setup-node@v4.1.0
with:
node-version: "20"
cache: "npm"
Expand All @@ -90,21 +91,21 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v4.2.2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v3.7.1

- name: Build backend image
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6.9.0
with:
context: ./backend
push: false
tags: crms-backend:${{ github.sha }}
load: true

- name: Build frontend image
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6.9.0
with:
context: ./frontend
push: false
Expand Down
8 changes: 5 additions & 3 deletions backend/app/core/database.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm import sessionmaker, declarative_base
import os
from dotenv import load_dotenv

load_dotenv()

DATABASE_URL = os.getenv("DATABASE_URL", "postgresql://postgres:password@localhost:5432/crms_dev")
DATABASE_URL = os.getenv(
"DATABASE_URL",
"postgresql://postgres:password@localhost:5432/crms_dev"
)

engine = create_engine(DATABASE_URL)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Expand Down
7 changes: 3 additions & 4 deletions backend/app/schemas/auth.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from pydantic import BaseModel
from pydantic import BaseModel, ConfigDict
from datetime import date

class StudentLoginRequest(BaseModel):
register_number: str
date_of_birth: date

class StudentInfo(BaseModel):
model_config = ConfigDict(from_attributes=True)

register_number: str
name: str
degree: str
Expand All @@ -14,9 +16,6 @@ class StudentInfo(BaseModel):
regulation_year: int
current_semester: int

class Config:
from_attributes = True

class LoginResponse(BaseModel):
access_token: str
token_type: str = "bearer"
Expand Down
13 changes: 7 additions & 6 deletions backend/app/schemas/result.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
from pydantic import BaseModel
from pydantic import BaseModel, ConfigDict
from typing import List, Optional
from datetime import datetime


class ResultItem(BaseModel):
model_config = ConfigDict(from_attributes=True)

semester: int
subject_code: str
subject_name: str
subject_type: str
grade: Optional[str]
marks_obtained: Optional[float]
grade: Optional[str] = None
marks_obtained: Optional[float] = None
result_status: str
attempt_number: int

class Config:
from_attributes = True

class ExamSessionInfo(BaseModel):
display_label: str
session_name: str
exam_year: int


class ResultsResponse(BaseModel):
student_name: str
register_number: str
Expand Down
13 changes: 13 additions & 0 deletions backend/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import pytest
from fastapi.testclient import TestClient
from app.main import app
from app.core.database import engine, Base

from app.models.student import Student, Branch, Regulation
from app.models.result import Result, Subject, ExamSession


@pytest.fixture(scope="session", autouse=True)
def create_tables():
"""Create all tables before tests run, drop after."""
Base.metadata.create_all(bind=engine)
yield
Base.metadata.drop_all(bind=engine)


@pytest.fixture
def client():
Expand Down
Loading