From 7ae29ee5c70818a49854115a1c646f64eb2f8077 Mon Sep 17 00:00:00 2001 From: Ziedelth Date: Fri, 1 Mar 2024 14:19:19 +0100 Subject: [PATCH] Add sonarqube.yml --- .github/workflows/sonarqube.yml | 41 +++++++++++++++++++++++++++++++++ build.gradle.kts | 11 +++++++++ 2 files changed, 52 insertions(+) create mode 100644 .github/workflows/sonarqube.yml diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml new file mode 100644 index 00000000..6d449904 --- /dev/null +++ b/.github/workflows/sonarqube.yml @@ -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 \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 3789984c..871b26a2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -110,6 +110,13 @@ kotlin { jvmToolchain(21) } +sonar { + properties { + property("sonar.projectKey", "core") + property("sonar.projectName", "core") + } +} + tasks.test { useJUnitPlatform() finalizedBy("jacocoTestReport") @@ -123,3 +130,7 @@ tasks.jacocoTestReport { html.required = false } } + +tasks.sonar { + dependsOn("jacocoTestReport") +}