diff --git a/.github/workflows/develop-ci.yml b/.github/workflows/develop-ci.yml index 9e7d9031..7a454676 100644 --- a/.github/workflows/develop-ci.yml +++ b/.github/workflows/develop-ci.yml @@ -32,11 +32,26 @@ jobs: echo "${{ secrets.ENV_DEV }}" > .env.test shell: bash + - 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: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle + - name: touch dev data.sql run: | touch src/main/resources/sql/data.sql echo "${{ secrets.DATA_SQL }}" > src/main/resources/sql/data.sql shell: bash + - name: touch test data.sql run: | touch src/test/resources/sql/data.sql @@ -44,7 +59,9 @@ jobs: shell: bash - name: Build and analyze - run: ./gradlew build + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: ./gradlew build sonar --info - name: Upload Gradle Report uses: actions/upload-artifact@v4 diff --git a/build.gradle b/build.gradle index e3e16d51..327e8103 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,8 @@ plugins { id 'java' id 'org.springframework.boot' version '3.4.3' id 'io.spring.dependency-management' version '1.1.7' + id "org.sonarqube" version "6.2.0.5505" + id 'jacoco' } group = 'org.Runimo' @@ -60,6 +62,52 @@ dependencies { } +jacoco { + toolVersion = "0.8.12" +} + +jacocoTestReport { + dependsOn test + reports { + xml.required = true + html.required = true + csv.required = false + } + finalizedBy jacocoTestCoverageVerification +} + +jacocoTestCoverageVerification { + dependsOn jacocoTestReport + violationRules { + rule { + limit { + minimum = 0.70 // 70% 커버리지 요구 + } + } + rule { + enabled = false + element = 'CLASS' + includes = ['org.Runimo.*'] + limit { + counter = 'LINE' + value = 'TOTALCOUNT' + maximum = 200 + } + } + } +} + +sonar { + properties { + property "sonar.projectKey", "Run-Us_Runimo" + property "sonar.organization", "runimo-backend-server" + property "sonar.host.url", "https://sonarcloud.io" + } +} + tasks.named('test') { useJUnitPlatform() + finalizedBy jacocoTestReport } + +tasks.sonarqube.dependsOn jacocoTestReport