From 5ce737ed954244ff8bbf87fab840c88f5638c666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Horv=C3=A1th=20Istv=C3=A1n?= Date: Sun, 29 Sep 2024 17:02:24 +0200 Subject: [PATCH] Add sonarcloud scan for backend --- .github/workflows/sonar-backend.yml | 37 +++++++++++++++++++++++++++++ backend/build.gradle.kts | 9 +++++++ 2 files changed, 46 insertions(+) create mode 100644 .github/workflows/sonar-backend.yml diff --git a/.github/workflows/sonar-backend.yml b/.github/workflows/sonar-backend.yml new file mode 100644 index 0000000..81d9b3b --- /dev/null +++ b/.github/workflows/sonar-backend.yml @@ -0,0 +1,37 @@ +name: SonarCloud +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] +jobs: + build: + name: Build and analyze + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + 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: 'zulu' # Alternative distribution options are available + - name: Cache SonarCloud 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: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: ./gradlew build sonar --info diff --git a/backend/build.gradle.kts b/backend/build.gradle.kts index b9efaa5..999c688 100644 --- a/backend/build.gradle.kts +++ b/backend/build.gradle.kts @@ -3,6 +3,7 @@ plugins { kotlin("plugin.spring") version "2.0.20" id("org.springframework.boot") version "3.3.3" id("io.spring.dependency-management") version "1.1.6" + id("org.sonarqube") version "4.4.1.3373" } group = "hu.bme.sch" @@ -24,6 +25,14 @@ repositories { mavenCentral() } +sonar { + properties { + property("sonar.projectKey", "simonyiszk_paybasz-next-backend") + property("sonar.organization", "simonyiszk") + property("sonar.host.url", "https://sonarcloud.io") + } +} + extra["springModulithVersion"] = "1.2.3" dependencies {