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
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
86 changes: 85 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 @@ -71,6 +73,88 @@ 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, **/*Repository*.kt, **/*Dto*.kt, **/*Response*.kt, **/*Request*.kt, **/*Exception*.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.*"
)
}
}
}
Loading