Skip to content

Commit

Permalink
Merge pull request #3 from everymeals/chore/project-setting
Browse files Browse the repository at this point in the history
[chore/project-setting] Jacoco 설정
  • Loading branch information
dldmsql committed Jul 9, 2023
2 parents f9df265 + bc592a9 commit eca6c77
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Build and analyze
run: ./gradlew build sonar --info
run: ./gradlew test sonar --info
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
51 changes: 51 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id 'org.springframework.boot' version '3.1.1'
id 'io.spring.dependency-management' version '1.1.0'
id "org.sonarqube" version "4.2.1.3168"
id 'jacoco'
}

group = 'everymeal'
Expand All @@ -17,6 +18,8 @@ sonar {
property 'sonar.language', 'java'
property 'sonar.sourceEncoding', 'UTF-8'
property "sonar.exclusions", "**/*Application*.java"
property "sonar.java.coveragePlugin", "jacoco"
property 'sonar.coverage.jacoco.xmlReportPaths', 'build/reports/jacoco/test/jacocoTestReport.xml'
}
}

Expand All @@ -36,4 +39,52 @@ dependencies {

tasks.named('test') {
useJUnitPlatform()
outputs.dir snippetsDir
finalizedBy 'jacocoTestReport'
}
ext {
snippetsDir = file('build/generated-snippets')
}
jacocoTestReport {
reports {
xml.required = true
html.required = true
}

afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
"**/*Application*",
"**/config/*"
])
}))
}

finalizedBy 'jacocoTestCoverageVerification'
}
jacocoTestCoverageVerification {
violationRules {
rule {
enabled = true // rule을 on/off
element = "CLASS" // class 단위로 rule 체크
limit { // 라인 커버리지 최소 80% 충족
counter = "LINE"
value = "COVEREDRATIO"
minimum = "0.80".toBigDecimal()
}
limit {// 빈 줄 제외한 코드 라인수 최대 1000라인으로 제한한다.
counter = "LINE"
value = "TOTALCOUNT"
maximum = "1000.0".toBigDecimal()
}
}
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
"**/*Application*",
"**/config/*"
])
}))
}
}

0 comments on commit eca6c77

Please sign in to comment.