Skip to content

Commit 589ad30

Browse files
committed
configure sonar
1 parent 3720b56 commit 589ad30

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

.github/workflows/check.yml

+9
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,12 @@ jobs:
7676
with:
7777
name: reports
7878
path: '**/build/reports'
79+
80+
- name: Re-run all tests with Gradle
81+
run: ./gradlew check
82+
83+
- name: Report analysis to sonar
84+
run: ./gradlew sonar
85+
env:
86+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build.gradle.kts

+17-7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED
77
import org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED
88
import org.gradle.api.tasks.testing.logging.TestLogEvent.SKIPPED
99
import org.gradle.api.tasks.testing.logging.TestLogEvent.STARTED
10+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
11+
import org.sonarqube.gradle.SonarQubePlugin
1012
import org.springframework.boot.gradle.plugin.SpringBootPlugin
1113
import org.springframework.boot.gradle.tasks.bundling.BootJar
1214

@@ -19,7 +21,6 @@ buildscript {
1921
}
2022
}
2123

22-
@Suppress("DSL_SCOPE_VIOLATION")
2324
plugins {
2425
kotlin("jvm") version libs.versions.kotlin.get()
2526
kotlin("plugin.spring") version libs.versions.kotlin.get() apply false
@@ -44,7 +45,6 @@ dependencyManagement {
4445
}
4546

4647
val testModuleDirs = setOf("common/common-test", "common/common-persistence-jooq-test")
47-
val testModules = testModuleDirs.map { it.substringAfter("/") }
4848
val testPackages = testModuleDirs.map { "$it/**/*" }
4949
val generatedPackages: Set<String> = setOf(
5050
"**/ch/difty/scipamato/core/db/**",
@@ -54,7 +54,7 @@ val generatedPackages: Set<String> = setOf(
5454

5555
testing {
5656
suites {
57-
@Suppress("UnstableApiUsage")
57+
@Suppress("UnstableApiUsage", "unused")
5858
val test by getting(JvmTestSuite::class) {
5959
useJUnitJupiter()
6060
}
@@ -65,10 +65,8 @@ jacoco {
6565
toolVersion = libs.versions.jacoco.get()
6666
}
6767

68-
val jacocoTestReportFile = layout.buildDirectory.get().asFile.resolve("reports/jacoco/test/jacocoTestReport.xml")
6968
val jacocoTestPattern = "**/build/jacoco/*.exec"
7069
val genPkg = generatedPackages.joinToString(",")
71-
val detektReportFile = layout.buildDirectory.get().asFile.resolve("reports/detekt/detekt.xml")
7270

7371
sonarqube {
7472
properties {
@@ -77,8 +75,6 @@ sonarqube {
7775
property("sonar.organization", "ursjoss-github")
7876
property("sonar.exclusions", "**/ch/difty/scipamato/publ/web/themes/markup/html/publ/**/*,$genPkg")
7977
property("sonar.coverage.exclusions", (generatedPackages + testPackages).joinToString(","))
80-
property("sonar.coverage.jacoco.xmlReportPaths", jacocoTestReportFile)
81-
property("sonar.kotlin.detekt.reportPaths", detektReportFile)
8278
}
8379
}
8480

@@ -98,6 +94,20 @@ subprojects {
9894
apply<JavaPlugin>()
9995
apply<IdeaPlugin>()
10096
apply<JacocoPlugin>()
97+
apply<SonarQubePlugin>()
98+
99+
sonarqube {
100+
properties {
101+
property(
102+
"sonar.kotlin.detekt.reportPaths",
103+
layout.buildDirectory.get().asFile.resolve("reports/detekt/detekt.xml")
104+
)
105+
property(
106+
"sonar.coverage.jacoco.xmlReportPaths",
107+
layout.buildDirectory.get().asFile.resolve("reports/jacoco/test/jacocoTestReport.xml")
108+
)
109+
}
110+
}
101111

102112
testing {
103113
suites {

0 commit comments

Comments
 (0)