Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAC-306 deploy : sonarCloud 추가 #104

Merged
merged 23 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3a15ff7
RAC-306 deploy : sonarCloud 추가
ywj9811 Feb 1, 2024
d2cf9be
RAC-306 deploy : sonarCloud 플러그인 추가
ywj9811 Feb 1, 2024
46d6386
RAC-306 deploy : sonarCloud 플러그인 수정
ywj9811 Feb 1, 2024
6945b08
RAC-306 deploy : sonarCloud 플러그인 수정
ywj9811 Feb 1, 2024
11ec06a
RAC-306 deploy : stackTrace추가
ywj9811 Feb 1, 2024
b1aa9d5
RAC-306 fix : error라인 삭제
ywj9811 Feb 1, 2024
a67801a
RAC-306 deploy : workflow 수정
ywj9811 Feb 1, 2024
8515261
RAC-306 deploy : jacoco 추가
ywj9811 Feb 1, 2024
f142ec3
RAC-306 deploy : 워크플로우 수정
ywj9811 Feb 1, 2024
6e08b52
RAC-306 deploy : sonar 플러그인 추가 및 workflow수정
ywj9811 Feb 1, 2024
74d5422
RAC-306 deploy : jacoco 추가
ywj9811 Feb 1, 2024
93ec48d
RAC-306 deploy : application.yml 읽도록 수정
ywj9811 Feb 1, 2024
70d1a2b
RAC-306 deploy : sonarcloud workflow 수정
ywj9811 Feb 1, 2024
3c2de95
RAC-306 deploy : CI와 sonarCloud 통합
ywj9811 Feb 1, 2024
7e940ea
RAC-306 deploy : pr시 동작하도록 수정
ywj9811 Feb 1, 2024
4d4c3bb
RAC-306 deploy : pr시 동작하도록 수정
ywj9811 Feb 1, 2024
5533191
RAC-306 test : 빌드 실패 테스트
ywj9811 Feb 1, 2024
b4fc778
RAC-306 test : 테스트 성공하도록 수정
ywj9811 Feb 1, 2024
7d1cd8d
RAC-306 deploy : workflow 내용 수정
ywj9811 Feb 1, 2024
3b5b0e5
RAC-306 deploy : jacoco 설정 추가
ywj9811 Feb 1, 2024
271f595
RAC-306 deploy : workFlow SonarScan 수정
ywj9811 Feb 1, 2024
b1bed7a
RAC-306 fix : jacoco 설정 수정
ywj9811 Feb 1, 2024
8098f9d
RAC-306 deploy : CI 분리
ywj9811 Feb 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions .github/workflows/CI-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,37 @@ jobs:
APPLICATION: ${{ secrets.APPLICATION }}

steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Create application.yml
run: |
echo "${{env.APPLICATION}}" > ./src/main/resources/application.yml
- name: Grant execute permission for gradlew
run: chmod +x gradlew
working-directory: ${{ env.working-directory }}
- name: Build with Gradle
run: ./gradlew build
working-directory: ${{ env.working-directory }}
- name: Cleanup Gradle Cache
if: ${{ always() }}
run: |
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'

- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Create application.yml
run: |
echo "${{env.APPLICATION}}" > ./src/main/resources/application.yml

- name: Grant execute permission for gradlew
run: chmod +x gradlew
working-directory: ${{ env.working-directory }}

- name: Build with Gradle
run: ./gradlew build
working-directory: ${{ env.working-directory }}

- name: Cleanup Gradle Cache
if: ${{ always() }}
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
rm -f ~/.gradle/caches/modules-2/gc.properties
53 changes: 53 additions & 0 deletions .github/workflows/SonarCloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: SonarCloudScan
on:
pull_request:
branches: [ "develop" ]
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
env:
working-directory: ./
APPLICATION: ${{ secrets.APPLICATION }}

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'

- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Create application.yml
run: |
echo "${{env.APPLICATION}}" > ./src/main/resources/application.yml

- name: Grant execute permission for gradlew
run: chmod +x gradlew
working-directory: ${{ env.working-directory }}

- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: SonarCloud scan
run: ./gradlew sonar --info --stacktrace
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
119 changes: 108 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.1.4'
id 'io.spring.dependency-management' version '1.1.3'

