Skip to content

Commit

Permalink
Add Sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielFleischer committed Mar 11, 2024
1 parent 2ca3980 commit 578827a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,11 @@ jobs:
# This step generates the coverage report which will be uploaded to sonar
- name: Generate coverage
run: |
./gradlew jacocoTestReport
./gradlew jacocoTestReport
# Upload the various reports to sonar
- name: Upload report to SonarCloud
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew sonar --info --parallel --build-cache
16 changes: 16 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
alias(libs.plugins.androidApplication)
alias(libs.plugins.jetbrainsKotlinAndroid)
alias(libs.plugins.ktfmt)
alias(libs.plugins.sonar)
id("jacoco")
}

Expand Down Expand Up @@ -90,6 +91,21 @@ android {
}
}

sonar {
properties {
property("sonar.projectKey", "gf_android-sample")
property("sonar.projectName", "Android-Sample")
property("sonar.organization", "gabrielfleischer")
property("sonar.host.url", "https://sonarcloud.io")
// Comma-separated paths to the various directories containing the *.xml JUnit report files. Each path may be absolute or relative to the project base directory.
property("sonar.junit.reportPaths", "${project.layout.buildDirectory.get()}/test-results/testDebugunitTest/")
// Paths to xml files with Android Lint issues. If the main flavor is changed, this file will have to be changed too.
property("sonar.androidLint.reportPaths", "${project.layout.buildDirectory.get()}/reports/lint-results-debug.xml")
// Paths to JaCoCo XML coverage report files.
property("sonar.coverage.jacoco.xmlReportPaths", "${project.layout.buildDirectory.get()}/reports/jacoco/jacocoTestReport/jacocoTestReport.xml")
}
}

// When a library is used both by robolectric and connected tests, use this function
fun DependencyHandlerScope.globalTestImplementation(dep: Any) {
androidTestImplementation(dep)
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ composeViewModel = "2.7.0"
lifecycleRuntimeKtx = "2.7.0"
kaspresso = "1.5.5"
robolectric = "4.11.1"
sonar = "4.4.1.3373"

[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
Expand Down Expand Up @@ -44,3 +45,4 @@ robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectr
androidApplication = { id = "com.android.application", version.ref = "agp" }
jetbrainsKotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
ktfmt = { id = "com.ncorti.ktfmt.gradle", version.ref = "ktfmt" }
sonar = { id = "org.sonarqube", version.ref = "sonar" }

0 comments on commit 578827a

Please sign in to comment.