Skip to content

Commit

Permalink
Add coverage integration to SonarCloud, using JaCoCo XML reports
Browse files Browse the repository at this point in the history
  • Loading branch information
clementguillot committed Feb 8, 2024
1 parent 883c5fa commit 2753f5b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ jobs:
- uses: ./.github/actions/nx-affected-target
with:
target: test
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
lint:
runs-on: ubuntu-latest
steps:
Expand Down
10 changes: 10 additions & 0 deletions apps/api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
kotlin("plugin.noarg")
id("io.quarkus")
id("com.diffplug.spotless")
id("jacoco")
}

repositories {
Expand Down Expand Up @@ -59,6 +60,15 @@ 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
7 changes: 6 additions & 1 deletion apps/api/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@
"executor": "@jnxplus/nx-gradle:run-task",
"options": {
"task": "test"
}
},
"outputs": [
"{projectRoot}/build/classes",
"{projectRoot}/build/reports",
"{projectRoot}/build/test-results"
]
},
"integration-test": {
"executor": "@jnxplus/nx-gradle:run-task",
Expand Down
4 changes: 4 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sonar.projectKey=clementguillot_nx-cloud-ce
sonar.organization=clementguillot

sonar.coverage.jacoco.xmlReportPaths=**/build/reports/jacoco/jacoco.xml

0 comments on commit 2753f5b

Please sign in to comment.