From 2753f5b1bcf9d67a4065cc4f2a484e76b4360c35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Guillot?= Date: Thu, 8 Feb 2024 09:53:16 +0100 Subject: [PATCH] Add coverage integration to SonarCloud, using JaCoCo XML reports --- .github/workflows/ci.yml | 5 +++++ apps/api/build.gradle.kts | 10 ++++++++++ apps/api/project.json | 7 ++++++- sonar-project.properties | 4 ++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 sonar-project.properties diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a85a8b00..c7bed144 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/apps/api/build.gradle.kts b/apps/api/build.gradle.kts index 61c6cd7e..04a27af5 100644 --- a/apps/api/build.gradle.kts +++ b/apps/api/build.gradle.kts @@ -4,6 +4,7 @@ plugins { kotlin("plugin.noarg") id("io.quarkus") id("com.diffplug.spotless") + id("jacoco") } repositories { @@ -59,6 +60,15 @@ java { tasks.withType { 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 { diff --git a/apps/api/project.json b/apps/api/project.json index e0f0689d..128af186 100644 --- a/apps/api/project.json +++ b/apps/api/project.json @@ -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", diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..8cb7d268 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,4 @@ +sonar.projectKey=clementguillot_nx-cloud-ce +sonar.organization=clementguillot + +sonar.coverage.jacoco.xmlReportPaths=**/build/reports/jacoco/jacoco.xml