diff --git a/.github/workflows/pr_test.yml b/.github/workflows/pr_test.yml new file mode 100644 index 0000000..38b11fd --- /dev/null +++ b/.github/workflows/pr_test.yml @@ -0,0 +1,41 @@ +name: PR Test + +on: + pull_request: + branches: [ develop ] + +permissions: write-all + +jobs: + test: + # 실행 환경 + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + + # JDK 17 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + # ./gradlew 권한 설정 + - name: ./gradlew 권한 설정 + run: chmod +x ./gradlew + + # Gradle 테스트 수행 + - name: ./gradlew 테스트 + run: ./gradlew --info test + + # Jacoco Test Coverage Report + - name: Test Coverage Report + id: jacoco + uses: madrapps/jacoco-report@v1.6 + with: + title: Test Coverage Report + paths: ${{ github.workspace }}/build/reports/jacoco/test/jacocoTestReport.xml + token: ${{ secrets.GITHUB_TOKEN }} + min-coverage-overall: 70 + min-coverage-changed-files: 70 \ No newline at end of file diff --git a/build.gradle b/build.gradle index 6abfae4..fd989aa 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,7 @@ plugins { id 'org.springframework.boot' version '3.1.9' id 'io.spring.dependency-management' version '1.1.4' id "org.asciidoctor.jvm.convert" version "3.3.2" + id 'jacoco' } group = 'com' @@ -131,3 +132,35 @@ bootJar { } } // ------------------- + +// Jacoco 설정 ------------------- +test { + finalizedBy jacocoTestReport + useJUnitPlatform() +} + +jacoco { + toolVersion = "0.8.8" +} + +jacocoTestReport { + dependsOn test + + afterEvaluate { // report 작성 시 특정 파일 제외 + classDirectories.setFrom(files(classDirectories.files.collect { + fileTree(dir: it, + exclude: ['**/JisunginApplication', + '**/*Request*', + '**/*Response*', + 'com/jisungin/config/**', + 'com/jisungin/exception/**', + 'com/jisungin/infra/**', + 'com/jisungin/trace/**']) + })) + } + + reports { + xml.required.set(true) + } +} +// ------------------- \ No newline at end of file diff --git a/lombok.config b/lombok.config new file mode 100644 index 0000000..8f7e8aa --- /dev/null +++ b/lombok.config @@ -0,0 +1 @@ +lombok.addLombokGeneratedAnnotation = true \ No newline at end of file