diff --git a/.github/workflows/gradle-build.yml b/.github/workflows/gradle-build.yml index cdc1dc00..5d2ab2fb 100644 --- a/.github/workflows/gradle-build.yml +++ b/.github/workflows/gradle-build.yml @@ -19,7 +19,6 @@ jobs: with: cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop' }} - - name: Cache Gradle packages uses: actions/cache@v3 with: @@ -27,6 +26,13 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} restore-keys: ${{ runner.os }}-gradle + - name: Cache SonarCloud packages + uses: actions/cache@v3 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Execute Gradle build run: ./gradlew clean check integrationTest --scan --stacktrace @@ -45,6 +51,14 @@ jobs: coverage_report_title: JaCoCo github_token: ${{ secrets.GITHUB_TOKEN }} + - name: Analyze with SonarCloud + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: | + BRANCH_NAME=${GITHUB_REF#refs/heads/} + ./gradlew sonar -Psonar.branch.name=${BRANCH_NAME} --info + - name: Upload Artifacts uses: actions/upload-artifact@master with: diff --git a/build.gradle b/build.gradle index c8a687ec..33e38bdc 100644 --- a/build.gradle +++ b/build.gradle @@ -10,9 +10,18 @@ buildscript { plugins { id 'java' + alias(libs.plugins.sonar) alias(libs.plugins.gradle.versions) } +sonar { + properties { + property "sonar.projectKey", System.getenv("SONAR_PROJECT_KEY") ?: "aim42_htmlSanityCheck" + property "sonar.organization", System.getenv('SONAR_ORGANIZATION') ?: "aim42" + property "sonar.host.url", "https://sonarcloud.io" + } +} + allprojects { group = group version = version diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 16668ed4..29515765 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -12,7 +12,8 @@ slf4j-nop = "org.slf4j:slf4j-nop:2.0.11" spock = "org.spockframework:spock-bom:2.3-groovy-3.0" [plugins] -gradle-versions = { id= "com.github.ben-manes.versions", version = "0.50.0" } +gradle-versions = { id = "com.github.ben-manes.versions", version = "0.50.0" } +sonar = { id = "org.sonarqube", version = "5.0.0.4638" } # Copyright Gerd Aschemann and aim42 contributors. #