Skip to content

Commit

Permalink
Enable sonar cloud reporting (#177)
Browse files Browse the repository at this point in the history
* Add Jacoco report generation

* Add sonar cluod report upload

* Update CI

* Add sonar token to env

* Update sonar organization

* Add github token to CI
  • Loading branch information
AnasNaouchi authored Aug 1, 2024
1 parent 85fe55f commit 1118ed5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew test
- name: Build and Test with gradle
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew test jacocoTestReport sonar
26 changes: 26 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ apply plugin: 'maven-publish'
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'
Expand All @@ -28,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")
}
}

Expand All @@ -48,6 +51,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 {
Expand Down Expand Up @@ -156,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-1'
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"
}
}

0 comments on commit 1118ed5

Please sign in to comment.