From a7ed2a41b40ec419a2ad21e068358e07b57a4ca4 Mon Sep 17 00:00:00 2001 From: ybchar Date: Tue, 5 Dec 2023 21:41:45 +0900 Subject: [PATCH] chore: sonarcloud setting (#38) * chore: lifeCycle remove 1 * chore: Sonar test --- .github/workflows/develop_pull_request.yml | 17 +++++++++++---- build.gradle | 24 ++++++++++++++++++---- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/.github/workflows/develop_pull_request.yml b/.github/workflows/develop_pull_request.yml index ce87861a..693496db 100644 --- a/.github/workflows/develop_pull_request.yml +++ b/.github/workflows/develop_pull_request.yml @@ -11,7 +11,7 @@ jobs: java-version: [ 17 ] steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Java uses: actions/setup-java@v3 @@ -22,12 +22,21 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x ./gradlew + - name: Cache SonarCloud packages + uses: actions/cache@v3 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Setup Gradle uses: gradle/gradle-build-action@v2 with: arguments: check cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop' }} - - name: LifeCycle check - run: | - ./gradlew check + - name: SonarCloud scan + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: ./gradlew sonar --info --stacktrace diff --git a/build.gradle b/build.gradle index 3dbbcac9..a2bae45c 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,7 @@ plugins { id 'io.spring.dependency-management' version '1.1.3' id 'com.diffplug.spotless' version '6.11.0' id 'jacoco' + id 'org.sonarqube' version '4.4.1.3373' } group = 'com.depromeet' @@ -44,10 +45,6 @@ tasks.named('test') { finalizedBy 'jacocoTestReport' } -jacoco { - toolVersion = "0.8.8" -} - def jacocoDir = layout.buildDirectory.dir("reports/") def QDomains = [] @@ -68,6 +65,25 @@ def jacocoExcludePatterns = [ "**/*Resolver*" ] +sonar { + properties { + property "sonar.projectKey", "depromeet_10mm-server" + property "sonar.organization", "depromeet-1" + property "sonar.host.url", "https://sonarcloud.io" + property 'sonar.sources', 'src' + property 'sonar.language', 'java' + property 'sonar.sourceEncoding', 'UTF-8' + property 'sonar.test.exclusions', jacocoExcludePatterns.toString() + property 'sonar.test.inclusions', '**/*Test.java' + property 'sonar.java.coveragePlugin', 'jacoco' + property 'sonar.coverage.jacoco.xmlReportPaths', jacocoDir.get().file("jacoco/index.xml").asFile + } +} + +jacoco { + toolVersion = "0.8.8" +} + jacocoTestReport { dependsOn test reports {