Skip to content

Commit

Permalink
chore: fix JaCoCo report integration in SonarCloud (#233)
Browse files Browse the repository at this point in the history
* chore: update JaCoco settings to following Quarkus documentation and recommandations

* chore: update Sonar settings with new JaCoCo report location

* chore: run **all** tests on `main` branch
  • Loading branch information
clementguillot authored Oct 22, 2024
1 parent a1d341c commit 3e8fef5
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 74 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,22 @@ jobs:
- name: Setup build tools
uses: ./.github/actions/setup-tools

- name: Run Test for affected projects
- name: Run Test for affected projects (PR)
if: github.ref != 'refs/heads/main'
run: pnpm exec nx affected -t test
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}

# - name: SonarCloud Scan
# uses: SonarSource/sonarcloud-github-action@eb211723266fe8e83102bac7361f0a05c3ac1d1b # v3.0.0
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Run Test for all projects (main)
if: github.ref == 'refs/heads/main'
run: pnpm exec nx run-many --target=test --all
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@383f7e52eae3ab0510c3cb0e7d9d150bbaeab838 # v3.1.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

lint:
runs-on: ubuntu-latest
Expand Down
10 changes: 0 additions & 10 deletions apps/server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ plugins {
kotlin("plugin.allopen")
id("io.quarkus")
id("com.diffplug.spotless")
id("jacoco")
}

repositories {
Expand Down Expand Up @@ -69,15 +68,6 @@ java {

tasks.withType<Test> {
systemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager")
finalizedBy("jacocoTestReport")
}

tasks.jacocoTestReport {
reports {
csv.required.set(false)
xml.required.set(true)
xml.outputLocation.set(layout.buildDirectory.file("reports/jacoco/jacoco.xml"))
}
}

allOpen {
Expand Down
15 changes: 8 additions & 7 deletions libs/server/domain/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ tasks.withType<Jar> {

tasks.withType<Test> {
systemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager")
finalizedBy("jacocoTestReport")
}
finalizedBy(tasks.jacocoTestReport)

configure<JacocoTaskExtension> {
excludeClassLoaders = listOf("*QuarkusClassLoader")
setDestinationFile(layout.buildDirectory.file("jacoco-quarkus.exec").get().asFile)
}

tasks.jacocoTestReport {
reports {
csv.required.set(false)
xml.required.set(true)
xml.outputLocation.set(layout.buildDirectory.file("reports/jacoco/jacoco.xml"))
tasks.jacocoTestReport {
enabled = false
}
}

Expand Down
10 changes: 0 additions & 10 deletions libs/server/persistence/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ plugins {
kotlin("plugin.noarg")
id("io.quarkus")
id("com.diffplug.spotless")
id("jacoco")
}

repositories {
Expand Down Expand Up @@ -53,15 +52,6 @@ tasks.withType<Jar> {

tasks.withType<Test> {
systemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager")
finalizedBy("jacocoTestReport")
}

tasks.jacocoTestReport {
reports {
csv.required.set(false)
xml.required.set(true)
xml.outputLocation.set(layout.buildDirectory.file("reports/jacoco/jacoco.xml"))
}
}

allOpen {
Expand Down
10 changes: 0 additions & 10 deletions libs/server/storage/azure/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ plugins {
kotlin("plugin.allopen")
id("io.quarkus")
id("com.diffplug.spotless")
id("jacoco")
}

repositories {
Expand Down Expand Up @@ -57,15 +56,6 @@ tasks.withType<Jar> {

tasks.withType<Test> {
systemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager")
finalizedBy("jacocoTestReport")
}

tasks.jacocoTestReport {
reports {
csv.required.set(false)
xml.required.set(true)
xml.outputLocation.set(layout.buildDirectory.file("reports/jacoco/jacoco.xml"))
}
}

allOpen {
Expand Down
10 changes: 0 additions & 10 deletions libs/server/storage/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ plugins {
kotlin("plugin.allopen")
id("io.quarkus")
id("com.diffplug.spotless")
id("jacoco")
}

repositories {
Expand Down Expand Up @@ -48,15 +47,6 @@ tasks.withType<Jar> {

tasks.withType<Test> {
systemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager")
finalizedBy("jacocoTestReport")
}

tasks.jacocoTestReport {
reports {
csv.required.set(false)
xml.required.set(true)
xml.outputLocation.set(layout.buildDirectory.file("reports/jacoco/jacoco.xml"))
}
}

allOpen {
Expand Down
10 changes: 0 additions & 10 deletions libs/server/storage/gcs/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ plugins {
kotlin("plugin.allopen")
id("io.quarkus")
id("com.diffplug.spotless")
id("jacoco")
}

repositories {
Expand Down Expand Up @@ -55,15 +54,6 @@ tasks.withType<Jar> {

tasks.withType<Test> {
systemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager")
finalizedBy("jacocoTestReport")
}

tasks.jacocoTestReport {
reports {
csv.required.set(false)
xml.required.set(true)
xml.outputLocation.set(layout.buildDirectory.file("reports/jacoco/jacoco.xml"))
}
}

allOpen {
Expand Down
10 changes: 0 additions & 10 deletions libs/server/storage/s3/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ plugins {
kotlin("plugin.allopen")
id("io.quarkus")
id("com.diffplug.spotless")
id("jacoco")
}

repositories {
Expand Down Expand Up @@ -54,15 +53,6 @@ tasks.withType<Jar> {

tasks.withType<Test> {
systemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager")
finalizedBy("jacocoTestReport")
}

tasks.jacocoTestReport {
reports {
csv.required.set(false)
xml.required.set(true)
xml.outputLocation.set(layout.buildDirectory.file("reports/jacoco/jacoco.xml"))
}
}

allOpen {
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sonar.projectKey=clementguillot_nx-cloud-ce
sonar.organization=clementguillot
sonar.kotlin.source.version=2.0
sonar.coverage.jacoco.xmlReportPaths=**/build/reports/jacoco/jacoco.xml
sonar.coverage.jacoco.xmlReportPaths=**/build/jacoco-report/jacoco.xml
sonar.test.inclusions=**/src/test/kotlin/**/*.kt

0 comments on commit 3e8fef5

Please sign in to comment.