From 0596dc7f12017c690e409b7301b8775db3914f5c Mon Sep 17 00:00:00 2001 From: Roman Khlebnov Date: Wed, 18 Sep 2024 20:11:25 +0200 Subject: [PATCH] Updating CI --- .github/workflows/build.yml | 14 ++++++++++++-- build.gradle | 37 ++++++++++++++++++++++++++++++------- gradle.properties | 3 +++ 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b6946a9..3157eb4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,6 +31,13 @@ jobs: - name: Validate Gradle wrapper uses: gradle/wrapper-validation-action@v3 + - name: Cache SonarCloud packages + uses: actions/cache@v4 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache Gradle packages uses: actions/cache@v4 with: @@ -38,5 +45,8 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} restore-keys: ${{ runner.os }}-gradle - - name: Build with Gradle - run: ./gradlew build \ No newline at end of file + - name: Build with Gradle and analyze + run: ./gradlew build sonar --info + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 7fa2552..23206ab 100644 --- a/build.gradle +++ b/build.gradle @@ -7,12 +7,13 @@ plugins { id 'idea' id 'eclipse' - id 'jacoco' - // Publishing id 'com.vanniktech.maven.publish' version '0.29.0' - id 'com.diffplug.spotless' version '6.22.0' + // Utility + id 'jacoco' + id 'org.sonarqube' version '4.4.1.3373' + id 'com.diffplug.spotless' version '6.25.0' } // Project properties @@ -44,10 +45,6 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter:5.11.0' } -test { - useJUnitPlatform() -} - task sourceJar(type: Jar, dependsOn: classes) { archiveClassifier.set('sources') from sourceSets.main.allSource @@ -73,3 +70,29 @@ tasks.withType(JavaCompile).configureEach { options.encoding = StandardCharsets.UTF_8.name() dependsOn(spotlessJavaCheck) } + +test { + useJUnitPlatform() + + // Report is always generated after tests run + finalizedBy jacocoTestReport +} + +jacocoTestReport { + // Tests are required to run before generating the report + dependsOn test + + reports { + html.required = true + xml.required = true + csv.required = false + } +} + +sonar { + properties { + property "sonar.projectKey", "SuppieRK_java-throwable-utils" + property "sonar.organization", "suppierk" + property "sonar.host.url", "https://sonarcloud.io" + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index da6767a..abf5179 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,3 +25,6 @@ POM_DEVELOPER_URL=https://github.com/SuppieRK/ SONATYPE_CONNECT_TIMEOUT_SECONDS=300 SONATYPE_CLOSE_TIMEOUT_SECONDS=1800 + +# Miscellaneous +systemProp.sonar.gradle.skipCompile=true \ No newline at end of file