Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 테스트 커버리지 측정 자동화 #112

Merged
merged 4 commits into from
Nov 14, 2024
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
18 changes: 17 additions & 1 deletion .github/workflows/pr_weekly_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: 빌드 테스트 수행
run: |
chmod +x ./gradlew
./gradlew clean build --build-cache --stacktrace
./gradlew clean build jacocoTestReport --build-cache --stacktrace

- name: 테스트 수행 결과 보고
uses: EnricoMi/publish-unit-test-result-action@v2
Expand All @@ -67,3 +67,19 @@ jobs:
with:
report_paths: '**/build/test-results/test/TEST-*.xml'
token: ${{ github.token }}

- name: JaCoCo 테스트 커버리지 리포트 업로드
uses: actions/upload-artifact@v3
if: always()
with:
name: jacoco-report
path: '**/build/reports/jacoco/'

- name: JaCoCo 테스트 커버리지 결과를 PR에 코멘트로 등록
uses: madrapps/[email protected]
with:
paths: ${{ github.workspace }}/build/reports/jacoco/test/jacocoTestReport.xml
token: ${{ github.token }}
min-coverage-overall: 70
min-coverage-changed-files: 70
title: '📊 테스트 커버리지 리포트'
39 changes: 39 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'java'
id 'jacoco'
id 'org.springframework.boot' version '3.3.3'
id 'io.spring.dependency-management' version '1.1.6'
}
Expand Down Expand Up @@ -51,3 +52,41 @@ dependencies {
tasks.named('test') {
useJUnitPlatform()
}

jacocoTestReport {
dependsOn test // 테스트 실행 후 리포트 생성을 보장

reports {
xml.required = true
html.required = true
}

afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
'**/constant/**',
'**/config/**',
'**/dto/**',
'**/security/**',
'**/exception/**',
'**/*Application.class'
])
}))
}
}

test {
useJUnitPlatform()
finalizedBy jacocoTestReport
}

// 테스트 커버리지 최소 기준 설정
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.70
}
}
}
}
Loading