From b00867647d58b6d2229b12d0d8869cbb333f9261 Mon Sep 17 00:00:00 2001 From: dldmsql Date: Sun, 9 Jul 2023 11:04:29 +0900 Subject: [PATCH 1/2] =?UTF-8?q?chore:=20jacoco=20=ED=94=8C=EB=9F=AC?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/build.gradle b/build.gradle index d947d4b..ec5a348 100644 --- a/build.gradle +++ b/build.gradle @@ -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' @@ -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' } } @@ -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/*" + ]) + })) + } } From bc592a9f4c65432f88a2b70478f5b61e58ea1693 Mon Sep 17 00:00:00 2001 From: dldmsql Date: Sun, 9 Jul 2023 11:04:54 +0900 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20jacoco=20=ED=94=8C=EB=9F=AC?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=EC=84=A4=EC=A0=95=EC=97=90=20=EB=94=B0?= =?UTF-8?q?=EB=A5=B8=20=EB=B6=84=EC=84=9D=20=EB=AA=85=EB=A0=B9=EC=96=B4=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sonar.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml index c07ea60..2a1e964 100644 --- a/.github/workflows/sonar.yml +++ b/.github/workflows/sonar.yml @@ -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 }}