Skip to content
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

chore: fix JaCoCo report integration in SonarCloud #233

Merged
merged 3 commits into from
Oct 22, 2024
Merged
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
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