diff --git a/.github/workflows/deploy-dev-test.yml b/.github/workflows/deploy-dev-test.yml index 35d8c842..7a15787b 100644 --- a/.github/workflows/deploy-dev-test.yml +++ b/.github/workflows/deploy-dev-test.yml @@ -59,6 +59,19 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- + - name: Cache SonarCloud packages + uses: actions/cache@v3 + with: + fetch-depth: 0 + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.SUBMODULE_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - name: Build with Gradle run: | ./gradlew doonut-app-external-api:bootJar --stacktrace diff --git a/doonut-app-external-api/build.gradle.kts b/doonut-app-external-api/build.gradle.kts index f604d4a9..f5beb144 100644 --- a/doonut-app-external-api/build.gradle.kts +++ b/doonut-app-external-api/build.gradle.kts @@ -5,6 +5,9 @@ plugins { id("io.spring.dependency-management") version "1.1.5" kotlin("jvm") version "1.9.24" kotlin("plugin.spring") version "1.9.24" + + id("jacoco") + id("org.sonarqube") version "5.1.0.4882" } group = "com.doonutmate" @@ -18,6 +21,21 @@ repositories { mavenCentral() } +sonarqube { + properties { + property("sonar.projectKey", "doonutmate123") + property("sonar.organization", "doonutmate_sonarcloud") + property("sonar.host.url", "https://sonarcloud.io") + // sonar additional settings + property("sonar.sources", "src") + property("sonar.language", "Kotlin") + property("sonar.sourceEncoding", "UTF-8") + property("sonar.test.inclusions", "**/*Test.java") + property("sonar.exclusions", "**/test/**, **/Q*.kt, **/*Doc*.kt, **/resources/** ,**/*Application*.kt , **/*Config*.kt, **/*Dto*.kt, **/*Request*.kt, **/*Response*.kt ,**/*Exception*.kt ,**/*ErrorCode*.kt") + property("sonar.java.coveragePlugin", "jacoco") + } +} + dependencies { implementation(project(":doonut-core")) implementation(project(":doonut-support")) @@ -100,4 +118,19 @@ tasks { withType { enabled = false } + + jacocoTestReport { + dependsOn(test) // tests are required to run before generating the report + reports { + xml.required.set(true) + html.required.set(true) + } + } + test { + finalizedBy(jacocoTestReport) // report is always generated after tests run + reports { + junitXml.required.set(false) + html.required.set(true) + } + } } diff --git a/doonut-core/build.gradle.kts b/doonut-core/build.gradle.kts index 7d0c6b1e..7c296251 100644 --- a/doonut-core/build.gradle.kts +++ b/doonut-core/build.gradle.kts @@ -68,3 +68,11 @@ tasks.withType { ), ) } + +tasks.bootJar { + enabled = false +} + +tasks.jar { + enabled = true +} diff --git a/doonut-support/build.gradle.kts b/doonut-support/build.gradle.kts index b3db734b..69ce565c 100644 --- a/doonut-support/build.gradle.kts +++ b/doonut-support/build.gradle.kts @@ -30,3 +30,11 @@ dependencies { tasks.withType { useJUnitPlatform() } + +tasks.bootJar { + enabled = false +} + +tasks.jar { + enabled = true +}