From f4ff44a35894769a4bbb73ee062f9e1cdc6a51bc Mon Sep 17 00:00:00 2001 From: Dev Uni Date: Fri, 27 Oct 2023 16:04:25 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20sonarcloud,=20checkstyle,=20jacoco=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9=20(#2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: sonarcloud 및 jacoco 세팅 * chore: checkstyle 세팅 * chore: gitignore 수정 --- .editorconfig | 18 + .github/workflows/ci.yml | 46 +++ .gitignore | 1 + build.gradle | 66 +++ config/checkstyle/checkstyle.xml | 444 +++++++++++++++++++++ config/checkstyle/suppressions.xml | 7 + config/naver-checkstyle-rules.xml | 433 ++++++++++++++++++++ config/naver-intellij-formatter-custom.xml | 74 ++++ 8 files changed, 1089 insertions(+) create mode 100644 .editorconfig create mode 100644 .github/workflows/ci.yml create mode 100644 config/checkstyle/checkstyle.xml create mode 100644 config/checkstyle/suppressions.xml create mode 100644 config/naver-checkstyle-rules.xml create mode 100644 config/naver-intellij-formatter-custom.xml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..855c0c54 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +max_line_length = 120 +tab_width = 4 +trim_trailing_whitespace = true + +[*.bat] +end_of_line = crlf + +[*.java] +indent_style = tab +ij_java_blank_lines_after_class_header = 1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..3109497d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,46 @@ +name: ci + +on: + pull_request: + branches: [ "main", "develop" ] + +jobs: + build: + name: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: JDK 17 셋업 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'corretto' + + - name: Gradle 캐싱 + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Gradle Grant 권한 부여 + run: chmod +x gradlew + + - name: SonarCloud 캐싱 + uses: actions/cache@v3 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: 빌드 및 분석 + run: ./gradlew build jacocoTestReport sonar --info --stacktrace + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_CLOUD_TOKEN }} diff --git a/.gitignore b/.gitignore index cf3974ce..df8fb3c3 100644 --- a/.gitignore +++ b/.gitignore @@ -120,3 +120,4 @@ gradle-app.setting logs/ application-*.yml +src/main/resources/config diff --git a/build.gradle b/build.gradle index 34b36b11..1fc75afe 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,9 @@ plugins { id 'java' id 'org.springframework.boot' version '3.1.5' id 'io.spring.dependency-management' version '1.1.3' + id 'org.sonarqube' version '4.4.1.3373' + id 'jacoco' + id 'checkstyle' } group = 'com.moabam' @@ -46,8 +49,71 @@ dependencies { annotationProcessor 'com.querydsl:querydsl-apt:5.0.0:jakarta' annotationProcessor 'jakarta.annotation:jakarta.annotation-api' annotationProcessor 'jakarta.persistence:jakarta.persistence-api' + + // H2 + implementation 'com.h2database:h2' } tasks.named('test') { useJUnitPlatform() + finalizedBy jacocoTestReport +} + +jacocoTestReport { + dependsOn test + reports { + xml.required = true + html.required = true + } + def Qdomains = [] + + for (qPattern in '**/QA'..'**/QZ') { // qPattern = '**/QA', '**/QB', ... '*.QZ' + Qdomains.add(qPattern + '*') + } + + afterEvaluate { + classDirectories.setFrom( + files(classDirectories.files.collect { + fileTree(dir: it, excludes: [ + "**/*Application*", + "**/*Config*", + "**/*Request*", + "**/*Response*", + "**/*Exception*", + "**/*Mapper*", + "**/*ErrorMessage*", + ] + Qdomains) + }) + ) + } +} + +compileJava.options.encoding = 'UTF-8' +compileTestJava.options.encoding = 'UTF-8' + +tasks.withType(Checkstyle).configureEach { + reports { + xml.required = true + html.required = true + } +} + +checkstyle { + toolVersion = "10.4" + maxWarnings = 0 + configFile = file("${rootDir}/config/checkstyle/checkstyle.xml") + configProperties = ["suppressionFile": "${rootDir}/config/checkstyle/suppressions.xml"] +} + +sonar { + properties { + property "sonar.projectKey", "team-moabam_moabam-BE" + property "sonar.organization", "team-moabam-sonarcloud-secret-key" + property "sonar.host.url", "https://sonarcloud.io" + property 'sonar.coverage.jacoco.xmlReportPaths', 'build/reports/jacoco/test/jacocoTestReport.xml' + property 'sonar.coverage.exclusions', '**/test/**, **/Q*.java, **/*Doc*.java, **/resources/** ' + + ',**/*Application*.java , **/*Config*.java, **/*Request*.java, **/*Response*.java ,**/*Exception*.java ' + + ',**/*ErrorMessage*.java, **/*Mapper*.java' + property 'sonar.java.checkstyle.reportPaths', 'build/reports/checkstyle/main.xml' + } } diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml new file mode 100644 index 00000000..217fa012 --- /dev/null +++ b/config/checkstyle/checkstyle.xml @@ -0,0 +1,444 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/checkstyle/suppressions.xml b/config/checkstyle/suppressions.xml new file mode 100644 index 00000000..3f11e0cd --- /dev/null +++ b/config/checkstyle/suppressions.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/config/naver-checkstyle-rules.xml b/config/naver-checkstyle-rules.xml new file mode 100644 index 00000000..dafbb4d1 --- /dev/null +++ b/config/naver-checkstyle-rules.xml @@ -0,0 +1,433 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/naver-intellij-formatter-custom.xml b/config/naver-intellij-formatter-custom.xml new file mode 100644 index 00000000..26f28954 --- /dev/null +++ b/config/naver-intellij-formatter-custom.xml @@ -0,0 +1,74 @@ + + + \ No newline at end of file