Skip to content

Commit

Permalink
[INJIMOB-2712] add sonar job as push trigger (#77)
Browse files Browse the repository at this point in the history
Signed-off-by: KiruthikaJeyashankar <[email protected]>
  • Loading branch information
KiruthikaJeyashankar authored Jan 24, 2025
1 parent 86e77c0 commit aeaf7fb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
1 change: 0 additions & 1 deletion .github/workflows/push-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ jobs:
uses: mosip/kattu/.github/workflows/gradlew-sonar-analysis.yml@master-java21
with:
SERVICE_LOCATION: vc-verifier/kotlin/vcverifier
ANDROID_LOCATION: ''
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_ORGANIZATION: ${{ secrets.ORG_KEY }}
Expand Down
2 changes: 2 additions & 0 deletions vc-verifier/kotlin/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ lifecycleRuntimeKtx = "2.8.5"
activityCompose = "1.9.2"
composeBom = "2024.04.01"
orgJson = "20240303"
sonarqube = "5.1.0.4872"

[libraries]
junitJupiter = { group = "org.junit.jupiter", name = "junit-jupiter", version.ref = "junit" }
Expand Down Expand Up @@ -49,3 +50,4 @@ androidApplication = { id = "com.android.application", version.ref = "agp" }
androidLibrary = { id = "com.android.library", version.ref = "agp" }
jetbrainsKotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
sonarqube = { id = "org.sonarqube", version.ref = "sonarqube" }
49 changes: 46 additions & 3 deletions vc-verifier/kotlin/vcverifier/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@ plugins {
alias(libs.plugins.jetbrainsKotlinAndroid)
`maven-publish`
alias(libs.plugins.dokka)
alias(libs.plugins.sonarqube)
jacoco
signing
}

jacoco {
toolVersion = "0.8.8" // Ensure compatibility
}

android {
namespace = "io.mosip.vccred.vcverifier"
compileSdk = 33
Expand Down Expand Up @@ -49,14 +55,41 @@ dependencies {
implementation("co.nstant.in:cbor:0.9")
implementation ( "com.android.identity:identity-credential:20231002")



testImplementation(libs.mockk)
testImplementation(libs.junitJupiter)
}

tasks.withType<Test> {
useJUnitPlatform()
jacoco {
isEnabled = true
}
finalizedBy(tasks.named("jacocoTestReport"))
}

tasks.register("jacocoTestReport", JacocoReport::class) {
description = "Generates Test coverage report"
group = "TestReport"
dependsOn("testDebugUnitTest")

reports {
xml.required = true
html.required = true
csv.required = false
}

val kotlinTree = fileTree(
mapOf(
"dir" to "${layout.buildDirectory.get()}/tmp/kotlin-classes/debug",
"includes" to listOf("**/*.class")
)
)
val coverageSourceDirs = arrayOf("src/main/java")

classDirectories.setFrom(files(kotlinTree))
sourceDirectories.setFrom(coverageSourceDirs)

executionData.setFrom(files("${layout.buildDirectory.get()}/jacoco/testDebugUnitTest.exec"))
}

tasks.register<Jar>("jarRelease") {
Expand Down Expand Up @@ -91,4 +124,14 @@ tasks.register<Jar>("sourcesJar") {
apply(from = "publish-artifact.gradle")
tasks.register("generatePom") {
dependsOn("generatePomFileForAarPublication", "generatePomFileForJarReleasePublication")
}
}

sonarqube {
properties {
property( "sonar.java.binaries", "build/intermediates/javac/debug")
property( "sonar.language", "kotlin")
property( "sonar.exclusions", "**/build/**, **/*.kt.generated, **/R.java, **/BuildConfig.java")
property( "sonar.scm.disabled", "true")
property( "sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml")
}
}

0 comments on commit aeaf7fb

Please sign in to comment.