Skip to content

Commit

Permalink
chore: sonarcloud, checkstyle, jacoco 적용 (#2)
Browse files Browse the repository at this point in the history
* chore: sonarcloud 및 jacoco 세팅

* chore: checkstyle 세팅

* chore: gitignore 수정
  • Loading branch information
Shin-Jae-Yoon authored Oct 27, 2023
1 parent eabe156 commit f4ff44a
Show file tree
Hide file tree
Showing 8 changed files with 1,089 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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 }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,4 @@ gradle-app.setting

logs/
application-*.yml
src/main/resources/config
66 changes: 66 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
}
}
Loading

0 comments on commit f4ff44a

Please sign in to comment.