Skip to content

Commit

Permalink
[IDLE-45] Sonarcloud 의존성 추가 및 workflow 파일 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
wonjunYou committed Jun 19, 2024
1 parent e37193f commit ad36d54
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 1 deletion.
46 changes: 46 additions & 0 deletions .github/workflows/sonar_cloud.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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@v3
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: corretto

- name: Cache SonarCloud 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:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew

- name: Build And analyze Http Server
env:
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew clean test jacocoTestReport sonar --info
31 changes: 31 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id("jacoco")
id("jacoco-report-aggregation")
id("java-test-fixtures")
id(libs.plugins.sonarqube.get().pluginId) version libs.plugins.sonarqube.get().version.toString()
id(libs.plugins.spring.boot.get().pluginId) version libs.plugins.spring.boot.get().version.toString()
id(libs.plugins.spring.dependency.management.get().pluginId) version libs.plugins.spring.dependency.management.get().version.toString()
id(libs.plugins.kotlin.jvm.get().pluginId) version libs.plugins.kotlin.jvm.get().version.toString()
Expand All @@ -19,7 +20,9 @@ allprojects {
}

subprojects {
apply(plugin = "jacoco")
apply(plugin = "java-test-fixtures")
apply(plugin = "org.sonarqube")
apply(plugin = rootProject.libs.plugins.kotlin.jvm.get().pluginId)
apply(plugin = rootProject.libs.plugins.kotlin.jpa.get().pluginId)
apply(plugin = rootProject.libs.plugins.kotlin.spring.get().pluginId)
Expand Down Expand Up @@ -64,3 +67,31 @@ subprojects {
useJUnitPlatform()
}
}

sonar {
properties {
property("sonar.projectKey", "3IDLES_idle-server")
property("sonar.organization", "3idles")
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.java.coveragePlugin", "jacoco")
}
}

val allProjects = project.allprojects
.asSequence()
.filter { it.name != "idle-server" }
.filter { it.name != "idle-support" }
.filter { it.name != "idle-domain" }
.filter { it.name != "idle-infrastructure" }
.filter { it.name != "idle-api" }
.toList()

project(":idle-support:jacoco") {
apply(plugin = "jacoco-report-aggregation")

dependencies {
allProjects.forEach {
add("jacocoAggregation", project(it.path))
}
}
}
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ java = "17"
spring-boot = "3.3.0"
spring-boot-dependency-management = "1.1.4"
kotlin = "1.9.21"
sonar-cloud = "4.4.1.3373"

mockk = "1.13.7"
spring-mockk = "4.0.2"
Expand Down Expand Up @@ -39,6 +40,8 @@ kotest-extensions-testcontainers = { group = "io.kotest.extensions", name = "kot
testcontainers-junit-jupiter = { group = "org.testcontainers", name = "junit-jupiter", version.ref = "testcontainers" }

[plugins]

sonarqube = { id = "org.sonarqube", version.ref = "sonar-cloud" }
spring-boot = { id = "org.springframework.boot", version.ref = "spring-boot" }
spring-dependency-management = { id = "io.spring.dependency-management", version.ref = "spring-boot-dependency-management" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
Expand Down
3 changes: 3 additions & 0 deletions idle-support/jacoco/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dependencies {

}
3 changes: 2 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ include(
"idle-domain",
"idle-infrastructure",
"idle-support:common",
"idle-support:logging"
"idle-support:logging",
"idle-support:jacoco"
)

0 comments on commit ad36d54

Please sign in to comment.