Skip to content

Commit

Permalink
Add sonarqube.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziedelth committed Mar 1, 2024
1 parent 3a8a065 commit 7ae29ee
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build and analyze

on:
push:
branches:
- master
- dev
pull_request:
types: [ opened, synchronize, reopened ]

jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions: read-all
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'adopt'
- 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: Build and analyze
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: ./gradlew build sonar --info
11 changes: 11 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ kotlin {
jvmToolchain(21)
}

sonar {
properties {
property("sonar.projectKey", "core")
property("sonar.projectName", "core")
}
}

tasks.test {
useJUnitPlatform()
finalizedBy("jacocoTestReport")
Expand All @@ -123,3 +130,7 @@ tasks.jacocoTestReport {
html.required = false
}
}

tasks.sonar {
dependsOn("jacocoTestReport")
}

0 comments on commit 7ae29ee

Please sign in to comment.