From 9d59e5075ae84c419f95c5e38ca287c291e02c7b Mon Sep 17 00:00:00 2001 From: AnasNaouchi Date: Tue, 23 Jul 2024 08:49:07 +0700 Subject: [PATCH 1/6] Add Jacoco report generation --- build.gradle | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/build.gradle b/build.gradle index f71a726b..a644706b 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,7 @@ apply plugin: 'maven-publish' apply plugin: 'signing' apply plugin: 'io.github.goooler.shadow' apply plugin: 'com.github.ben-manes.versions' +apply plugin: 'jacoco' group 'co.omise' version '5.0.0' @@ -48,6 +49,18 @@ javadoc { } } +jacoco { + toolVersion = "0.8.12" +} + +jacocoTestReport { + reports { + xml.required = true + csv.required = true + html.outputLocation = layout.buildDirectory.dir('jacocoHtml') + } +} + // REF: https://docs.gradle.org/current/userguide/publishing_maven.html publishing { publications { From a94bbbbfc2000b285f7445c6ba6a726a804a9c63 Mon Sep 17 00:00:00 2001 From: AnasNaouchi Date: Tue, 23 Jul 2024 09:02:37 +0700 Subject: [PATCH 2/6] Add sonar cluod report upload --- build.gradle | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/build.gradle b/build.gradle index a644706b..0d73b45e 100644 --- a/build.gradle +++ b/build.gradle @@ -5,6 +5,7 @@ apply plugin: 'signing' apply plugin: 'io.github.goooler.shadow' apply plugin: 'com.github.ben-manes.versions' apply plugin: 'jacoco' +apply plugin: 'org.sonarqube' group 'co.omise' version '5.0.0' @@ -29,6 +30,7 @@ buildscript { dependencies { classpath "io.github.goooler.shadow:shadow-gradle-plugin:8.1.8" classpath 'com.github.ben-manes:gradle-versions-plugin:0.15.0' + classpath("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:5.1.0.4882") } } @@ -169,3 +171,14 @@ dependencies { testImplementation 'com.google.guava:guava:32.0.1-jre' } + +sonar { + properties { + property 'sonar.host.url', 'https://sonarcloud.io' + property 'sonar.organization', 'omise' + property 'sonar.projectName', 'omise-java' + property 'sonar.projectKey', 'omise_omise-java' + property 'sonar.coverage.jacoco.xmlReportPaths', "${project.buildDir}/reports/jacoco/jacocoTestReport/jacocoTestReport.xml" + property 'sonar.junit.reportPaths', "${project.buildDir}/test-results/testProductionDebugUnitTest" + } +} From 2abd60454b3ca832e4f58db981b3a2cd5d5f7342 Mon Sep 17 00:00:00 2001 From: AnasNaouchi Date: Tue, 23 Jul 2024 09:02:55 +0700 Subject: [PATCH 3/6] Update CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86e942f8..d9dbfb52 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,4 +22,4 @@ jobs: run: chmod +x gradlew - name: Build with Gradle - run: ./gradlew test + run: ./gradlew test jacocoTestReport sonar From b7fd1270b155203aa505183593274e1d1b967209 Mon Sep 17 00:00:00 2001 From: AnasNaouchi Date: Wed, 24 Jul 2024 11:57:14 +0700 Subject: [PATCH 4/6] Add sonar token to env --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d9dbfb52..6bc9ba9a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,5 +21,7 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Build with Gradle + - name: Build and Test with gradle + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: ./gradlew test jacocoTestReport sonar From aa3a816d4d0ef6120937ae450f304dac1a6a0349 Mon Sep 17 00:00:00 2001 From: AnasNaouchi Date: Thu, 1 Aug 2024 11:26:20 +0700 Subject: [PATCH 5/6] Update sonar organization --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0d73b45e..ca5a44dd 100644 --- a/build.gradle +++ b/build.gradle @@ -175,7 +175,7 @@ dependencies { sonar { properties { property 'sonar.host.url', 'https://sonarcloud.io' - property 'sonar.organization', 'omise' + property 'sonar.organization', 'omise-1' property 'sonar.projectName', 'omise-java' property 'sonar.projectKey', 'omise_omise-java' property 'sonar.coverage.jacoco.xmlReportPaths', "${project.buildDir}/reports/jacoco/jacocoTestReport/jacocoTestReport.xml" From 1c78c7b240b126b26045889add19239dbba26c76 Mon Sep 17 00:00:00 2001 From: AnasNaouchi Date: Thu, 1 Aug 2024 11:54:14 +0700 Subject: [PATCH 6/6] Add github token to CI --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6bc9ba9a..766249bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,4 +24,5 @@ jobs: - name: Build and Test with gradle env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: ./gradlew test jacocoTestReport sonar