Skip to content

chore: configure sonar #585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,12 @@ jobs:
with:
name: reports
path: '**/build/reports'

- name: Re-run all tests with Gradle
run: ./gradlew check

- name: Report analysis to sonar
run: ./gradlew sonar
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 17 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED
import org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED
import org.gradle.api.tasks.testing.logging.TestLogEvent.SKIPPED
import org.gradle.api.tasks.testing.logging.TestLogEvent.STARTED
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.sonarqube.gradle.SonarQubePlugin
import org.springframework.boot.gradle.plugin.SpringBootPlugin
import org.springframework.boot.gradle.tasks.bundling.BootJar

Expand All @@ -19,7 +21,6 @@ buildscript {
}
}

@Suppress("DSL_SCOPE_VIOLATION")
plugins {
kotlin("jvm") version libs.versions.kotlin.get()
kotlin("plugin.spring") version libs.versions.kotlin.get() apply false
Expand All @@ -44,7 +45,6 @@ dependencyManagement {
}

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

testing {
suites {
@Suppress("UnstableApiUsage")
@Suppress("UnstableApiUsage", "unused")
val test by getting(JvmTestSuite::class) {
useJUnitJupiter()
}
Expand All @@ -65,10 +65,8 @@ jacoco {
toolVersion = libs.versions.jacoco.get()
}

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

sonarqube {
properties {
Expand All @@ -77,8 +75,6 @@ sonarqube {
property("sonar.organization", "ursjoss-github")
property("sonar.exclusions", "**/ch/difty/scipamato/publ/web/themes/markup/html/publ/**/*,$genPkg")
property("sonar.coverage.exclusions", (generatedPackages + testPackages).joinToString(","))
property("sonar.coverage.jacoco.xmlReportPaths", jacocoTestReportFile)
property("sonar.kotlin.detekt.reportPaths", detektReportFile)
}
}

Expand All @@ -98,6 +94,20 @@ subprojects {
apply<JavaPlugin>()
apply<IdeaPlugin>()
apply<JacocoPlugin>()
apply<SonarQubePlugin>()

sonarqube {
properties {
property(
"sonar.kotlin.detekt.reportPaths",
layout.buildDirectory.get().asFile.resolve("reports/detekt/detekt.xml")
)
property(
"sonar.coverage.jacoco.xmlReportPaths",
layout.buildDirectory.get().asFile.resolve("reports/jacoco/test/jacocoTestReport.xml")
)
}
}

testing {
suites {
Expand Down
Loading