Skip to content

Commit

Permalink
[FEAT]: SonarQube Test
Browse files Browse the repository at this point in the history
  • Loading branch information
phonil committed Apr 13, 2024
1 parent 4f52d27 commit b5d2059
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build

on:
push:
branches:
- test


jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions: read-all
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- 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: Make Gradle Wrapper script executable
run: chmod +x ./gradlew

- name: Build and analyze
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: ./gradlew build -x test sonar --info
18 changes: 18 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'java'
id "org.sonarqube" version "4.4.1.3373"
id 'org.springframework.boot' version '3.1.3'
id 'io.spring.dependency-management' version '1.1.3'
id 'jacoco'
Expand Down Expand Up @@ -66,6 +67,9 @@ dependencies {
implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'javax.xml.bind:jaxb-api:2.3.0'

// SonarQube
implementation 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.3'

// test container
testImplementation "org.testcontainers:junit-jupiter:1.17.2"
testImplementation "org.testcontainers:mysql:1.17.2"
Expand All @@ -74,6 +78,20 @@ dependencies {
testImplementation("org.springframework.cloud:spring-cloud-contract-wiremock")
}

sonarqube {
properties {
property "sonar.projectKey", "sonar-user"
property "sonar.projectName", "sonar-user"
// property "sonar.sources", "src" // 소스 경로
// property "sonar.language", "java" // 언어
// property "sonar.java.source", "17"
// property "sonar.sourceEncoding", "UTF-8"
// property "sonar.profile", "Sonar way" // SonarQube 에서 분석할 때 적용할 프로필(분석할 수준 설정)
// property "sonar.java.binaries", "${buildDir}/classes" // 자바 클래스 파일위치
// property "sonar.test.inclusions", "**/*Test.java" // 코드 분석에 사용할 테스트 소스
}
}

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
Expand Down

0 comments on commit b5d2059

Please sign in to comment.