Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
36 changes: 36 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## ✅ PR 유형
> 어떤 변경 사항이 있었나요?

- [ ] 새로운 기능 추가
- [ ] 버그 수정
- [ ] 코드에 영향을 주지 않는 변경사항(오타 수정, 탭 사이즈 변경, 변수명 변경)
- [ ] 코드 리팩토링
- [ ] 주석 추가 및 수정
- [ ] 문서 수정
- [ ] 빌드 부분 혹은 패키지 매니저 수정
- [ ] 파일 혹은 폴더명 수정
- [ ] 파일 혹은 폴더 삭제

---

## 🚀 작업 내용
> 이번 PR에서 작업한 내용을 구체적으로 설명해주세요. (이미지 첨부 가능)

- 작업한 내용 1
- 작업한 내용 2

---

## 📝️ 관련 이슈
> 본인이 작업한 내용이 어떤 Issue와 관련이 있는지 작성해주세요.

ex)
- Fixes : #00 (수정중인 이슈)
- Resolves : #100 (무슨 이슈를 해결했는지)
- Ref : #00 #01 (참고할 이슈)
- Related to : #00 #01 (해당 커밋과 관련)

---

## 💬 기타 사항 or 추가 코멘트
> 남기고 싶은 말, 참고 블로그 등이 있다면 기록해주세요.
54 changes: 54 additions & 0 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: SonarCloud Analysis

on:
push:
branches: [develop]
pull_request:
branches: [develop]

permissions:
contents: read
checks: write
pull-requests: write

jobs:
sonarcloud:
runs-on: ubuntu-latest

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

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

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


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

- name: Grant execute permission for Gradle
run: chmod +x gradlew

# SonarCloud 분석 (커버리지 연동)
- name: Build, Test, and Analyze (SonarCloud)
run: ./gradlew clean build jacocoTestReport sonarqube
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
29 changes: 28 additions & 1 deletion .github/workflows/test-cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ on:
pull_request:
branches: [develop]

permissions:
checks: write
pull-requests: write
contents: read

jobs:
build-and-test:
name: Build & Test
Expand All @@ -21,19 +26,41 @@ jobs:
distribution: 'temurin'
java-version: '21'

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

- name: Grant execute permission for Gradle
run: chmod +x gradlew

- name: Build & Run Tests
run: |
./gradlew clean build -x test
./gradlew clean build

- name: 빌드 결과 저장
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: build/libs/*.jar

- name: 테스트 결과를 PR 코멘트로 출력
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: '**/build/test-results/test/TEST-*.xml'

- name: 테스트 실패 시, 오류가 발생한 코드 라인에 코멘트 추가
uses: mikepenz/action-junit-report@v4
if: always()
with:
report_paths: '**/build/test-results/test/TEST-*.xml'

docker-build-and-push:
name: Build & Push Docker Image
runs-on: ubuntu-latest
Expand Down
24 changes: 24 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.4.1'
id 'io.spring.dependency-management' version '1.1.7'
id 'org.sonarqube' version '5.0.0.4638'
id 'jacoco'
}

group = 'kr.woong2e'
Expand All @@ -13,6 +15,27 @@ java {
}
}

sonarqube {
properties {
property "sonar.projectKey", "woong2e_MYPAGE_BE"
property "sonar.organization", "woong2e"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco/test/jacocoTestReport.xml"
}
}

jacoco {
toolVersion = "0.8.11"
}

jacocoTestReport {
dependsOn test
reports {
xml.required = true
html.required = true
}
}

configurations {
compileOnly {
extendsFrom annotationProcessor
Expand Down Expand Up @@ -41,6 +64,7 @@ dependencies {
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

@SpringBootTest
@ActiveProfiles("test")
class HomepageApplicationTests {

@Test
Expand Down
49 changes: 49 additions & 0 deletions src/test/resources/application-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
spring:
config:
activate:
on-profile: test

application:
name: "homepage"

datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:~/test
username: sa
password:

jpa:
show_sql: true
hibernate:
ddl-auto: create

security:
user:
name: testuser
password: testpassword

mail:
host: smtp.example.com
port: 1025
username: [email protected]
password: examplePassword
properties:
mail:
smtp:
auth: true
starttls:
enable: true
required: true


jwt:
secret: JwtSecretKeyExample

management:
endpoints:
web:
exposure:
include: health
endpoint:
health:
show-details: always