diff --git a/.gitea/workflows/sonar.yaml b/.gitea/workflows/sonar.yaml new file mode 100644 index 0000000..ce7dc5f --- /dev/null +++ b/.gitea/workflows/sonar.yaml @@ -0,0 +1,42 @@ +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + +name: SonarQube Scan +jobs: + sonarqube: + name: SonarQube Trigger + runs-on: ubuntu-latest + steps: + - name: Checking out + uses: actions/checkout@v4 + with: + # Disabling shallow clone is recommended for improving relevancy of reporting + fetch-depth: 0 + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: 21 + distribution: 'temurin' # Alternative distribution options are available. + - name: Setup Android SDK + uses: android-actions/setup-android@v3 + - name: Cache SonarQube packages + uses: actions/cache@v4 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache Gradle packages + uses: actions/cache@v4 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle + - name: SonarQube Scan + env: + SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONARQUBE_HOST }} + run: ./gradlew build sonar --info --build-cache diff --git a/build.gradle.kts b/build.gradle.kts index fbf852a..900641c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,6 +6,7 @@ plugins { // this is necessary to avoid the plugins to be loaded multiple times // in each subproject's classloader alias(libs.plugins.versions) + alias(libs.plugins.sonarqube) alias(libs.plugins.android.application) apply false alias(libs.plugins.android.library) apply false alias(libs.plugins.compose) apply false @@ -15,6 +16,13 @@ plugins { alias(libs.plugins.jetbrains.kotlin.android) apply false } +sonar { + properties { + property("sonar.projectKey", "YAEP") + property("sonar.projectName", "YAEP") + } +} + tasks.withType().configureEach { compilerOptions { jvmTarget.set(JvmTarget.fromTarget(libs.versions.jdk.get())) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f4b2fef..5650832 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,7 +4,7 @@ app-version-name = "1.0.0" agp = "8.11.1" jdk = "21" android-compileSdk = "36" -android-minSdk = "24" +android-minSdk = "26" android-targetSdk = "36" androidx-activityCompose = "1.10.1" androidx-compose = "1.8.3" @@ -35,5 +35,6 @@ android-library = { id = "com.android.library", version.ref = "agp" } kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } +sonarqube = { id = "org.sonarqube", version = "6.2.0.5505" } compose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" } jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }