Skip to content

Commit

Permalink
Add SonarQube analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
ascheman committed Mar 26, 2024
1 parent 5ea8d97 commit c69a877
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/gradle-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,31 @@ jobs:
with:
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop' }}


- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
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

- 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: 'Publish Test Results'
uses: EnricoMi/publish-unit-test-result-action/composite@v2
if: always()
Expand Down
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down

0 comments on commit c69a877

Please sign in to comment.