Skip to content

Commit

Permalink
chore: SonarQube 설정 추가 #50
Browse files Browse the repository at this point in the history
  • Loading branch information
chaewss committed Aug 19, 2024
1 parent 2457789 commit e1acc2b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@ jobs:
steps:
- name : Checkout branch
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Cache SonarQube packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache Gradle packages
uses: actions/cache@v3
with:
Expand All @@ -30,5 +39,8 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew

- name: Build with Gradle Wrapper
run: ./gradlew clean build
- name: Test and analyze
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: ./gradlew test sonar --info
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.0.4'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id "org.sonarqube" version "5.0.0.4638"
}

apply from: 'gradle/jacoco.gradle'
apply from: 'gradle/junit.gradle'
apply from: 'gradle/lombok.gradle'
apply from: 'gradle/spring.gradle'
apply from: 'gradle/sonar.gradle'

allprojects {
group = 'com.chaewsstore'
Expand All @@ -27,9 +29,15 @@ allprojects {
subprojects {
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.sonarqube'
compileJava.options.encoding = 'UTF-8'

dependencies {
implementation 'org.apache.commons:commons-collections4:4.4'
}
sonar {
properties {
property 'sonar.java.binaries', "${buildDir}/classes"
}
}
}
2 changes: 1 addition & 1 deletion gradle/jacoco.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ subprojects {
jacocoTestReport {
reports {
html.required.set(true)
xml.required.set(false)
xml.required.set(true)
csv.required.set(false)
}
afterEvaluate {
Expand Down
16 changes: 16 additions & 0 deletions gradle/sonar.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
sonar {
properties {
property "sonar.projectKey", "chaewsstore"
property "sonar.projectName", "chaewsstore"
property 'sonar.sources', 'src'
property 'sonar.language', 'java'
property 'sonar.sourceEncoding', 'UTF-8'
property "sonar.profile", "Sonar way"
property 'sonar.test.inclusions', '**/*Test.java'
property 'sonar.exclusions', '**/Q*.java, **/config/**, **/common/**, **/importer/**, ' +
'**/*Application*.java, **/*Dto*.java, **/*Exception*.java, **/*ErrorCode*.java, ' +
'**/*Constants*.java, **/*Util*.java, **/Jwts.java, **/*DetailService*.java'
property 'sonar.java.coveragePlugin', 'jacoco'
property 'sonar.coverage.jacoco.xmlReportPaths', "${project.rootDir}/support/jacoco/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml"
}
}

0 comments on commit e1acc2b

Please sign in to comment.