From 42df8ef0bebecdb4c154fdb20955ab84f44d3a6f Mon Sep 17 00:00:00 2001 From: adorableco Date: Thu, 1 Aug 2024 21:20:12 +0900 Subject: [PATCH] =?UTF-8?q?Infra:=20GitAction=20yml=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit part of swm-106 related to: #110 --- .github/workflows/test-automation.yml | 46 +++++++++++++++++++ build.gradle.kts | 20 ++++++++ .../phote/service/WorkbookService.kt | 3 +- 3 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/test-automation.yml diff --git a/.github/workflows/test-automation.yml b/.github/workflows/test-automation.yml new file mode 100644 index 0000000..bbb0502 --- /dev/null +++ b/.github/workflows/test-automation.yml @@ -0,0 +1,46 @@ +name: test-automation + +on: + push: + branches: + - 'develop' + pull_request: + branches: + - 'develop' + +permissions: write-all + +jobs: + code-coverage: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Set up properties + run: | + cd src/main + mkdir resources + cd resources + touch application.properties + echo "${{ secrets.APPLICATION }}" > application.properties + cat application.properties + + shell: bash + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Test with Gradle + run: ./gradlew clean build test jacocoTestReport + + - name: Publish Unit Test Results + uses: EnricoMi/publish-unit-test-result-action@v1 + if: ${{ always() }} + with: + files: build/test-results/**/*.xml diff --git a/build.gradle.kts b/build.gradle.kts index 643d1ad..6e7755d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,10 +7,20 @@ plugins { kotlin("plugin.jpa") version "1.9.24" kotlin("jvm") version "1.9.24" kotlin("plugin.spring") version "1.9.24" + id("jacoco") // for querydsl kotlin("kapt") version "1.7.10" } + +subprojects { + apply(plugin = "jacoco") + + jacoco { + toolVersion = "0.8.6" + } +} + val queryDslVersion: String by extra group = "com.swm-standard" @@ -127,3 +137,13 @@ tasks.named("clean") { kapt { generateStubs = true } + +tasks.jacocoTestReport { + reports { + html.required.set(false) + xml.required.set(true) + csv.required.set(false) + + xml.outputLocation = file(project.layout.buildDirectory.dir("jacoco/index.xml")) + } +} diff --git a/src/main/kotlin/com/swm_standard/phote/service/WorkbookService.kt b/src/main/kotlin/com/swm_standard/phote/service/WorkbookService.kt index 90f8a39..a16944e 100644 --- a/src/main/kotlin/com/swm_standard/phote/service/WorkbookService.kt +++ b/src/main/kotlin/com/swm_standard/phote/service/WorkbookService.kt @@ -105,8 +105,7 @@ class WorkbookService( .findById(questionId) .getOrElse { throw NotFoundException(fieldName = "question", message = "id 를 재확인해주세요.") } - if (questionSetRepository - .existsByQuestionIdAndWorkbookId(questionId, workbook.id) + if (questionSetRepository.existsByQuestionIdAndWorkbookId(questionId, workbook.id) ) { throw AlreadyExistedException("questionId ($questionId)") }