Skip to content

Commit

Permalink
[CI] SonarCloud integration
Browse files Browse the repository at this point in the history
  • Loading branch information
odoralc committed Dec 5, 2022
1 parent a442afc commit f28f3a4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Expand Up @@ -39,7 +39,7 @@ jobs:
uses: gradle/gradle-build-action@v2
with:
gradle-version: 7.3
arguments: clean test --info --continue
arguments: clean codeCoverageReport --info --continue

- name: Set up JDK 11
uses: actions/setup-java@v2
Expand All @@ -51,7 +51,7 @@ jobs:
uses: gradle/gradle-build-action@v2
with:
gradle-version: 7.3
arguments: clean sonarqube --info --continue
arguments: clean sonarqube -x test --info --continue
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
39 changes: 21 additions & 18 deletions build.gradle
Expand Up @@ -10,10 +10,26 @@ allprojects {
}
}

def allTestCoverageFile = "${rootProject.buildDir}/jacoco/allTestCoverage.exec"
task jacocoMerge(type: JacocoMerge, group: 'verification') {
destinationFile = file(allTestCoverageFile)
executionData = project.fileTree(dir: '.', include:'**/build/jacoco/test.exec')
task codeCoverageReport(type: JacocoReport) {

// Gather execution data from all subprojects
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")

// Add all relevant source sets from the subprojects
subprojects.each {
sourceSets it.sourceSets.main
}

reports {
xml.enabled true
html.enabled true
csv.enabled false
}
}

// always run the tests before generating the report
codeCoverageReport.dependsOn {
subprojects*.test
}

sonarqube {
Expand All @@ -23,7 +39,7 @@ sonarqube {
property "sonar.sourceEncoding", "UTF-8"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.java.source", "8"
property 'sonar.jacoco.reportPaths', allTestCoverageFile
property "sonar.coverage.jacoco.xmlReportPaths", "${rootDir}/build/reports/jacoco/codeCoverageReport/codeCoverageReport.xml"
}
}

Expand All @@ -46,17 +62,6 @@ subprojects {
testCompileOnly 'org.projectlombok:lombok:1.18.24'
}

sonarqube {
properties {
property "sonar.projectKey", "odoral_adventofcode"
property "sonar.organization", "odoral"
property "sonar.sourceEncoding", "UTF-8"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.java.source", "8"
property 'sonar.jacoco.reportPaths', allTestCoverageFile
}
}

wrapper {
gradleVersion = '7.3'
distributionType = Wrapper.DistributionType.BIN
Expand All @@ -66,6 +71,4 @@ subprojects {
toolVersion = "0.8.3"
}

test.finalizedBy(jacocoMerge)

}

0 comments on commit f28f3a4

Please sign in to comment.