Skip to content

Commit

Permalink
Merge branch 'dev' into feature/YS-37
Browse files Browse the repository at this point in the history
  • Loading branch information
Ji-soo708 authored Dec 31, 2024
2 parents 763e74d + 910db21 commit 085dcfb
Show file tree
Hide file tree
Showing 15 changed files with 624 additions and 21 deletions.
27 changes: 22 additions & 5 deletions .github/workflows/ci-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,37 @@ on:
- dev

jobs:
build:
test:
name: Code Quality Check
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew clean build
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: check
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' }}

- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew build sonar --info
89 changes: 88 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ plugins {
kotlin("plugin.spring") version "1.9.25"
id("org.springframework.boot") version "3.4.1"
id("io.spring.dependency-management") version "1.1.7"
id("jacoco")
id("org.sonarqube") version "6.0.1.5171"
kotlin("plugin.jpa") version "1.9.25"
}

Expand All @@ -11,7 +13,7 @@ version = "0.0.1-SNAPSHOT"

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
languageVersion.set(JavaLanguageVersion.of(17))
}
}

Expand Down Expand Up @@ -39,6 +41,7 @@ dependencies {
implementation("com.github.f4b6a3:ulid-creator:5.2.3")
implementation("org.mariadb.jdbc:mariadb-java-client:2.7.3")
implementation ("io.awspring.cloud:spring-cloud-starter-aws:2.4.4")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0")
compileOnly("org.projectlombok:lombok")
runtimeOnly("com.mysql:mysql-connector-j")
runtimeOnly("com.h2database:h2")
Expand Down Expand Up @@ -72,6 +75,90 @@ allOpen {
annotation("jakarta.persistence.Embeddable")
}

jacoco {
toolVersion = "0.8.8"
}

tasks.withType<Test> {
useJUnitPlatform()
finalizedBy(tasks.jacocoTestReport)
}

sonar {
properties {
property("sonar.projectKey", "YAPP-Github_25th-Web-Team-2-BE")
property("sonar.organization", "yapp-github")
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco/index.xml")
property("sonar.sources", "src/main/kotlin")
property("sonar.sourceEncoding", "UTF-8")
property("sonar.exclusions", "**/test/**, **/resources/**, **/*Application*.kt, **/*Controller*.kt, " +
"**/*Config.kt, **/*Entity*.kt, **/*Repository*.kt, **/*Dto*.kt, **/*Response*.kt, **/*Request*.kt, **/*Exception*.kt," +
"**/*Filter.kt, **/*Handler.kt, **/*Properties.kt, **/*Utils.kt")
property("sonar.test.inclusions", "**/*Test.kt")
property("sonar.kotlin.coveragePlugin", "jacoco")
}
}

tasks.jacocoTestReport {
dependsOn(tasks.test)
reports{
html.required.set(true)
xml.required.set(true)
html.outputLocation.set(file(layout.buildDirectory.dir("reports/jacoco/index.html").get().asFile))
xml.outputLocation.set(file(layout.buildDirectory.dir("reports/jacoco/index.xml").get().asFile))
}

classDirectories.setFrom(
files(
classDirectories.files.flatMap { dir ->
fileTree(dir) {
exclude(
"**/*Application*",
"**/config/*",
"**/domain/exception/*",
"**/domain/gateway/*",
"**/domain/model/*",
"**/infrastructure/*",
"**/presentation/*",
"**/util/*"
)
}.files
}
)
)
finalizedBy(tasks.jacocoTestCoverageVerification)
}

tasks.jacocoTestCoverageVerification {
violationRules {
rule {
isFailOnViolation = false
isEnabled = true
element = "CLASS"

limit {
counter = "LINE"
value = "COVEREDRATIO"
minimum = 0.70.toBigDecimal()
}

limit {
counter = "BRANCH"
value = "COVEREDRATIO"
minimum = 0.70.toBigDecimal()
}

excludes = listOf(
"**.*Application*",
"**.config.*",
"**.domain.exception.*",
"**.domain.gateway.*",
"**.domain.model.*",
"**.infrastructure.*",
"**.presentation.*",
"**.util.*"
)
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.dobby.backend.infrastructure.database.entity

import AuditingEntity
import com.dobby.backend.infrastructure.database.entity.enum.MemberStatus
import com.dobby.backend.infrastructure.database.entity.enum.ProviderType
import com.dobby.backend.infrastructure.database.entity.enum.RoleType
import jakarta.persistence.*
import java.time.LocalDate

@Entity(name = "member")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "role_type")
open class Member (
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
val id: Long,

@Column(name = "oauth_email", length = 100, nullable = false, unique = true)
val oauthEmail : String,

@Column(name = "oauth_provider", nullable = false)
@Enumerated(EnumType.STRING)
val provider : ProviderType,

@Column(nullable = false)
@Enumerated(EnumType.STRING)
var status: MemberStatus = MemberStatus.HOLD,

@Column(name = "role", nullable = true)
@Enumerated(EnumType.STRING)
val role: RoleType,

@Column(name = "contact_email", length = 100, nullable = false)
val contactEmail : String,

@Column(name = "name", length = 10, nullable = false)
val name : String,

@Column(name = "birth_date", nullable = false)
val birthDate : LocalDate,
) : AuditingEntity()
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.dobby.backend.infrastructure.database.entity

import com.dobby.backend.infrastructure.database.entity.enum.GenderType
import com.dobby.backend.infrastructure.database.entity.enum.MatchType
import com.dobby.backend.infrastructure.database.entity.enum.ProviderType
import com.dobby.backend.infrastructure.database.entity.enum.RoleType
import com.dobby.backend.infrastructure.database.entity.enum.areaInfo.Area
import com.dobby.backend.infrastructure.database.entity.enum.areaInfo.Region
import jakarta.persistence.Column
import jakarta.persistence.DiscriminatorValue
import jakarta.persistence.Entity
import jakarta.persistence.EnumType
import jakarta.persistence.Enumerated
import java.time.LocalDate

@Entity(name = "participant")
@DiscriminatorValue("PARTICIPANT")
class Participant (
@Column(name = "gender", nullable = false)
@Enumerated(EnumType.STRING)
val gender: GenderType,

@Column(name = "basic_region", nullable = false)
@Enumerated(EnumType.STRING)
var basicRegion: Region,

@Column(name = "basic_area", nullable = false)
@Enumerated(EnumType.STRING)
var basicArea : Area,

@Column(name = "optional_region", nullable = true)
@Enumerated(EnumType.STRING)
var optionalRegion: Region,

@Column(name = "optional_area", nullable = true)
@Enumerated(EnumType.STRING)
var optionalArea: Area,

@Column(name = "prefer_type", nullable = true)
@Enumerated(EnumType.STRING)
var preferType: MatchType,

id: Long,
oauthEmail: String,
provider: ProviderType,
contactEmail: String,
name: String,
birthDate: LocalDate
) : Member(
id= id,
oauthEmail = oauthEmail,
provider = provider,
contactEmail= contactEmail,
role = RoleType.PARTICIPANT,
name = name,
birthDate = birthDate
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.dobby.backend.infrastructure.database.entity

import com.dobby.backend.infrastructure.database.entity.enum.ProviderType
import com.dobby.backend.infrastructure.database.entity.enum.RoleType
import jakarta.persistence.Column
import jakarta.persistence.DiscriminatorValue
import jakarta.persistence.Entity
import java.time.LocalDate

@Entity(name = "researcher")
@DiscriminatorValue("RESEARCHER")
class Researcher (
@Column(name = "univ_email", length = 100, nullable = false)
val univEmail : String,

@Column(name = "email_verified", nullable = false)
var emailVerified: Boolean = false,

@Column(name = "univ_name", length = 100, nullable = false)
val univName : String,

@Column(name = "major", length = 10, nullable = false)
val major : String,

@Column(name = "lab_info", length = 100, nullable = true)
val labInfo : String,

id: Long,
oauthEmail: String,
provider: ProviderType,
contactEmail: String,
name: String,
birthDate: LocalDate
) : Member(
id= id,
oauthEmail = oauthEmail,
provider = provider,
contactEmail= contactEmail,
role = RoleType.RESEARCHER,
name = name,
birthDate = birthDate
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import jakarta.persistence.Column
import jakarta.persistence.EntityListeners
import jakarta.persistence.MappedSuperclass
import org.springframework.data.annotation.CreatedDate
import org.springframework.data.annotation.LastModifiedDate
import org.springframework.data.jpa.domain.support.AuditingEntityListener
import java.time.LocalDateTime

@MappedSuperclass
@EntityListeners(AuditingEntityListener::class)
abstract class AuditingEntity {
@CreatedDate
@Column(name = "created_at", nullable = false, updatable = false)
lateinit var createdAt: LocalDateTime

@LastModifiedDate
@Column(name = "updated_at", nullable = false)
lateinit var updatedAt: LocalDateTime
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.dobby.backend.infrastructure.database.entity.enum

enum class GenderType {
MALE, FEMALE, SECRET
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.dobby.backend.infrastructure.database.entity.enum

enum class MatchType {
OFFLINE, ONLINE, HYBRID
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.dobby.backend.infrastructure.database.entity.enum

enum class MemberStatus {
HOLD,
ACTIVE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.dobby.backend.infrastructure.database.entity.enum

enum class ProviderType {
NAVER, GOOGLE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.dobby.backend.infrastructure.database.entity.enum

enum class RoleType {
RESEARCHER, PARTICIPANT
}
Loading

0 comments on commit 085dcfb

Please sign in to comment.