From 5652fa88868cb1369cb60b9b6e3aeec257e8f69e Mon Sep 17 00:00:00 2001 From: Jonathan Percival Date: Wed, 2 Oct 2024 15:22:53 -0600 Subject: [PATCH] Enable SonarQube --- .github/workflows/build.yml | 11 ++++++++++- .github/workflows/check-pr.yml | 11 ++++++++++- Src/java/build.gradle | 9 +++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 49f3dfba4..839dd232c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,14 +21,23 @@ jobs: with: distribution: 'temurin' java-version: '21' + cache: gradle + - name: Cache SonarCloud packages + uses: actions/cache@v4 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar - name: Setup Gradle uses: gradle/actions/setup-gradle@v3 - name: Run Gradle Build working-directory: ./Src/java - run: ./gradlew check publish + run: ./gradlew check publish sonar env: OSSRH_USERNAME: ${{ vars.OSSRH_USERNAME }} OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - name: Publish Test Report uses: mikepenz/action-junit-report@v4 if: success() || failure() # always run even if the previous step fails diff --git a/.github/workflows/check-pr.yml b/.github/workflows/check-pr.yml index 226811f8a..0efe07790 100644 --- a/.github/workflows/check-pr.yml +++ b/.github/workflows/check-pr.yml @@ -23,11 +23,20 @@ jobs: distribution: 'temurin' java-version: '21' cache: gradle + - name: Cache SonarCloud packages + uses: actions/cache@v4 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar - name: Setup Gradle uses: gradle/actions/setup-gradle@v3 - name: Run Gradle Build + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} working-directory: ./Src/java - run: ./gradlew check -x spotlessCheck + run: ./gradlew check sonar -x spotlessCheck - name: Publish Test Report uses: mikepenz/action-junit-report@v4 if: (success() || failure()) && matrix.os == 'ubuntu-latest' diff --git a/Src/java/build.gradle b/Src/java/build.gradle index 5cc640c3a..938708ac2 100644 --- a/Src/java/build.gradle +++ b/Src/java/build.gradle @@ -1,6 +1,15 @@ plugins { id 'idea' id 'eclipse' + id "org.sonarqube" version "4.4.1.3373" +} + +sonar { + properties { + property "sonar.projectKey", "cqframework_clinical_quality_language" + property "sonar.organization", "cqframework" + property "sonar.host.url", "https://sonarcloud.io" + } } idea {