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
59 changes: 59 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Spring Boot Student Management App CI/CD

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

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

# Spin up Postgres for integration tests
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: smsdb_test
POSTGRES_PASSWORD: pass123
POSTGRES_USER: admin
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

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

- name: Set up JDK 21 (matches your pom.xml)
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven

- name: Make Maven Wrapper executable
run: chmod +x mvnw

- name: Run Tests with Maven Wrapper
run: ./mvnw clean test
env:
# Match your application.properties/docker-compose settings
SPRING_DATASOURCE_URL: jdbc:postgresql://localhost:5432/smsdb_test
SPRING_DATASOURCE_USERNAME: admin
SPRING_DATASOURCE_PASSWORD: pass123
SPRING_JPA_HIBERNATE_DDL_AUTO: update
SPRING_JPA_SHOW_SQL: false

- name: Build JAR with Maven Wrapper
run: ./mvnw clean package -DskipTests

- name: Verify JAR file
run: |
ls -la target/*.jar
echo "Build completed successfully!"
51 changes: 0 additions & 51 deletions init.sql
Original file line number Diff line number Diff line change
@@ -1,54 +1,3 @@
-- Create users table
CREATE TABLE users (
id SERIAL PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
password VARCHAR(100) NOT NULL,
email VARCHAR(100) UNIQUE NOT NULL,
role VARCHAR(20) NOT NULL CHECK (role IN ('STUDENT', 'TEACHER')),
enabled BOOLEAN DEFAULT TRUE
);

-- Create departments table
CREATE TABLE departments (
id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL UNIQUE,
code VARCHAR(10) NOT NULL UNIQUE
);

-- Create teachers table
CREATE TABLE teachers (
id SERIAL PRIMARY KEY,
user_id INTEGER UNIQUE REFERENCES users(id) ON DELETE CASCADE,
department_id INTEGER REFERENCES departments(id),
employee_id VARCHAR(20) UNIQUE NOT NULL
);

-- Create students table
CREATE TABLE students (
id SERIAL PRIMARY KEY,
user_id INTEGER UNIQUE REFERENCES users(id) ON DELETE CASCADE,
department_id INTEGER REFERENCES departments(id),
student_id VARCHAR(20) UNIQUE NOT NULL,
phone VARCHAR(20),
address TEXT
);

-- Create courses table
CREATE TABLE courses (
id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL,
code VARCHAR(20) UNIQUE NOT NULL,
teacher_id INTEGER REFERENCES teachers(id),
department_id INTEGER REFERENCES departments(id)
);

-- Create student_courses table (Many-to-Many)
CREATE TABLE student_courses (
student_id INTEGER REFERENCES students(id) ON DELETE CASCADE,
course_id INTEGER REFERENCES courses(id) ON DELETE CASCADE,
PRIMARY KEY (student_id, course_id)
);

-- Insert sample departments
INSERT INTO departments (name, code) VALUES
('Computer Science', 'CS'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.shuvocse21.StudentManagementApp.controller;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class StudentControllerTest {

@Test
void profile() {
}

@Test
void updateProfile() {
}
}