From 5ac5b151a1abe739b80e1cdd7e86b0f0c36cccb0 Mon Sep 17 00:00:00 2001 From: wjdtkdgns Date: Mon, 13 Nov 2023 13:14:58 +0900 Subject: [PATCH 01/18] =?UTF-8?q?feat:=20=EA=B9=83=ED=97=99=20issue,=20pul?= =?UTF-8?q?l=20request=20=ED=83=AC=ED=94=8C=EB=A6=BF=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/issue-enhancement.md | 21 +++++++++++++++++ .github/ISSUE_TEMPLATE/issue-fix.md | 25 +++++++++++++++++++++ .github/ISSUE_TEMPLATE/issue-refactor.md | 20 +++++++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 8 +++++++ 4 files changed, 74 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/issue-enhancement.md create mode 100644 .github/ISSUE_TEMPLATE/issue-fix.md create mode 100644 .github/ISSUE_TEMPLATE/issue-refactor.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE/issue-enhancement.md b/.github/ISSUE_TEMPLATE/issue-enhancement.md new file mode 100644 index 00000000..366b93d8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/issue-enhancement.md @@ -0,0 +1,21 @@ +--- +name: 'Issue: Enhancement' +about: 새로운 기능 구현, 리팩토링과 관련된 이슈 템플릿 +title: "🤖 [FEATURE]" +labels: '' +assignees: '' + +--- + +# 🤖 기능 개요 + + +### ✅ Implement TODO + +- [ ] + +### 🚧 작업 브랜치 + + +### 📚 Remarks + diff --git a/.github/ISSUE_TEMPLATE/issue-fix.md b/.github/ISSUE_TEMPLATE/issue-fix.md new file mode 100644 index 00000000..ad8d9547 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/issue-fix.md @@ -0,0 +1,25 @@ +--- +name: 'Issue: Fix' +about: 에러 및 버그에 관련된 이슈 템플릿 +title: "🐞 [ERROR / BUG]" +labels: '' +assignees: '' + +--- + +# 🐞 에러 상황 설명 +### 📄 에러 대상 + + +### 🕵🏻‍♀️ 에러 상황 + + +### ✅ Resolve TODO + +- [ ] + +### 🚧 작업 브랜치 + + +### 📚 Remarks + diff --git a/.github/ISSUE_TEMPLATE/issue-refactor.md b/.github/ISSUE_TEMPLATE/issue-refactor.md new file mode 100644 index 00000000..ebd68118 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/issue-refactor.md @@ -0,0 +1,20 @@ +--- +name: "Issue: Refactor" +about: 리팩토링 시에 적는 템플릿 +title: "🔨[REFACTOR]" +labels: '' +assignees: '' + +--- + +# 🔨 리팩토링이 필요한 부분 + + +### ✅ refactoring TODO + + +### 🚧 작업 브랜치 + + +### 📚 Remarks + \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..5807a4ce --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,8 @@ +## 개요 +- close #issueNumber + +## 작업사항 +- 내용을 적어주세요. + +## 변경로직 +- 내용을 적어주세요. From d22f5ab0017f4c9ee11e884f1def743c8d9c4680 Mon Sep 17 00:00:00 2001 From: wjdtkdgns Date: Mon, 13 Nov 2023 13:28:44 +0900 Subject: [PATCH 02/18] =?UTF-8?q?feat:=20ktlint=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EC=A0=81=EC=9A=A9=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle.kts | 3 +++ .../boilerplate/config/database/BoilerPlateDatabaseConfig.kt | 4 ++-- src/main/kotlin/com/goofy/boilerplate/exception/ErrorCode.kt | 2 +- .../kotlin/com/goofy/boilerplate/extension/LoggerExtension.kt | 1 - .../goofy/boilerplate/health/presentation/HealthResource.kt | 1 - 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 5db8f139..0ce512b6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,6 +11,9 @@ plugins { kotlin("plugin.allopen") version kotlinVersion kotlin("kapt") version kotlinVersion idea + + /** ktlint **/ + id("org.jlleitschuh.gradle.ktlint") version "11.6.1" } group = "com.goofy" diff --git a/src/main/kotlin/com/goofy/boilerplate/config/database/BoilerPlateDatabaseConfig.kt b/src/main/kotlin/com/goofy/boilerplate/config/database/BoilerPlateDatabaseConfig.kt index 72d77580..22771635 100644 --- a/src/main/kotlin/com/goofy/boilerplate/config/database/BoilerPlateDatabaseConfig.kt +++ b/src/main/kotlin/com/goofy/boilerplate/config/database/BoilerPlateDatabaseConfig.kt @@ -51,7 +51,7 @@ class BoilerPlateDatabaseConfig { @Bean fun boilerplateNamedParameterJdbcTemplate( - @Qualifier("boilerplateMasterHikariDataSource") dataSource: DataSource, + @Qualifier("boilerplateMasterHikariDataSource") dataSource: DataSource ): NamedParameterJdbcTemplate { return NamedParameterJdbcTemplate(dataSource) } @@ -73,7 +73,7 @@ class BoilerPlateDatabaseConfig { return entityManagerFactoryBuilder .dataSource(boilerplateDataSource) .packages( - "com.goofy.boilerplate.user.domain", + "com.goofy.boilerplate.user.domain" ) .properties( mapOf(AvailableSettings.BEAN_CONTAINER to SpringBeanContainer(configurableListableBeanFactory)) diff --git a/src/main/kotlin/com/goofy/boilerplate/exception/ErrorCode.kt b/src/main/kotlin/com/goofy/boilerplate/exception/ErrorCode.kt index 245605ac..6133052d 100644 --- a/src/main/kotlin/com/goofy/boilerplate/exception/ErrorCode.kt +++ b/src/main/kotlin/com/goofy/boilerplate/exception/ErrorCode.kt @@ -10,6 +10,6 @@ enum class ErrorCode(val status: HttpStatus, val description: String) { METHOD_NOT_ALLOWED_ERROR(HttpStatus.METHOD_NOT_ALLOWED, "Method type is invalid"), INVALID_MEDIA_TYPE_ERROR(HttpStatus.BAD_REQUEST, "invalid media type"), QUERY_DSL_NOT_EXISTS_ERROR(HttpStatus.NOT_FOUND, "not found query dsl"), - COROUTINE_CANCELLATION_ERROR(HttpStatus.BAD_REQUEST, "coroutine cancellation error"), + COROUTINE_CANCELLATION_ERROR(HttpStatus.BAD_REQUEST, "coroutine cancellation error") ; } diff --git a/src/main/kotlin/com/goofy/boilerplate/extension/LoggerExtension.kt b/src/main/kotlin/com/goofy/boilerplate/extension/LoggerExtension.kt index d914bb8e..17ea6d48 100644 --- a/src/main/kotlin/com/goofy/boilerplate/extension/LoggerExtension.kt +++ b/src/main/kotlin/com/goofy/boilerplate/extension/LoggerExtension.kt @@ -11,4 +11,3 @@ fun KLogger.resolveCancellation(name: String, throwable: Throwable, other: (KLog } } } - diff --git a/src/main/kotlin/com/goofy/boilerplate/health/presentation/HealthResource.kt b/src/main/kotlin/com/goofy/boilerplate/health/presentation/HealthResource.kt index de0dec60..6ffb04fc 100644 --- a/src/main/kotlin/com/goofy/boilerplate/health/presentation/HealthResource.kt +++ b/src/main/kotlin/com/goofy/boilerplate/health/presentation/HealthResource.kt @@ -25,4 +25,3 @@ class HealthResource( profile = environment.activeProfiles.contentToString() ).wrapOk() } - From 5bb0223afc10391dfa53d4d62bd77ddc9b12bed7 Mon Sep 17 00:00:00 2001 From: wjdtkdgns Date: Mon, 13 Nov 2023 14:34:19 +0900 Subject: [PATCH 03/18] =?UTF-8?q?feat:=20github=20action=20ci=20workflow?= =?UTF-8?q?=20ktlint=20check=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80=20#?= =?UTF-8?q?1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CI.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/CI.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 00000000..bdb22bf9 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,38 @@ +name: CI + +on: + pull_request: + branches: + - develop + types: [ opened, synchronize, reopened ] + +jobs: + build: + name: CI + runs-on: ubuntu-latest + strategy: + matrix: + kotlin-version: [ "1.8.22" ] + java-version: [ "11" ] + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Kotlin + uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.java-version }} + kotlin-version: ${{ matrix.kotlin-version }} + distribution: 'adopt' + + # 자동 Ktlint 체크 자동화 + - name: ktlint + uses: ScaCap/action-ktlint@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-pr-check + ktlint_version: "1.8.22" +# fail_on_error: true # 오류 발생시 실패 \ No newline at end of file From 83b4bb8d10f65883884498461a4e325217567116 Mon Sep 17 00:00:00 2001 From: wjdtkdgns Date: Mon, 13 Nov 2023 15:40:14 +0900 Subject: [PATCH 04/18] =?UTF-8?q?feat:=20jacoco=20=EC=B6=94=EA=B0=80=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle.kts | 38 +++++++++++++++++++ .../com/goofy/boilerplate/example/Jacoco.kt | 10 +++++ .../com/goofy/boilerplate/ApplicationTests.kt | 13 +++++++ .../goofy/boilerplate/example/JacocoTest.kt | 18 +++++++++ 4 files changed, 79 insertions(+) create mode 100644 src/main/kotlin/com/goofy/boilerplate/example/Jacoco.kt create mode 100644 src/test/kotlin/com/goofy/boilerplate/ApplicationTests.kt create mode 100644 src/test/kotlin/com/goofy/boilerplate/example/JacocoTest.kt diff --git a/build.gradle.kts b/build.gradle.kts index 0ce512b6..7cca2389 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,6 +14,9 @@ plugins { /** ktlint **/ id("org.jlleitschuh.gradle.ktlint") version "11.6.1" + + /** jacoco **/ + id("jacoco") } group = "com.goofy" @@ -96,6 +99,12 @@ dependencies { implementation("io.github.microutils:kotlin-logging:${DependencyVersion.KOTLIN_LOGGING_VERSION}") implementation("net.logstash.logback:logstash-logback-encoder:${DependencyVersion.LOGBACK_ENCODER_VERSION}") + /** test **/ + testImplementation("org.springframework.boot:spring-boot-starter-test") + testImplementation("io.kotest:kotest-runner-junit5:5.7.2") + testImplementation("io.kotest:kotest-assertions-core:5.7.2") + testImplementation("io.kotest.extensions:kotest-extensions-spring:1.1.2") + /** etc */ developmentOnly("org.springframework.boot:spring-boot-devtools") } @@ -145,3 +154,32 @@ when { } val Project.isSnapshotVersion: Boolean get() = version.toString().endsWith("SNAPSHOT") + +tasks.test { + finalizedBy(tasks.jacocoTestReport) // 테스트 후 진행 +} + +tasks.jacocoTestReport { + dependsOn(tasks.test) // 테스트 선행 필요 + reports { + html.required.set(true) + csv.required.set(false) + xml.required.set(true) + xml.outputLocation.set(File("build/reports/jacoco.xml")) + } + + classDirectories.setFrom( + files(classDirectories.files.map { + fileTree(it) { + exclude("**/*Application*", + "**/*Config*", + "**/*Dto*", + "**/*Request*", + "**/*Response*", + "**/*Interceptor*", + "**/*Exception*" , + "**/Q*.class") // Query Dsl 용 + } + }) + ) +} \ No newline at end of file diff --git a/src/main/kotlin/com/goofy/boilerplate/example/Jacoco.kt b/src/main/kotlin/com/goofy/boilerplate/example/Jacoco.kt new file mode 100644 index 00000000..60b92fb6 --- /dev/null +++ b/src/main/kotlin/com/goofy/boilerplate/example/Jacoco.kt @@ -0,0 +1,10 @@ +package com.goofy.boilerplate.example + +import org.springframework.stereotype.Component + +@Component +class Jacoco { + fun jacocoTest(): String { + return "jacocoTest" + } +} \ No newline at end of file diff --git a/src/test/kotlin/com/goofy/boilerplate/ApplicationTests.kt b/src/test/kotlin/com/goofy/boilerplate/ApplicationTests.kt new file mode 100644 index 00000000..c934fd21 --- /dev/null +++ b/src/test/kotlin/com/goofy/boilerplate/ApplicationTests.kt @@ -0,0 +1,13 @@ +package com.goofy.boilerplate + +import org.junit.jupiter.api.Test +import org.springframework.boot.test.context.SpringBootTest + +@SpringBootTest +class ApplicationTests { + + @Test + fun contextLoads() { + } + +} diff --git a/src/test/kotlin/com/goofy/boilerplate/example/JacocoTest.kt b/src/test/kotlin/com/goofy/boilerplate/example/JacocoTest.kt new file mode 100644 index 00000000..59838a89 --- /dev/null +++ b/src/test/kotlin/com/goofy/boilerplate/example/JacocoTest.kt @@ -0,0 +1,18 @@ +package com.goofy.boilerplate.example + +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.equals.shouldBeEqual +import io.kotest.matchers.shouldBe +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.context.SpringBootTest + +@SpringBootTest +class JacocoTest @Autowired constructor( + private val jacoco: Jacoco +): FunSpec({ + context("jacoco test"){ + test("test1"){ + jacoco.jacocoTest() shouldBeEqual "jacocoTest" + } + } +}) \ No newline at end of file From 30acd9eddf2c8240c4960cb219701fe43a1536d5 Mon Sep 17 00:00:00 2001 From: wjdtkdgns Date: Mon, 13 Nov 2023 21:12:47 +0900 Subject: [PATCH 05/18] =?UTF-8?q?feat:=20jacoco=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20=EC=B6=94=EA=B0=80=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 + build.gradle.kts | 6 ++- docker-compose.yml | 17 +++++++ src/main/resources/config/application-dev.yml | 4 +- src/test/resources/config/application-dev.yml | 47 +++++++++++++++++++ src/test/resources/config/application.yml | 43 +++++++++++++++++ 6 files changed, 116 insertions(+), 3 deletions(-) create mode 100644 docker-compose.yml create mode 100644 src/test/resources/config/application-dev.yml create mode 100644 src/test/resources/config/application.yml diff --git a/.gitignore b/.gitignore index c2065bc2..bf0b45e7 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,5 @@ out/ ### VS Code ### .vscode/ + +mysqldata/ \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 7cca2389..e14fd822 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -155,6 +155,10 @@ when { val Project.isSnapshotVersion: Boolean get() = version.toString().endsWith("SNAPSHOT") +tasks.withType { + useJUnitPlatform() +} + tasks.test { finalizedBy(tasks.jacocoTestReport) // 테스트 후 진행 } @@ -165,7 +169,7 @@ tasks.jacocoTestReport { html.required.set(true) csv.required.set(false) xml.required.set(true) - xml.outputLocation.set(File("build/reports/jacoco.xml")) + xml.outputLocation.set(File("$buildDir/reports/jacoco.xml")) } classDirectories.setFrom( diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..0d5f85c3 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +version: '3.7' + +services: + mysql: + image: mysql + container_name: mysql + hostname: mysql + volumes: + - ./mysqldata:/var/lib/mysql + environment: + - MYSQL_USER=user + - MYSQL_PASSWORD=user + - MYSQL_ROOT_PASSWORD=root + - MYSQL_HOST=localhost + - MYSQL_PORT=3306 + ports: + - "3307:3306" \ No newline at end of file diff --git a/src/main/resources/config/application-dev.yml b/src/main/resources/config/application-dev.yml index 1e2e0c90..c119f8e3 100644 --- a/src/main/resources/config/application-dev.yml +++ b/src/main/resources/config/application-dev.yml @@ -30,9 +30,9 @@ spring: # DEV-DATABASE-COMMON datasource: &dev-datasource - url: jdbc:mysql://localhost:3306/boilerplate?useUnicode=true&charset=utf8mb4&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull + url: jdbc:mysql://localhost:3307/test?useUnicode=true&charset=utf8mb4&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull username: root - password: + password: root hikari: minimum-idle: 2 maximum-pool-size: 2 diff --git a/src/test/resources/config/application-dev.yml b/src/test/resources/config/application-dev.yml new file mode 100644 index 00000000..c119f8e3 --- /dev/null +++ b/src/test/resources/config/application-dev.yml @@ -0,0 +1,47 @@ +# =================================================================== +# Spring Boot Configuration for the dev profile +# =================================================================== + +# SERVER +server: + error: + include-exception: true # Include the "exception" attribute. + include-stacktrace: always # When to include a "stacktrace" attribute. + whitelabel.enabled: true + +# LOGGING +logging: + level: + root: INFO + com.goofy: DEBUG + org.hibernate.SQL: DEBUG + org.hibernate.type.descriptor.sql.BasicBinder: TRACE + org.springframework.jdbc.core.JdbcTemplate: DEBUG + org.springframework.jdbc.core.StatementCreatorUtils: TRACE + org.springframework.orm.jpa.JpaTransactionManager: DEBUG + org.springframework.web.server.adapter.HttpWebHandlerAdapter: DEBUG + reactor.netty.http.client: DEBUG + +# SPRING +spring: + jackson: + serialization: + indent_output: true + +# DEV-DATABASE-COMMON +datasource: &dev-datasource + url: jdbc:mysql://localhost:3307/test?useUnicode=true&charset=utf8mb4&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull + username: root + password: root + hikari: + minimum-idle: 2 + maximum-pool-size: 2 + +# DATABASE +boilerplate: + master.datasource: *dev-datasource + jpa: + properties: + hibernate.format_sql: true + hibernate.hbm2ddl.auto: none + maximum-jdbc-thread-pool-size: diff --git a/src/test/resources/config/application.yml b/src/test/resources/config/application.yml new file mode 100644 index 00000000..e402ce22 --- /dev/null +++ b/src/test/resources/config/application.yml @@ -0,0 +1,43 @@ +# =================================================================== +# Spring Boot Configuration for the default profile +# =================================================================== + +# SERVER +server: + port: 8080 + http2: + enabled: true + shutdown: graceful # timeout configuration property : spring.lifecycle.timeout-per-shutdown-phase + +# LOGGING +logging: + level: + root: INFO + +# SPRING +spring: + lifecycle: + timeout-per-shutdown-phase: 5s # format : https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-external-config-conversion-duration + application: + name: goofy-boilerplate + profiles: + active: dev + +# DATABASE +boilerplate: + master: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + jpa: + properties: + hibernate.default_batch_fetch_size: 10 + hibernate.cache.use_second_level_cache: false + hibernate.cache.use_query_cache: false + hibernate.order_inserts: true + hibernate.order_updates: true + hibrenate.jdbc.batch_size: 50 + hibernate.jdbc.batch_versioned_data: true + hibernate.jdbc.time_zone: Asia/Seoul + hibernate.hbm2ddl.auto: none + show-sql: false + database: mysql From a76c1ef128819773d5a99df37f678f77652c292b Mon Sep 17 00:00:00 2001 From: wjdtkdgns Date: Wed, 15 Nov 2023 00:49:49 +0900 Subject: [PATCH 06/18] =?UTF-8?q?feat:=20sonarcube=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CI.yml | 15 +++++++++++++-- build.gradle.kts | 23 +++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index bdb22bf9..60a8a28e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -29,10 +29,21 @@ jobs: distribution: 'adopt' # 자동 Ktlint 체크 자동화 - - name: ktlint + - name: ktlint check uses: ScaCap/action-ktlint@master with: github_token: ${{ secrets.GITHUB_TOKEN }} reporter: github-pr-check ktlint_version: "1.8.22" -# fail_on_error: true # 오류 발생시 실패 \ No newline at end of file +# fail_on_error: true # 오류 발생시 실패 + + # 빌드 + - name: Gradle Clean & Build + run: ./gradlew clean build + + # jacoco, sonarcube + - name: test and analyze + run: ./gradlew test sonar --info + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index e14fd822..512a7712 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,6 +17,9 @@ plugins { /** jacoco **/ id("jacoco") + + /** sonarqube **/ + id("org.sonarqube") version "4.4.1.3373" } group = "com.goofy" @@ -155,6 +158,7 @@ when { val Project.isSnapshotVersion: Boolean get() = version.toString().endsWith("SNAPSHOT") +/** jacoco **/ tasks.withType { useJUnitPlatform() } @@ -186,4 +190,23 @@ tasks.jacocoTestReport { } }) ) +} + +/** sonarqube **/ +sonarqube { + properties { + property("sonar.projectKey", "YAPP-Github_23rd_aos-1") + property("sonar.organization", "yapp-github") + property("sonar.host.url", "https://sonarcloud.io") + + // sonar additional settings + property("sonar.sources", "src") + property("sonar.language", "Kotlin") + property("sonar.sourceEncoding", "UTF-8") + property("sonar.test.inclusions", "**/*Test.java") + property("sonar.exclusions", "**/test/**, **/Q*.kt, **/*Doc*.kt, **/resources/** ,**/*Application*.kt , **/*Config*.kt, **/*Dto*.kt, **/*Request*.kt, **/*Response*.kt ,**/*Exception*.kt ,**/*ErrorCode*.kt") + property("sonar.java.coveragePlugin", "jacoco") + property("sonar.java.binaries", "$buildDir/classes") + property("sonar.coverage.jacoco.xmlReportPaths", "$buildDir/reports/jacoco.xml") + } } \ No newline at end of file From e13c73f7ffc0dcff11b39a66db56351afb7f0218 Mon Sep 17 00:00:00 2001 From: wjdtkdgns Date: Thu, 16 Nov 2023 00:19:40 +0900 Subject: [PATCH 07/18] =?UTF-8?q?feat:=20sonarcloud=20key=20=EC=97=85?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=8A=B8=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CI.yml | 4 ++-- build.gradle.kts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 60a8a28e..d0f23a05 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -32,7 +32,7 @@ jobs: - name: ktlint check uses: ScaCap/action-ktlint@master with: - github_token: ${{ secrets.GITHUB_TOKEN }} + github_token: ${{ secrets.GITHUBTOKEN }} reporter: github-pr-check ktlint_version: "1.8.22" # fail_on_error: true # 오류 발생시 실패 @@ -45,5 +45,5 @@ jobs: - name: test and analyze run: ./gradlew test sonar --info env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUBTOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 512a7712..0b9ff652 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -195,7 +195,7 @@ tasks.jacocoTestReport { /** sonarqube **/ sonarqube { properties { - property("sonar.projectKey", "YAPP-Github_23rd_aos-1") + property("sonar.projectKey", "YAPP-Github_23rd-Android-Team-1-BE") property("sonar.organization", "yapp-github") property("sonar.host.url", "https://sonarcloud.io") From 1e7d00b8f60463f3eeb9f375a60ae045d5bc9628 Mon Sep 17 00:00:00 2001 From: wjdtkdgns Date: Thu, 16 Nov 2023 00:28:00 +0900 Subject: [PATCH 08/18] =?UTF-8?q?chore:=20ktlint=20=EC=A0=81=EC=9A=A9=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle.kts | 26 +++++++++++-------- .../com/goofy/boilerplate/example/Jacoco.kt | 2 +- .../com/goofy/boilerplate/ApplicationTests.kt | 7 +++-- .../goofy/boilerplate/example/JacocoTest.kt | 11 ++++---- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 0b9ff652..a38ea4d2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -177,18 +177,22 @@ tasks.jacocoTestReport { } classDirectories.setFrom( - files(classDirectories.files.map { + files( + classDirectories.files.map { fileTree(it) { - exclude("**/*Application*", - "**/*Config*", - "**/*Dto*", - "**/*Request*", - "**/*Response*", - "**/*Interceptor*", - "**/*Exception*" , - "**/Q*.class") // Query Dsl 용 + exclude( + "**/*Application*", + "**/*Config*", + "**/*Dto*", + "**/*Request*", + "**/*Response*", + "**/*Interceptor*", + "**/*Exception*", + "**/Q*.class" + ) // Query Dsl 용 } - }) + } + ) ) } @@ -209,4 +213,4 @@ sonarqube { property("sonar.java.binaries", "$buildDir/classes") property("sonar.coverage.jacoco.xmlReportPaths", "$buildDir/reports/jacoco.xml") } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/goofy/boilerplate/example/Jacoco.kt b/src/main/kotlin/com/goofy/boilerplate/example/Jacoco.kt index 60b92fb6..2265fdb1 100644 --- a/src/main/kotlin/com/goofy/boilerplate/example/Jacoco.kt +++ b/src/main/kotlin/com/goofy/boilerplate/example/Jacoco.kt @@ -7,4 +7,4 @@ class Jacoco { fun jacocoTest(): String { return "jacocoTest" } -} \ No newline at end of file +} diff --git a/src/test/kotlin/com/goofy/boilerplate/ApplicationTests.kt b/src/test/kotlin/com/goofy/boilerplate/ApplicationTests.kt index c934fd21..7fdeac39 100644 --- a/src/test/kotlin/com/goofy/boilerplate/ApplicationTests.kt +++ b/src/test/kotlin/com/goofy/boilerplate/ApplicationTests.kt @@ -6,8 +6,7 @@ import org.springframework.boot.test.context.SpringBootTest @SpringBootTest class ApplicationTests { - @Test - fun contextLoads() { - } - + @Test + fun contextLoads() { + } } diff --git a/src/test/kotlin/com/goofy/boilerplate/example/JacocoTest.kt b/src/test/kotlin/com/goofy/boilerplate/example/JacocoTest.kt index 59838a89..acb35518 100644 --- a/src/test/kotlin/com/goofy/boilerplate/example/JacocoTest.kt +++ b/src/test/kotlin/com/goofy/boilerplate/example/JacocoTest.kt @@ -2,17 +2,16 @@ package com.goofy.boilerplate.example import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.equals.shouldBeEqual -import io.kotest.matchers.shouldBe import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest @SpringBootTest class JacocoTest @Autowired constructor( - private val jacoco: Jacoco -): FunSpec({ - context("jacoco test"){ - test("test1"){ + private val jacoco: Jacoco +) : FunSpec({ + context("jacoco test") { + test("test1") { jacoco.jacocoTest() shouldBeEqual "jacocoTest" } } -}) \ No newline at end of file +}) From 381ceb6aad7031321f1ec43f1a2e5f922bd695d0 Mon Sep 17 00:00:00 2001 From: wjdtkdgns Date: Thu, 16 Nov 2023 00:36:01 +0900 Subject: [PATCH 09/18] =?UTF-8?q?fix:=20ci=20workflow=20ktlint=5Fversion?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d0f23a05..81b36771 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -34,7 +34,7 @@ jobs: with: github_token: ${{ secrets.GITHUBTOKEN }} reporter: github-pr-check - ktlint_version: "1.8.22" + ktlint_version: "11.6.1" # fail_on_error: true # 오류 발생시 실패 # 빌드 From dd99c7e2603be27b30f97eb7959b04a3a1128755 Mon Sep 17 00:00:00 2001 From: wjdtkdgns Date: Thu, 16 Nov 2023 01:57:48 +0900 Subject: [PATCH 10/18] =?UTF-8?q?fix:=20=EB=A6=AC=EB=B7=B0=20=EB=B0=98?= =?UTF-8?q?=EC=98=81=20=EB=B0=8F=20workflow=20ktlint=20=EB=B2=84=EC=A0=84?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 4 ++++ .github/workflows/CI.yml | 2 +- build.gradle.kts | 8 +++++--- src/main/kotlin/com/goofy/boilerplate/Application.kt | 2 +- .../goofy/boilerplate/common/dto/ErrorResponse.kt | 2 +- .../com/goofy/boilerplate/common/dto/Response.kt | 2 +- .../config/database/BoilerPlateDatabaseConfig.kt | 8 ++++---- .../goofy/boilerplate/config/web/SpringDocConfig.kt | 2 +- .../goofy/boilerplate/config/web/WebFluxConfig.kt | 2 +- .../com/goofy/boilerplate/exception/ErrorCode.kt | 2 +- .../com/goofy/boilerplate/exception/Exceptions.kt | 2 +- .../boilerplate/exception/advice/ExceptionHandler.kt | 12 ++++++------ .../goofy/boilerplate/health/dto/HealthResponse.kt | 2 +- .../health/presentation/HealthResource.kt | 2 +- .../com/goofy/boilerplate/example/JacocoTest.kt | 2 +- 15 files changed, 30 insertions(+), 24 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..608dd57b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +[*.{kt,kts}] +insert_final_newline=true +ij_kotlin_allow_trailing_comma = true +# ij_kotlin_allow_trailing_comma_on_call_site = true \ No newline at end of file diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 81b36771..8eab1ed7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -34,7 +34,7 @@ jobs: with: github_token: ${{ secrets.GITHUBTOKEN }} reporter: github-pr-check - ktlint_version: "11.6.1" + ktlint_version: "0.50.0" # fail_on_error: true # 오류 발생시 실패 # 빌드 diff --git a/build.gradle.kts b/build.gradle.kts index a38ea4d2..4e40511f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -60,6 +60,8 @@ object DependencyVersion { const val JAVADOC_SCRIBE_VERSION = "0.15.0" const val KOTLIN_LOGGING_VERSION = "2.0.11" const val LOGBACK_ENCODER_VERSION = "6.6" + const val KOTEST_VERSION = "5.7.2" + const val KOTEST_EXTENSION_VERSION = "1.1.2" } dependencies { @@ -104,9 +106,9 @@ dependencies { /** test **/ testImplementation("org.springframework.boot:spring-boot-starter-test") - testImplementation("io.kotest:kotest-runner-junit5:5.7.2") - testImplementation("io.kotest:kotest-assertions-core:5.7.2") - testImplementation("io.kotest.extensions:kotest-extensions-spring:1.1.2") + testImplementation("io.kotest:kotest-runner-junit5:${DependencyVersion.KOTEST_VERSION}") + testImplementation("io.kotest:kotest-assertions-core:${DependencyVersion.KOTEST_VERSION}") + testImplementation("io.kotest.extensions:kotest-extensions-spring:${DependencyVersion.KOTEST_EXTENSION_VERSION}") /** etc */ developmentOnly("org.springframework.boot:spring-boot-devtools") diff --git a/src/main/kotlin/com/goofy/boilerplate/Application.kt b/src/main/kotlin/com/goofy/boilerplate/Application.kt index cb0fba06..4431371e 100644 --- a/src/main/kotlin/com/goofy/boilerplate/Application.kt +++ b/src/main/kotlin/com/goofy/boilerplate/Application.kt @@ -14,7 +14,7 @@ import java.util.* @SpringBootApplication class Application( private val buildProperties: BuildProperties, - private val environment: Environment + private val environment: Environment, ) : ApplicationListener { private val logger = mu.KotlinLogging.logger { } diff --git a/src/main/kotlin/com/goofy/boilerplate/common/dto/ErrorResponse.kt b/src/main/kotlin/com/goofy/boilerplate/common/dto/ErrorResponse.kt index 2b33dbff..bbbdb2ad 100644 --- a/src/main/kotlin/com/goofy/boilerplate/common/dto/ErrorResponse.kt +++ b/src/main/kotlin/com/goofy/boilerplate/common/dto/ErrorResponse.kt @@ -11,7 +11,7 @@ import javax.validation.ConstraintViolationException data class ErrorResponse( val errorCode: String, val reason: String, - val extra: Map? = null + val extra: Map? = null, ) { companion object { private const val FAIL_TO_VALIDATE_MESSAGE = "fail to validate" diff --git a/src/main/kotlin/com/goofy/boilerplate/common/dto/Response.kt b/src/main/kotlin/com/goofy/boilerplate/common/dto/Response.kt index 3f644f96..a2100ad8 100644 --- a/src/main/kotlin/com/goofy/boilerplate/common/dto/Response.kt +++ b/src/main/kotlin/com/goofy/boilerplate/common/dto/Response.kt @@ -9,7 +9,7 @@ data class PageResponseDto( val size: Int?, val totalPage: Int, val totalCount: Long, - val sort: Sort + val sort: Sort, ) { constructor(page: Page) : this( data = page.content, diff --git a/src/main/kotlin/com/goofy/boilerplate/config/database/BoilerPlateDatabaseConfig.kt b/src/main/kotlin/com/goofy/boilerplate/config/database/BoilerPlateDatabaseConfig.kt index 22771635..c3748785 100644 --- a/src/main/kotlin/com/goofy/boilerplate/config/database/BoilerPlateDatabaseConfig.kt +++ b/src/main/kotlin/com/goofy/boilerplate/config/database/BoilerPlateDatabaseConfig.kt @@ -41,7 +41,7 @@ class BoilerPlateDatabaseConfig { @Primary @ConfigurationProperties(prefix = "boilerplate.master.datasource.hikari") fun boilerplateMasterHikariDataSource( - @Qualifier("boilerplateMasterDataSourceProperties") masterProperty: DataSourceProperties + @Qualifier("boilerplateMasterDataSourceProperties") masterProperty: DataSourceProperties, ): HikariDataSource { return masterProperty .initializeDataSourceBuilder() @@ -51,7 +51,7 @@ class BoilerPlateDatabaseConfig { @Bean fun boilerplateNamedParameterJdbcTemplate( - @Qualifier("boilerplateMasterHikariDataSource") dataSource: DataSource + @Qualifier("boilerplateMasterHikariDataSource") dataSource: DataSource, ): NamedParameterJdbcTemplate { return NamedParameterJdbcTemplate(dataSource) } @@ -68,7 +68,7 @@ class BoilerPlateDatabaseConfig { fun boilerplateEntityManager( entityManagerFactoryBuilder: EntityManagerFactoryBuilder, configurableListableBeanFactory: ConfigurableListableBeanFactory, - @Qualifier("boilerplateMasterHikariDataSource") boilerplateDataSource: DataSource + @Qualifier("boilerplateMasterHikariDataSource") boilerplateDataSource: DataSource, ): LocalContainerEntityManagerFactoryBean { return entityManagerFactoryBuilder .dataSource(boilerplateDataSource) @@ -84,7 +84,7 @@ class BoilerPlateDatabaseConfig { @Bean @Primary fun boilerplateTransactionManager( - @Qualifier("boilerplateEntityManager") boilerplateEntityManager: EntityManagerFactory + @Qualifier("boilerplateEntityManager") boilerplateEntityManager: EntityManagerFactory, ): PlatformTransactionManager { return JpaTransactionManager(boilerplateEntityManager) } diff --git a/src/main/kotlin/com/goofy/boilerplate/config/web/SpringDocConfig.kt b/src/main/kotlin/com/goofy/boilerplate/config/web/SpringDocConfig.kt index 8a9bd98a..5f4b36fc 100644 --- a/src/main/kotlin/com/goofy/boilerplate/config/web/SpringDocConfig.kt +++ b/src/main/kotlin/com/goofy/boilerplate/config/web/SpringDocConfig.kt @@ -18,7 +18,7 @@ import org.springframework.web.server.WebSession */ @Configuration class SpringDocConfig( - private val buildProperties: BuildProperties + private val buildProperties: BuildProperties, ) { init { SpringDocUtils diff --git a/src/main/kotlin/com/goofy/boilerplate/config/web/WebFluxConfig.kt b/src/main/kotlin/com/goofy/boilerplate/config/web/WebFluxConfig.kt index ef379f72..3d0add9f 100644 --- a/src/main/kotlin/com/goofy/boilerplate/config/web/WebFluxConfig.kt +++ b/src/main/kotlin/com/goofy/boilerplate/config/web/WebFluxConfig.kt @@ -18,7 +18,7 @@ import java.nio.charset.Charset @Configuration class WebFluxConfig( - private val objectMapper: ObjectMapper + private val objectMapper: ObjectMapper, ) : WebFluxConfigurer { override fun addCorsMappings(registry: CorsRegistry) { registry.addMapping("/**") diff --git a/src/main/kotlin/com/goofy/boilerplate/exception/ErrorCode.kt b/src/main/kotlin/com/goofy/boilerplate/exception/ErrorCode.kt index 6133052d..245605ac 100644 --- a/src/main/kotlin/com/goofy/boilerplate/exception/ErrorCode.kt +++ b/src/main/kotlin/com/goofy/boilerplate/exception/ErrorCode.kt @@ -10,6 +10,6 @@ enum class ErrorCode(val status: HttpStatus, val description: String) { METHOD_NOT_ALLOWED_ERROR(HttpStatus.METHOD_NOT_ALLOWED, "Method type is invalid"), INVALID_MEDIA_TYPE_ERROR(HttpStatus.BAD_REQUEST, "invalid media type"), QUERY_DSL_NOT_EXISTS_ERROR(HttpStatus.NOT_FOUND, "not found query dsl"), - COROUTINE_CANCELLATION_ERROR(HttpStatus.BAD_REQUEST, "coroutine cancellation error") + COROUTINE_CANCELLATION_ERROR(HttpStatus.BAD_REQUEST, "coroutine cancellation error"), ; } diff --git a/src/main/kotlin/com/goofy/boilerplate/exception/Exceptions.kt b/src/main/kotlin/com/goofy/boilerplate/exception/Exceptions.kt index 5bf5e540..43f30dc1 100644 --- a/src/main/kotlin/com/goofy/boilerplate/exception/Exceptions.kt +++ b/src/main/kotlin/com/goofy/boilerplate/exception/Exceptions.kt @@ -3,5 +3,5 @@ package com.goofy.boilerplate.exception open class BusinessException( val errorCode: ErrorCode, override val message: String? = errorCode.description, - val extra: Map? = null + val extra: Map? = null, ) : RuntimeException(message ?: errorCode.description) diff --git a/src/main/kotlin/com/goofy/boilerplate/exception/advice/ExceptionHandler.kt b/src/main/kotlin/com/goofy/boilerplate/exception/advice/ExceptionHandler.kt index cc174c00..e1257ddc 100644 --- a/src/main/kotlin/com/goofy/boilerplate/exception/advice/ExceptionHandler.kt +++ b/src/main/kotlin/com/goofy/boilerplate/exception/advice/ExceptionHandler.kt @@ -22,7 +22,7 @@ class ExceptionHandler { @ExceptionHandler(WebExchangeBindException::class) protected fun handleWebExchangeBindException( e: WebExchangeBindException, - exchange: ServerWebExchange + exchange: ServerWebExchange, ): ResponseEntity { logger.warn { "WebExchangeBindException ${e.message}, requestUri=${exchange.request.uri}" } return ResponseEntity @@ -34,7 +34,7 @@ class ExceptionHandler { @ExceptionHandler(DecodingException::class) protected fun handleDecodingException( e: DecodingException, - exchange: ServerWebExchange + exchange: ServerWebExchange, ): ResponseEntity { logger.warn { "DecodingException ${e.message}, requestUri=${exchange.request.uri}" } return ResponseEntity @@ -46,7 +46,7 @@ class ExceptionHandler { @ExceptionHandler(ConstraintViolationException::class) protected fun handleConstraintViolationException( e: ConstraintViolationException, - exchange: ServerWebExchange + exchange: ServerWebExchange, ): ResponseEntity { logger.warn { "ConstraintViolationException ${e.message}, requestUri=${exchange.request.uri}" } return ResponseEntity @@ -58,7 +58,7 @@ class ExceptionHandler { @ExceptionHandler(ServerWebInputException::class) protected fun handleServerWebInputException( e: ServerWebInputException, - exchange: ServerWebExchange + exchange: ServerWebExchange, ): ResponseEntity { logger.warn { "ServerWebInputException ${e.message}, requestUri=${exchange.request.uri}" } return ResponseEntity @@ -70,7 +70,7 @@ class ExceptionHandler { @ExceptionHandler(TypeMismatchException::class) protected fun handleTypeMismatchException( e: TypeMismatchException, - exchange: ServerWebExchange + exchange: ServerWebExchange, ): ResponseEntity { logger.warn { "TypeMismatchException ${e.message}, requestUri=${exchange.request.uri}" } return ResponseEntity @@ -86,7 +86,7 @@ class ExceptionHandler { @ExceptionHandler(CancellationException::class) protected fun handleCancellationException( e: CancellationException, - exchange: ServerWebExchange + exchange: ServerWebExchange, ): ResponseEntity { logger.warn { "CancellationException ${e.message}, requestUri=${exchange.request.uri}" } return ResponseEntity diff --git a/src/main/kotlin/com/goofy/boilerplate/health/dto/HealthResponse.kt b/src/main/kotlin/com/goofy/boilerplate/health/dto/HealthResponse.kt index c73649d3..fcf43d81 100644 --- a/src/main/kotlin/com/goofy/boilerplate/health/dto/HealthResponse.kt +++ b/src/main/kotlin/com/goofy/boilerplate/health/dto/HealthResponse.kt @@ -5,5 +5,5 @@ import java.time.LocalDateTime data class HealthResponse( val message: String, val dateTime: LocalDateTime, - val profile: String + val profile: String, ) diff --git a/src/main/kotlin/com/goofy/boilerplate/health/presentation/HealthResource.kt b/src/main/kotlin/com/goofy/boilerplate/health/presentation/HealthResource.kt index 6ffb04fc..114ee372 100644 --- a/src/main/kotlin/com/goofy/boilerplate/health/presentation/HealthResource.kt +++ b/src/main/kotlin/com/goofy/boilerplate/health/presentation/HealthResource.kt @@ -15,7 +15,7 @@ import java.time.LocalDateTime @RestController @RequestMapping(produces = [MediaType.APPLICATION_JSON_VALUE]) class HealthResource( - private val environment: Environment + private val environment: Environment, ) { @Operation(summary = "health check") @GetMapping("/health") diff --git a/src/test/kotlin/com/goofy/boilerplate/example/JacocoTest.kt b/src/test/kotlin/com/goofy/boilerplate/example/JacocoTest.kt index acb35518..3668d329 100644 --- a/src/test/kotlin/com/goofy/boilerplate/example/JacocoTest.kt +++ b/src/test/kotlin/com/goofy/boilerplate/example/JacocoTest.kt @@ -7,7 +7,7 @@ import org.springframework.boot.test.context.SpringBootTest @SpringBootTest class JacocoTest @Autowired constructor( - private val jacoco: Jacoco + private val jacoco: Jacoco, ) : FunSpec({ context("jacoco test") { test("test1") { From 5e8fad44f4e1d3839dee92d1419f8da9c3a76a4f Mon Sep 17 00:00:00 2001 From: wjdtkdgns Date: Thu, 16 Nov 2023 02:04:52 +0900 Subject: [PATCH 11/18] =?UTF-8?q?fix:=20workflow=20=EC=A1=B0=EA=B1=B4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EB=B0=8F,=20ktlint=20=EB=B2=84=EC=A0=84?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CI.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8eab1ed7..70950eaa 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -34,8 +34,8 @@ jobs: with: github_token: ${{ secrets.GITHUBTOKEN }} reporter: github-pr-check - ktlint_version: "0.50.0" -# fail_on_error: true # 오류 발생시 실패 + ktlint_version: "1.0.0" + continue-on-error: true # 실패해도 계속 진행 # 빌드 - name: Gradle Clean & Build From 78b450dfd67bc02ba5e56fdc486960abc8172d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=B3=E1=86=A8=E1=84=85=E1=85=A1=E1=86=A8?= =?UTF-8?q?=E1=84=8F=E1=85=A9=E1=84=83=E1=85=B5=E1=86=BC?= <50691225+DongGeon0908@users.noreply.github.com> Date: Thu, 16 Nov 2023 02:12:24 +0900 Subject: [PATCH 12/18] imp: upgrade boot3 and jdk 17 --- .github/workflows/CI.yml | 4 ++-- README.md | 4 ++-- build.gradle.kts | 19 ++++++++++--------- .../boilerplate/common/dto/ErrorResponse.kt | 2 +- .../database/BoilerPlateDatabaseConfig.kt | 2 +- .../CoroutinesLocalValidatorFactoryBean.kt | 6 +++--- .../boilerplate/config/web/SpringDocConfig.kt | 2 +- .../exception/advice/ExceptionHandler.kt | 2 +- 8 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 70950eaa..6e34e170 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: kotlin-version: [ "1.8.22" ] - java-version: [ "11" ] + java-version: [ "17" ] steps: - name: Checkout code @@ -46,4 +46,4 @@ jobs: run: ./gradlew test sonar --info env: GITHUB_TOKEN: ${{ secrets.GITHUBTOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/README.md b/README.md index 4e0806fe..749de91e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Spring Webflux + Coroutine Boilerplate ### Spec -- SpringBoot v2.7.17 -- jdk 11 +- SpringBoot v3.1.5 +- jdk 17 diff --git a/build.gradle.kts b/build.gradle.kts index 4e40511f..c07cb75c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,8 +3,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { val kotlinVersion = "1.8.22" - id("org.springframework.boot") version "2.7.17" - id("io.spring.dependency-management") version "1.0.15.RELEASE" + id("org.springframework.boot") version "3.1.5" + id("io.spring.dependency-management") version "1.1.3" kotlin("jvm") version kotlinVersion kotlin("plugin.spring") version kotlinVersion kotlin("plugin.jpa") version kotlinVersion @@ -23,7 +23,7 @@ plugins { } group = "com.goofy" -java.sourceCompatibility = JavaVersion.VERSION_11 +java.sourceCompatibility = JavaVersion.VERSION_17 repositories { mavenCentral() @@ -56,7 +56,7 @@ object DependencyVersion { /** external */ const val QUERYDSL_VERSION = "5.0.0" const val ARROW_FX_VERSION = "1.1.3" - const val SPRINGDOC_VERSION = "1.6.15" + const val SPRINGDOC_VERSION = "2.2.0" const val JAVADOC_SCRIBE_VERSION = "0.15.0" const val KOTLIN_LOGGING_VERSION = "2.0.11" const val LOGBACK_ENCODER_VERSION = "6.6" @@ -92,9 +92,7 @@ dependencies { implementation("io.arrow-kt:arrow-fx-stm:${DependencyVersion.ARROW_FX_VERSION}") /** swagger */ - implementation("org.springdoc:springdoc-openapi-webflux-ui:${DependencyVersion.SPRINGDOC_VERSION}") - implementation("org.springdoc:springdoc-openapi-kotlin:${DependencyVersion.SPRINGDOC_VERSION}") - implementation("org.springdoc:springdoc-openapi-javadoc:${DependencyVersion.SPRINGDOC_VERSION}") + implementation("org.springdoc:springdoc-openapi-starter-webflux-ui:${DependencyVersion.SPRINGDOC_VERSION}") kapt("com.github.therapi:therapi-runtime-javadoc-scribe:${DependencyVersion.JAVADOC_SCRIBE_VERSION}") /** database */ @@ -127,7 +125,7 @@ tasks.getByName("jar") { tasks.withType { kotlinOptions { freeCompilerArgs = listOf("-Xjsr305=strict") - jvmTarget = "11" + jvmTarget = "17" } } @@ -210,7 +208,10 @@ sonarqube { property("sonar.language", "Kotlin") property("sonar.sourceEncoding", "UTF-8") property("sonar.test.inclusions", "**/*Test.java") - property("sonar.exclusions", "**/test/**, **/Q*.kt, **/*Doc*.kt, **/resources/** ,**/*Application*.kt , **/*Config*.kt, **/*Dto*.kt, **/*Request*.kt, **/*Response*.kt ,**/*Exception*.kt ,**/*ErrorCode*.kt") + property( + "sonar.exclusions", + "**/test/**, **/Q*.kt, **/*Doc*.kt, **/resources/** ,**/*Application*.kt , **/*Config*.kt, **/*Dto*.kt, **/*Request*.kt, **/*Response*.kt ,**/*Exception*.kt ,**/*ErrorCode*.kt" + ) property("sonar.java.coveragePlugin", "jacoco") property("sonar.java.binaries", "$buildDir/classes") property("sonar.coverage.jacoco.xmlReportPaths", "$buildDir/reports/jacoco.xml") diff --git a/src/main/kotlin/com/goofy/boilerplate/common/dto/ErrorResponse.kt b/src/main/kotlin/com/goofy/boilerplate/common/dto/ErrorResponse.kt index bbbdb2ad..fbc9c53f 100644 --- a/src/main/kotlin/com/goofy/boilerplate/common/dto/ErrorResponse.kt +++ b/src/main/kotlin/com/goofy/boilerplate/common/dto/ErrorResponse.kt @@ -1,12 +1,12 @@ package com.goofy.boilerplate.common.dto import com.goofy.boilerplate.exception.ErrorCode +import jakarta.validation.ConstraintViolationException import kotlinx.coroutines.CancellationException import org.hibernate.TypeMismatchException import org.springframework.core.codec.DecodingException import org.springframework.web.bind.support.WebExchangeBindException import org.springframework.web.server.ServerWebInputException -import javax.validation.ConstraintViolationException data class ErrorResponse( val errorCode: String, diff --git a/src/main/kotlin/com/goofy/boilerplate/config/database/BoilerPlateDatabaseConfig.kt b/src/main/kotlin/com/goofy/boilerplate/config/database/BoilerPlateDatabaseConfig.kt index c3748785..7ab397b8 100644 --- a/src/main/kotlin/com/goofy/boilerplate/config/database/BoilerPlateDatabaseConfig.kt +++ b/src/main/kotlin/com/goofy/boilerplate/config/database/BoilerPlateDatabaseConfig.kt @@ -1,6 +1,7 @@ package com.goofy.boilerplate.config.database import com.zaxxer.hikari.HikariDataSource +import jakarta.persistence.EntityManagerFactory import org.hibernate.cfg.AvailableSettings import org.springframework.beans.factory.annotation.Qualifier import org.springframework.beans.factory.config.ConfigurableListableBeanFactory @@ -19,7 +20,6 @@ import org.springframework.orm.jpa.JpaTransactionManager import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean import org.springframework.transaction.PlatformTransactionManager import org.springframework.transaction.annotation.EnableTransactionManagement -import javax.persistence.EntityManagerFactory import javax.sql.DataSource @Configuration diff --git a/src/main/kotlin/com/goofy/boilerplate/config/validation/CoroutinesLocalValidatorFactoryBean.kt b/src/main/kotlin/com/goofy/boilerplate/config/validation/CoroutinesLocalValidatorFactoryBean.kt index 725f82c0..6f8ce254 100644 --- a/src/main/kotlin/com/goofy/boilerplate/config/validation/CoroutinesLocalValidatorFactoryBean.kt +++ b/src/main/kotlin/com/goofy/boilerplate/config/validation/CoroutinesLocalValidatorFactoryBean.kt @@ -1,5 +1,7 @@ package com.goofy.boilerplate.config.validation +import jakarta.validation.ClockProvider +import jakarta.validation.ParameterNameProvider import org.hibernate.validator.internal.engine.DefaultClockProvider import org.springframework.core.KotlinReflectionParameterNameDiscoverer import org.springframework.core.LocalVariableTableParameterNameDiscoverer @@ -9,8 +11,6 @@ import org.springframework.core.StandardReflectionParameterNameDiscoverer import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean import java.lang.reflect.Constructor import java.lang.reflect.Method -import javax.validation.ClockProvider -import javax.validation.ParameterNameProvider import kotlin.reflect.jvm.kotlinFunction class CoroutinesLocalValidatorFactoryBean : LocalValidatorFactoryBean() { @@ -18,7 +18,7 @@ class CoroutinesLocalValidatorFactoryBean : LocalValidatorFactoryBean() { return DefaultClockProvider.INSTANCE } - override fun postProcessConfiguration(configuration: javax.validation.Configuration<*>) { + override fun postProcessConfiguration(configuration: jakarta.validation.Configuration<*>) { super.postProcessConfiguration(configuration) val discoverer = PrioritizedParameterNameDiscoverer().apply { diff --git a/src/main/kotlin/com/goofy/boilerplate/config/web/SpringDocConfig.kt b/src/main/kotlin/com/goofy/boilerplate/config/web/SpringDocConfig.kt index 5f4b36fc..da4ab19a 100644 --- a/src/main/kotlin/com/goofy/boilerplate/config/web/SpringDocConfig.kt +++ b/src/main/kotlin/com/goofy/boilerplate/config/web/SpringDocConfig.kt @@ -2,7 +2,7 @@ package com.goofy.boilerplate.config.web import io.swagger.v3.oas.models.OpenAPI import io.swagger.v3.oas.models.info.Info -import org.springdoc.core.SpringDocUtils +import org.springdoc.core.utils.SpringDocUtils import org.springframework.boot.info.BuildProperties import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration diff --git a/src/main/kotlin/com/goofy/boilerplate/exception/advice/ExceptionHandler.kt b/src/main/kotlin/com/goofy/boilerplate/exception/advice/ExceptionHandler.kt index e1257ddc..9efb497e 100644 --- a/src/main/kotlin/com/goofy/boilerplate/exception/advice/ExceptionHandler.kt +++ b/src/main/kotlin/com/goofy/boilerplate/exception/advice/ExceptionHandler.kt @@ -1,6 +1,7 @@ package com.goofy.boilerplate.exception.advice import com.goofy.boilerplate.common.dto.ErrorResponse +import jakarta.validation.ConstraintViolationException import kotlinx.coroutines.CancellationException import mu.KotlinLogging import org.hibernate.TypeMismatchException @@ -13,7 +14,6 @@ import org.springframework.web.bind.annotation.RestControllerAdvice import org.springframework.web.bind.support.WebExchangeBindException import org.springframework.web.server.ServerWebExchange import org.springframework.web.server.ServerWebInputException -import javax.validation.ConstraintViolationException @RestControllerAdvice class ExceptionHandler { From e3740b96f3e122f656d14d807163c2a0cdfd6464 Mon Sep 17 00:00:00 2001 From: wjdtkdgns Date: Thu, 16 Nov 2023 02:21:38 +0900 Subject: [PATCH 13/18] =?UTF-8?q?fix:=20workflow=20ktlint=20version=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 6e34e170..7ec4d979 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -34,7 +34,7 @@ jobs: with: github_token: ${{ secrets.GITHUBTOKEN }} reporter: github-pr-check - ktlint_version: "1.0.0" +# ktlint_version: "1.0.0" continue-on-error: true # 실패해도 계속 진행 # 빌드 From 9021638920865c699febdc68a4766f792e61ed68 Mon Sep 17 00:00:00 2001 From: wjdtkdgns Date: Thu, 16 Nov 2023 02:22:40 +0900 Subject: [PATCH 14/18] =?UTF-8?q?fix:=20ktlint=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=A3=BC=EC=84=9D=EC=B2=98=EB=A6=AC=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CI.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7ec4d979..f5caa96b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -29,13 +29,13 @@ jobs: distribution: 'adopt' # 자동 Ktlint 체크 자동화 - - name: ktlint check - uses: ScaCap/action-ktlint@master - with: - github_token: ${{ secrets.GITHUBTOKEN }} - reporter: github-pr-check +# - name: ktlint check +# uses: ScaCap/action-ktlint@master +# with: +# github_token: ${{ secrets.GITHUBTOKEN }} +# reporter: github-pr-check # ktlint_version: "1.0.0" - continue-on-error: true # 실패해도 계속 진행 +# continue-on-error: true # 실패해도 계속 진행 # 빌드 - name: Gradle Clean & Build From 4c2ae759dd5a0f28421f94b81dc01d6191ce8fef Mon Sep 17 00:00:00 2001 From: wjdtkdgns Date: Thu, 16 Nov 2023 02:31:09 +0900 Subject: [PATCH 15/18] =?UTF-8?q?fix:=20workflow=20=EC=88=98=EC=A0=95=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CI.yml | 4 ++++ .../common/dto/{Response.kt => PageResponseDto.kt} | 0 .../exception/{Exceptions.kt => BusinessException.kt} | 0 .../goofy/boilerplate/extension/{TimeExtension.kt => Zone.kt} | 0 4 files changed, 4 insertions(+) rename src/main/kotlin/com/goofy/boilerplate/common/dto/{Response.kt => PageResponseDto.kt} (100%) rename src/main/kotlin/com/goofy/boilerplate/exception/{Exceptions.kt => BusinessException.kt} (100%) rename src/main/kotlin/com/goofy/boilerplate/extension/{TimeExtension.kt => Zone.kt} (100%) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f5caa96b..e000d0b0 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -41,6 +41,10 @@ jobs: - name: Gradle Clean & Build run: ./gradlew clean build + # 컨테이너 실행 + - name: Start containers # test 돌릴때 mysql 필요 + run: docker-compose up -d + # jacoco, sonarcube - name: test and analyze run: ./gradlew test sonar --info diff --git a/src/main/kotlin/com/goofy/boilerplate/common/dto/Response.kt b/src/main/kotlin/com/goofy/boilerplate/common/dto/PageResponseDto.kt similarity index 100% rename from src/main/kotlin/com/goofy/boilerplate/common/dto/Response.kt rename to src/main/kotlin/com/goofy/boilerplate/common/dto/PageResponseDto.kt diff --git a/src/main/kotlin/com/goofy/boilerplate/exception/Exceptions.kt b/src/main/kotlin/com/goofy/boilerplate/exception/BusinessException.kt similarity index 100% rename from src/main/kotlin/com/goofy/boilerplate/exception/Exceptions.kt rename to src/main/kotlin/com/goofy/boilerplate/exception/BusinessException.kt diff --git a/src/main/kotlin/com/goofy/boilerplate/extension/TimeExtension.kt b/src/main/kotlin/com/goofy/boilerplate/extension/Zone.kt similarity index 100% rename from src/main/kotlin/com/goofy/boilerplate/extension/TimeExtension.kt rename to src/main/kotlin/com/goofy/boilerplate/extension/Zone.kt From f24747ce4d5ae8373e7faae57c7d3abe4c1cc9f9 Mon Sep 17 00:00:00 2001 From: wjdtkdgns Date: Thu, 16 Nov 2023 02:36:46 +0900 Subject: [PATCH 16/18] =?UTF-8?q?fix:=20docker-compose=20db=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EB=B3=80=EC=88=98=20=EC=B6=94=EA=B0=80=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index 0d5f85c3..572eecf0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,5 +13,6 @@ services: - MYSQL_ROOT_PASSWORD=root - MYSQL_HOST=localhost - MYSQL_PORT=3306 + - MYSQL_DATABASE=test ports: - "3307:3306" \ No newline at end of file From a064dd1d4f6ca44846a1920fc421f2defd3b8531 Mon Sep 17 00:00:00 2001 From: wjdtkdgns Date: Thu, 16 Nov 2023 13:08:24 +0900 Subject: [PATCH 17/18] =?UTF-8?q?fix:=20sonarcube=20=EB=B2=84=EC=A0=84=20?= =?UTF-8?q?=EB=8B=A4=EC=9A=B4=EA=B7=B8=EB=A0=88=EC=9D=B4=EB=93=9C=20?= =?UTF-8?q?=EB=B0=8F=20ktlint=20=EA=B2=80=EC=A6=9D=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CI.yml | 9 --------- build.gradle.kts | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e000d0b0..04ec5f60 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -28,15 +28,6 @@ jobs: kotlin-version: ${{ matrix.kotlin-version }} distribution: 'adopt' - # 자동 Ktlint 체크 자동화 -# - name: ktlint check -# uses: ScaCap/action-ktlint@master -# with: -# github_token: ${{ secrets.GITHUBTOKEN }} -# reporter: github-pr-check -# ktlint_version: "1.0.0" -# continue-on-error: true # 실패해도 계속 진행 - # 빌드 - name: Gradle Clean & Build run: ./gradlew clean build diff --git a/build.gradle.kts b/build.gradle.kts index c07cb75c..8bdf3788 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -19,7 +19,7 @@ plugins { id("jacoco") /** sonarqube **/ - id("org.sonarqube") version "4.4.1.3373" + id("org.sonarqube") version "4.3.1.3277" } group = "com.goofy" From fb7f3bf95b306abc593bea17542f84e7df9423af Mon Sep 17 00:00:00 2001 From: wjdtkdgns Date: Thu, 16 Nov 2023 13:15:23 +0900 Subject: [PATCH 18/18] =?UTF-8?q?feat:=20sonarqube=20run=20option=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CI.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 04ec5f60..eed85670 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -28,7 +28,7 @@ jobs: kotlin-version: ${{ matrix.kotlin-version }} distribution: 'adopt' - # 빌드 + # 빌드, ktlint check도 진행됨 - name: Gradle Clean & Build run: ./gradlew clean build @@ -38,7 +38,7 @@ jobs: # jacoco, sonarcube - name: test and analyze - run: ./gradlew test sonar --info + run: ./gradlew test sonar --stacktrace env: GITHUB_TOKEN: ${{ secrets.GITHUBTOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}