diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml new file mode 100644 index 0000000..432d182 --- /dev/null +++ b/.github/workflows/sonar.yaml @@ -0,0 +1,28 @@ +name: SonarCloud + +on: + push: + branches: [master] + pull_request: + branches: [master] + +permissions: + contents: read + +jobs: + sonar: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + + - name: Build, test, and analyze + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: ./gradlew test jacocoTestReport sonar diff --git a/build.gradle b/build.gradle index 460303c..640eefd 100644 --- a/build.gradle +++ b/build.gradle @@ -6,6 +6,7 @@ plugins { id 'com.diffplug.spotless' version "${spotlessVersion}" id 'net.ltgt.errorprone' version "${errorProneVersion}" id 'jacoco' + id 'org.sonarqube' version "${sonarqubeVersion}" } group = 'com.accountabilityatlas' @@ -95,6 +96,16 @@ jacocoTestCoverageVerification { check.dependsOn jacocoTestCoverageVerification +// ---- SonarCloud ---- +sonar { + properties { + property 'sonar.projectKey', 'kelleyglenn_AcctAtlas-api-gateway' + property 'sonar.projectName', 'AcctAtlas-api-gateway' + property 'sonar.organization', 'kelleyglenn' + property 'sonar.host.url', 'https://sonarcloud.io' + } +} + // ---- Jib ---- jib { from { diff --git a/gradle.properties b/gradle.properties index 82d5dee..6180ce7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,3 +20,6 @@ testcontainersVersion=1.21.4 # Lombok lombokVersion=1.18.42 + +# SonarQube +sonarqubeVersion=7.2.2.6593