Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: 프로젝트 추가 세팅 #2

Merged
merged 18 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/issue-enhancement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: 'Issue: Enhancement'
about: 새로운 기능 구현, 리팩토링과 관련된 이슈 템플릿
title: "🤖 [FEATURE]"
labels: ''
assignees: ''

---

# 🤖 기능 개요
<!-- 이슈에 할당된 기능이 무엇인지 간략하게 한 줄로 적습니다 -->

### ✅ Implement TODO
<!-- 이슈에 할당된 TODO를 나름대로 항목화하여 적습니다 (PR할 때에는 모두 체크되어야함) -->
- [ ]

### 🚧 작업 브랜치
<!-- 작업 브랜치 이름 적어주세요 -->

### 📚 Remarks
<!-- 기능 개발에 있어 비고사항이 있었다면 적기 -->
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/issue-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: 'Issue: Fix'
about: 에러 및 버그에 관련된 이슈 템플릿
title: "🐞 [ERROR / BUG]"
labels: ''
assignees: ''

---

# 🐞 에러 상황 설명
### 📄 에러 대상
<!-- 에러가 어디서 났는지 적기 -->

### 🕵🏻‍♀️ 에러 상황
<!-- 에러가 어떻게 나고 있는지 상세하게 적기 (사진 있으면 첨부) -->

### ✅ Resolve TODO
<!-- 에러/버그 수정 항목 나열하기 (PR할 때에는 모두 체크되어야함) -->
- [ ]

### 🚧 작업 브랜치
<!-- 작업 브랜치 이름 적어주세요 -->

### 📚 Remarks
<!-- 이슈 해결에 있어 비고사항이 있었다면 적기 -->
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/issue-refactor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: "Issue: Refactor"
about: 리팩토링 시에 적는 템플릿
title: "🔨[REFACTOR]"
labels: ''
assignees: ''

---

# 🔨 리팩토링이 필요한 부분
<!-- 리팩토링 내용 -->

### ✅ refactoring TODO
<!-- 리팩토링 투두 -->

### 🚧 작업 브랜치
<!-- 작업 브랜치 이름 적어주세요 -->

### 📚 Remarks
<!-- 기능 개발에 있어 비고사항이 있었다면 적기 -->
8 changes: 8 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## 개요
- close #issueNumber

## 작업사항
- 내용을 적어주세요.

## 변경로직
- 내용을 적어주세요.
44 changes: 44 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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: [ "17" ]

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 check도 진행됨
- 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 --stacktrace
env:
GITHUB_TOKEN: ${{ secrets.GITHUBTOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ out/

### VS Code ###
.vscode/

mysqldata/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Spring Webflux + Coroutine Boilerplate

### Spec
- SpringBoot v2.7.17
- jdk 11
- SpringBoot v3.1.5
- jdk 17
91 changes: 83 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@ 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
kotlin("plugin.allopen") version kotlinVersion
kotlin("kapt") version kotlinVersion
idea

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요기 신규 진행한거 저도 테스트를 해봐야 할 것 같어요

/** ktlint **/
id("org.jlleitschuh.gradle.ktlint") version "11.6.1"

/** jacoco **/
id("jacoco")

/** sonarqube **/
id("org.sonarqube") version "4.3.1.3277"
}

group = "com.goofy"
java.sourceCompatibility = JavaVersion.VERSION_11
java.sourceCompatibility = JavaVersion.VERSION_17

repositories {
mavenCentral()
Expand Down Expand Up @@ -47,10 +56,12 @@ 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"
const val KOTEST_VERSION = "5.7.2"
const val KOTEST_EXTENSION_VERSION = "1.1.2"
}

dependencies {
Expand Down Expand Up @@ -81,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 */
Expand All @@ -93,6 +102,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:${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")
}
Expand All @@ -110,7 +125,7 @@ tasks.getByName<Jar>("jar") {
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "11"
jvmTarget = "17"
}
}

Expand Down Expand Up @@ -142,3 +157,63 @@ when {
}

val Project.isSnapshotVersion: Boolean get() = version.toString().endsWith("SNAPSHOT")

/** jacoco **/
tasks.withType<Test> {
useJUnitPlatform()
}

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("$buildDir/reports/jacoco.xml"))
}

classDirectories.setFrom(
files(
classDirectories.files.map {
fileTree(it) {
exclude(
"**/*Application*",
"**/*Config*",
"**/*Dto*",
"**/*Request*",
"**/*Response*",
"**/*Interceptor*",
"**/*Exception*",
"**/Q*.class"
) // Query Dsl 용
}
}
)
)
}

/** sonarqube **/
sonarqube {
properties {
property("sonar.projectKey", "YAPP-Github_23rd-Android-Team-1-BE")
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")
}
}
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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
- MYSQL_DATABASE=test
ports:
- "3307:3306"
2 changes: 1 addition & 1 deletion src/main/kotlin/com/goofy/boilerplate/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import java.util.*
@SpringBootApplication
class Application(
private val buildProperties: BuildProperties,
private val environment: Environment
private val environment: Environment,
) : ApplicationListener<ApplicationReadyEvent> {
private val logger = mu.KotlinLogging.logger { }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
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,
val reason: String,
val extra: Map<String, Any>? = null
val extra: Map<String, Any>? = null,
) {
companion object {
private const val FAIL_TO_VALIDATE_MESSAGE = "fail to validate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data class PageResponseDto<T>(
val size: Int?,
val totalPage: Int,
val totalCount: Long,
val sort: Sort
val sort: Sort,
) {
constructor(page: Page<T>) : this(
data = page.content,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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()
Expand All @@ -68,12 +68,12 @@ class BoilerPlateDatabaseConfig {
fun boilerplateEntityManager(
entityManagerFactoryBuilder: EntityManagerFactoryBuilder,
configurableListableBeanFactory: ConfigurableListableBeanFactory,
@Qualifier("boilerplateMasterHikariDataSource") boilerplateDataSource: DataSource
@Qualifier("boilerplateMasterHikariDataSource") boilerplateDataSource: DataSource,
): LocalContainerEntityManagerFactoryBean {
return entityManagerFactoryBuilder
.dataSource(boilerplateDataSource)
.packages(
"com.goofy.boilerplate.user.domain",
"com.goofy.boilerplate.user.domain"
)
.properties(
mapOf(AvailableSettings.BEAN_CONTAINER to SpringBeanContainer(configurableListableBeanFactory))
Expand All @@ -84,7 +84,7 @@ class BoilerPlateDatabaseConfig {
@Bean
@Primary
fun boilerplateTransactionManager(
@Qualifier("boilerplateEntityManager") boilerplateEntityManager: EntityManagerFactory
@Qualifier("boilerplateEntityManager") boilerplateEntityManager: EntityManagerFactory,
): PlatformTransactionManager {
return JpaTransactionManager(boilerplateEntityManager)
}
Expand Down
Loading
Loading