id 'jacoco'
id 'org.sonarqube' version '4.4.1.3373'
}


group = 'com'
version = '0.0.1-SNAPSHOT'

Expand All @@ -22,8 +26,8 @@ repositories {
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-amqp'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-amqp'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.boot:spring-boot-starter-security'
Expand All @@ -40,18 +44,18 @@ dependencies {
testCompileOnly 'org.springframework.security:spring-security-test'
testAnnotationProcessor 'org.springframework.security:spring-security-test'

// https://mvnrepository.com/artifact/com.slack.api/slack-api-client
// 슬랙 api 추가
implementation group: 'com.slack.api', name: 'slack-api-client', version: '1.29.2'
// https://mvnrepository.com/artifact/com.slack.api/slack-api-client
// 슬랙 api 추가
implementation group: 'com.slack.api', name: 'slack-api-client', version: '1.29.2'

// https://mvnrepository.com/artifact/com.slack.api/slack-api-client
// 슬랙 api 추가
implementation group: 'com.slack.api', name: 'slack-api-client', version: '1.29.2'
// 슬랙 api 추가
implementation group: 'com.slack.api', name: 'slack-api-client', version: '1.29.2'

implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
implementation 'io.jsonwebtoken:jjwt-impl:0.11.5'
implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5'
//jwt 추가
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
implementation 'io.jsonwebtoken:jjwt-impl:0.11.5'
implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5'
//jwt 추가

// https://mvnrepository.com/artifact/org.springdoc/springdoc-openapi-starter-webmvc-ui
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'
Expand All @@ -77,4 +81,97 @@ dependencies {

tasks.named('test') {
useJUnitPlatform()
finalizedBy 'jacocoTestReport'
}

def jacocoDir = layout.buildDirectory.dir("reports/")

def QDomains = []
for (qPattern in '*.QA'..'*.QZ') { // qPattern = '*.QA', '*.QB', ... '*.QZ'
QDomains.add(qPattern + '*')
}

def jacocoExcludePatterns = [
// 측정 안하고 싶은 패턴
"**/*Application*",
"**/dto/**",
"**/*Config*",
"**/*Exception*",
"**/*Request*",
"**/*Response*",
"**/*Dto*",
"**/*Filter*",
"**/*Resolver*",
"**/entity/**",
"**/test/**",
"**/resources/**"
]

sonar {
properties {
property 'sonar.host.url', 'https://sonarcloud.io'
property 'sonar.organization', 'we-are-raccoons'
property 'sonar.projectKey', 'WE-ARE-RACCOONS_postgraduate-back'
property 'sonar.sources', 'src'
property 'sonar.language', 'java'
property 'sonar.sourceEncoding', 'UTF-8'
property 'sonar.test.exclusions', jacocoExcludePatterns.join(',')
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.11"
}

jacocoTestReport {
dependsOn test // 테스트가 수행되어야만 report를 생성할 수 있도록 설정
reports {
html.required.set(true)
xml.required.set(true)
csv.required.set(true)
html.destination jacocoDir.get().file("jacoco/index.html").asFile
xml.destination jacocoDir.get().file("jacoco/index.xml").asFile
csv.destination jacocoDir.get().file("jacoco/index.csv").asFile
}

afterEvaluate {
classDirectories.setFrom(
files(classDirectories.files.collect {
fileTree(dir: it, excludes: jacocoExcludePatterns + QDomains) // Querydsl 관련 제거
})
)
}
finalizedBy jacocoTestCoverageVerification
}

jacocoTestCoverageVerification {

violationRules {
rule {
// rule 활성화
enabled = true

// 클래스 단위로 룰 체크
element = 'CLASS'

// 라인 커버리지를 최소 80% 만족
// limit {
// counter = 'LINE'
// value = 'COVEREDRATIO'
// minimum = 0.80
// }

// 브랜치 커버리지를 최소 80% 만족
// limit {
// counter = 'BRANCH'
// value = 'COVEREDRATIO'
// minimum = 0.80
// }

excludes = jacocoExcludePatterns + QDomains
}
}
}
Loading