diff --git a/.github/workflows/jacoco.yml b/.github/workflows/jacoco.yml new file mode 100644 index 0000000..5776c7b --- /dev/null +++ b/.github/workflows/jacoco.yml @@ -0,0 +1,41 @@ +name: PR Test + +on: + pull_request: + types: [ opened, synchronize, reopened ] + +permissions: write-all + +jobs: + test: + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + + - name: Create .env file for CI environment + run: echo "${{ secrets.ENV_FILE_CONTENT }}" > .env + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Test with Gradle + run: ./gradlew test + + - name: Test Coverage Report + id: jacoco + uses: madrapps/jacoco-report@v1.7.1 + with: + title: Test Coverage Report + paths: ${{ github.workspace }}/build/reports/jacoco/test/jacocoTestReport.xml + token: ${{ secrets.GITHUB_TOKEN }} + min-coverage-overall: 50 + min-coverage-changed-files: 70 diff --git a/build.gradle b/build.gradle index 4c3876a..aa235ab 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ plugins { id 'java' id 'org.springframework.boot' version '3.4.5' id 'io.spring.dependency-management' version '1.1.7' + id 'jacoco' } group = 'run' @@ -38,3 +39,28 @@ dependencies { tasks.named('test') { useJUnitPlatform() } + +test { + finalizedBy jacocoTestReport +} + +jacoco { + toolVersion = "0.8.12" +} + +jacocoTestReport { + dependsOn test + reports { + xml.required.set(true) + } + afterEvaluate { + classDirectories.setFrom( + files(classDirectories.files.collect { + fileTree(dir: it, exclude: [ + '**/Q*.class', + '**/run/backend/BackendApplication.class' + ]) + }) + ) + } +} \ No newline at end of file diff --git a/lombok.config b/lombok.config new file mode 100644 index 0000000..7a21e88 --- /dev/null +++ b/lombok.config @@ -0,0 +1 @@ +lombok.addLombokGeneratedAnnotation = true diff --git a/src/test/java/run/backend/BackendApplicationTests.java b/src/test/java/run/backend/BackendApplicationTests.java deleted file mode 100644 index d9e66dd..0000000 --- a/src/test/java/run/backend/BackendApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package run.backend; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class BackendApplicationTests { - - @Test - void contextLoads() { - } - -}