Skip to content

Commit

Permalink
[DEV-000] sonarcloud 설정 추가 (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
5uhwann authored Dec 2, 2024
1 parent 6497982 commit 10c30a6
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/sonar_cloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: SonarCloud
on:
push:
branches:
- develop
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build and analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin' # Alternative distribution options are available
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew build sonar --info
45 changes: 45 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.2.6'
id 'io.spring.dependency-management' version '1.1.3'
id 'jacoco'
id "org.sonarqube" version "5.1.0.4882"
}

group = 'ddingdong'
Expand Down Expand Up @@ -82,4 +84,47 @@ dependencies {

tasks.named('test') {
useJUnitPlatform()
finalizedBy 'jacocoTestReport'
}

sonar {
properties {
property "sonar.projectKey", "COW-dev_ddingdong-be"
property "sonar.organization", "cow-dev"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.sourceEncoding", "UTF-8"
property "sonar.java.source", "${java.sourceCompatibility}"
property "sonar.coverage.jacoco.xmlReportPaths", "${layout.buildDirectory}/reports/jacoco/test/jacocoTestReport.xml"
property "sonar.junit.reportPaths", "${layout.buildDirectory}/test-results/test"

property "sonar.exclusions", [
"**/ddingdong/ddingdongBE/common/**",
"**/ddingdong/ddingdongBE/*Request*",
"**/ddingdong/ddingdongBE/*Response*",
"**/ddingdong/ddingdongBE/*Command*",
"**/ddingdong/ddingdongBE/*Query*",
"**/ddingdong/ddingdongBE/*Dto*"
].join(',')
}
}

jacocoTestReport {
dependsOn test
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
"ddingdong/ddingdongBE/common/**",
"ddingdong/ddingdongBE/*Request*",
"ddingdong/ddingdongBE/*Response*",
"ddingdong/ddingdongBE/*Command*",
"ddingdong/ddingdongBE/*Query*",
"ddingdong/ddingdongBE/*Dto*"
])
}))
}
reports {
html.required = true
xml.required = true
csv.required = false
}
}

0 comments on commit 10c30a6

Please sign in to comment.