From add0a0cec8d52f56d181f92585294b6a208c3e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=A1=EC=98=81=EB=AF=BC?= Date: Sun, 26 Nov 2023 19:05:29 +0900 Subject: [PATCH 1/3] feat: add test coverage workflow --- .github/workflows/test.yaml | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 00000000..be8dba33 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,52 @@ +name: 테스트 커버리지 워크플로우 +on: + pull_request: + branches: + - master + - dev + - 'release/**' + +env: + COVERAGE_PERCENT: 30 + +jobs: + build: + runs-on: [ ubuntu-latest ] + steps: + - name: GitHub 에서 레포 받아오기 + uses: actions/checkout@v3 + + - name: JDK17 준비하기 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: 커버리지 측정하기 + run: | + chmod +x gradlew + ./gradlew --info test + + - name: 테스트 결과 업로드 + uses: EnricoMi/publish-unit-test-result-action@v1 + if: ${{ always() }} + with: + files: build/test-results/**/*.xml + + - name: 커버리지 결과 PR에 업로드 + id: jacoco + uses: madrapps/jacoco-report@v1.3 + with: + paths: ${{ github.workspace }}/build/reportsJaCoCo/test/jacocoTestReport.xml + token: ${{ secrets.GITHUB_TOKEN }} + min-coverage-overall: ${{ env.COVERAGE_PERCENT }} + debug-mode: false + title: Code Coverage + update-comment: true + + - name: ${{ env.COVERAGE_PERCENT }}% 이하 커버리지 블로킹 + if: ${{ steps.jacoco.outputs.coverage-overall < env.COVERAGE_PERCENT }} + uses: actions/github-script@v6 + with: + script: | + core.setFailed('Overall coverage is less than ${{ env.COVERAGE_PERCENT }}%!') From 5278a3d3250084353fa4be54827c5cde12befa85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=A1=EC=98=81=EB=AF=BC?= Date: Sun, 26 Nov 2023 19:06:43 +0900 Subject: [PATCH 2/3] feat: fix job name for test --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index be8dba33..8f88752c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -10,7 +10,7 @@ env: COVERAGE_PERCENT: 30 jobs: - build: + measure: runs-on: [ ubuntu-latest ] steps: - name: GitHub 에서 레포 받아오기 From 23856d2a5726ad8d4bfc81eb694a6f5da268b451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=A1=EC=98=81=EB=AF=BC?= Date: Sun, 26 Nov 2023 19:34:26 +0900 Subject: [PATCH 3/3] feat: add test coverage config --- .github/workflows/test.yaml | 11 +++++++---- build.gradle | 3 +++ config/build.gradle | 3 +++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8f88752c..75b53c2a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -25,19 +25,22 @@ jobs: - name: 커버리지 측정하기 run: | chmod +x gradlew - ./gradlew --info test + ./gradlew --info testCodeCoverageReport - name: 테스트 결과 업로드 - uses: EnricoMi/publish-unit-test-result-action@v1 + uses: EnricoMi/publish-unit-test-result-action@v2 if: ${{ always() }} with: - files: build/test-results/**/*.xml + files: | + common/build/test-results/**/*.xml + config/build/test-results/**/*.xml + member/build/test-results/**/*.xml - name: 커버리지 결과 PR에 업로드 id: jacoco uses: madrapps/jacoco-report@v1.3 with: - paths: ${{ github.workspace }}/build/reportsJaCoCo/test/jacocoTestReport.xml + paths: ${{ github.workspace }}/config/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml token: ${{ secrets.GITHUB_TOKEN }} min-coverage-overall: ${{ env.COVERAGE_PERCENT }} debug-mode: false diff --git a/build.gradle b/build.gradle index 2c3b0279..76d2cfa5 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ plugins { id 'java' id 'org.springframework.boot' version '3.1.5' id 'io.spring.dependency-management' version '1.1.3' + id 'jacoco-report-aggregation' } repositories { @@ -17,6 +18,7 @@ subprojects { apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' apply plugin: 'jacoco' + apply plugin: 'jacoco-report-aggregation' configurations { compileOnly { @@ -72,6 +74,7 @@ subprojects { violationRules { rule { + failOnViolation = false enabled = true element = 'CLASS' diff --git a/config/build.gradle b/config/build.gradle index 6bf3d626..301067cc 100644 --- a/config/build.gradle +++ b/config/build.gradle @@ -11,6 +11,9 @@ dependencies { implementation project(':common') implementation project(':member') + jacocoAggregation project(':common') + jacocoAggregation project(':member') + implementation 'org.flywaydb:flyway-core' implementation 'org.flywaydb:flyway-mysql' runtimeOnly 'com.h2database:h2'