diff --git a/.github/workflows/pipeline-build.yml b/.github/workflows/pipeline-build.yml index e08c51a..eb4308e 100644 --- a/.github/workflows/pipeline-build.yml +++ b/.github/workflows/pipeline-build.yml @@ -26,11 +26,33 @@ jobs: uses: better0fdead/actions-setup-docker@better0fdead/increase-timeout #Build without test on Windows or macOS (when not a PR) + - name: Set up JDK 17 + uses: actions/setup-java@v1 + with: + java-version: 17 + + - name: Cache SonarQube packages + uses: actions/cache@v1 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: Cache Gradle packages + uses: actions/cache@v1 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle + - name: Gradle build + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} run: | if [[ "$RUNNER_OS" == "Windows" || ( "$RUNNER_OS" == "macOS" && ${{ github.event_name }} != 'pull_request' ) ]]; then ./gradlew build -x test else - ./gradlew build + ./gradlew build sonar --info fi shell: bash diff --git a/build.gradle b/build.gradle index c031c50..b4d2181 100644 --- a/build.gradle +++ b/build.gradle @@ -15,6 +15,7 @@ plugins { id 'java' id 'com.github.jk1.dependency-license-report' version '1.16' id("org.jetbrains.dokka") version "1.6.10" + id "org.sonarqube" version "4.4.1.3373" } repositories { @@ -27,12 +28,27 @@ final def tdeps = gradle.settings.test_dependencies final def app_version = '2.0.0' ext.keep_test_container_alive = project.hasProperty('keep_test_container_alive') ? project.getProperty('keep_test_container_alive').toBoolean() : false +def sonarProjectKey = System.getenv("SONAR_CLOUD_PROJECT_KEY") +def sonarProjectName = System.getenv("SONAR_CLOUD_PROJECT_NAME") +def sonarProjectOrganization = System.getenv("SONAR_CLOUD_ORGANIZATION") + +sonar { + properties { + property "sonar.projectKey", sonarProjectKey + property "sonar.projectName", sonarProjectName + property "sonar.organization", sonarProjectOrganization + property "sonar.sourceEncoding", "UTF-8" + property "sonar.host.url", "https://sonarcloud.io" + } +} + allprojects { apply plugin: 'org.jetbrains.kotlin.jvm' apply plugin: 'maven-publish' apply from: "$rootDir/ktlint.gradle" apply plugin: 'java' apply plugin: "org.jetbrains.dokka" + apply plugin: "org.sonarqube" repositories { mavenCentral()