diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml new file mode 100644 index 00000000000..feff199d12d --- /dev/null +++ b/.github/workflows/sonar.yml @@ -0,0 +1,45 @@ +name: SonarCloud +on: + push: + branches: + - develop + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + name: Build and analyze + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: 17 + + - name: Cache SonarCloud packages + uses: actions/cache@v3 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: Cache Gradle packages + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle*.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Build and analyze + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: ./gradlew build jacoco sonar --info \ No newline at end of file diff --git a/build.gradle b/build.gradle index dc92eec9f69..f1842a63965 100644 --- a/build.gradle +++ b/build.gradle @@ -8,6 +8,7 @@ plugins { // test id 'com.adarshr.test-logger' version '3.2.0' + id "org.sonarqube" version "4.2.1.3168" // helper id "com.github.ben-manes.versions" version "0.47.0" @@ -332,6 +333,17 @@ task jacoco(type: JacocoReport) { } } +/**********************************************************************************************************************\ + * Sonar + **********************************************************************************************************************/ +sonar { + properties { + property "sonar.projectKey", "kestra-io_kestra" + property "sonar.organization", "kestra-io" + property "sonar.host.url", "https://sonarcloud.io" + } +} + /**********************************************************************************************************************\ * Standalone **********************************************************************************************************************/