Skip to content

Commit ebe911d

Browse files
authored
Merge pull request #6 from YAPP-Github/ci/actions-auto
[Ci] 소나 클라우드, 인프라 변경 감지 추가
2 parents 3df89e4 + b86fb5e commit ebe911d

File tree

5 files changed

+88
-41
lines changed

5 files changed

+88
-41
lines changed

.github/pull-request-template.md

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,5 @@
1-
## 🚀 개요
1+
## 개요
22

3-
<!-- 변경 사항 및 관련 이슈에 대해 간단하게 작성해주세요. 어떻게보다 무엇을 왜 수정했는지 설명해주세요. -->
3+
## 🧾 관련 이슈
44

5-
## 🧾 관련 이슈 (Jira 연동 예정)
6-
7-
<!-- JIRA 이슈 키를 정확히 작성해주세요. 예: PROJ-123 -->
8-
Jira Issue: `PROJ-123`
9-
10-
## 📗 유형
11-
12-
- [ ] 새로운 기능 추가
13-
- [ ] 버그 수정
14-
- [ ] 코드에 영향을 주지 않는 변경사항(오타 수정, 탭 사이즈 변경, 변수명 변경)
15-
- [ ] 코드 리팩토링
16-
- [ ] 주석 추가 및 수정
17-
- [ ] 문서 수정
18-
- [ ] 테스트 추가, 테스트 리팩토링
19-
- [ ] 빌드 부분 혹은 패키지 매니저 수정
20-
- [ ] 파일 혹은 폴더명 수정
21-
- [ ] 파일 혹은 폴더 삭제
22-
- [ ] CI/CD 설정 수정
23-
- [ ] 의존성 버전 변경 / 업데이트
24-
25-
## 🔎 상세 내용
26-
27-
## ✅ Checklist
28-
29-
PR이 다음 요구 사항을 충족하는지 확인하세요.
30-
31-
- [ ] 커밋 메시지 컨벤션에 맞게 작성했습니다.
32-
- [ ] 변경 사항에 대한 테스트를 했습니다.
5+
## 🔍 참고 사항 (선택)

.github/workflows/notify-discord-noti.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ name: Notify Discord on `/noti` Comment
22

33
on:
44
issue_comment:
5-
types: [created]
5+
types: [ created ]
66

77
jobs:
88
notify-on-noti-comment:
99
if: github.event.issue.pull_request
1010
runs-on: ubuntu-latest
11+
env:
12+
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
1113
steps:
1214
- name: Check for `/noti` keyword and send Discord notification
1315
run: |
@@ -16,12 +18,12 @@ jobs:
1618
AUTHOR="${{ github.event.comment.user.login }}"
1719
1820
if echo "$COMMENT_BODY" | grep -q "/noti"; then
19-
CONTENT="📣 알림 요청이 감지되었습니다!\n🔗 ${PR_URL}\n🙋 작성자: ${AUTHOR}\n💬 댓글: ${COMMENT_BODY}"
21+
CONTENT=$(printf "📣 알림 요청이 감지되었습니다!\n🔗 %s\n🙋 작성자: %s\n💬 댓글: %s" "$PR_URL" "$AUTHOR" "$COMMENT_BODY")
2022
2123
curl -H "Content-Type: application/json" \
2224
-X POST \
23-
-d "{\"content\": \"${CONTENT}\"}" \
24-
${{ secrets.DISCORD_WEBHOOK }}
25+
-d "$(jq -n --arg content "$CONTENT" '{content: $content}')" \
26+
"$DISCORD_WEBHOOK"
2527
else
2628
echo "No /noti found. Skipping notification."
2729
fi

.github/workflows/notify-discord-pr.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
name: Notify Discord on PR or Review
2-
31
on:
42
pull_request:
53
types: [ opened ]
@@ -10,7 +8,8 @@ jobs:
108
notify-discord:
119
runs-on: ubuntu-latest
1210
steps:
13-
- name: Send Discord Webhook
11+
- name: Send Discord Webhook, Skip if review is just a comment
12+
if: github.event.review.state != 'commented'
1413
run: |
1514
PR_URL="https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number || github.event.pull_request_review.pull_request.number }}"
1615
AUTHOR="${{ github.event.pull_request.user.login || github.event.review.user.login }}"

.github/workflows/sonarcloud.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: sonarCloud
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Java
19+
uses: actions/setup-java@v3
20+
with:
21+
java-version: 21
22+
distribution: 'temurin'
23+
24+
- name: Grant execute permission for gradlew
25+
run: chmod +x ./gradlew
26+
27+
- name: Cache SonarCloud packages
28+
uses: actions/cache@v3
29+
with:
30+
path: ~/.sonar/cache
31+
key: ${{ runner.os }}-sonar
32+
restore-keys: ${{ runner.os }}-sonar
33+
34+
- name: Run tests and SonarCloud scan
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
38+
run: ./gradlew test jacocoTestReport sonar --info

build.gradle

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ plugins {
77
// Rest Docs & Swagger UI
88
id 'com.epages.restdocs-api-spec' version '0.18.2'
99
id 'org.hidetake.swagger.generator' version '2.18.2'
10+
11+
// Jacoco, sonarcloud
12+
id 'jacoco'
13+
id("org.sonarqube") version "6.2.0.5505"
1014
}
1115

1216
group = 'baegam'
@@ -18,6 +22,22 @@ java {
1822
}
1923
}
2024

25+
jacoco {
26+
toolVersion = "0.8.12"
27+
}
28+
29+
sonarqube {
30+
properties {
31+
property "sonar.projectKey", "baegam_timeeat"
32+
property "sonar.organization", "baegam"
33+
property "sonar.host.url", "https://sonarcloud.io"
34+
property 'sonar.sourceEncoding', 'UTF-8'
35+
property 'sonar.java.coveragePlugin', 'jacoco'
36+
property "sonar.coverage.jacoco.xmlReportPaths",
37+
layout.buildDirectory.file("reports/jacoco/test/jacocoTestReport.xml").get().asFile.path
38+
}
39+
}
40+
2141
configurations {
2242
compileOnly {
2343
extendsFrom annotationProcessor
@@ -65,6 +85,21 @@ bootJar {
6585
tasks.named('test', Test) {
6686
outputs.dir snippetsDir
6787
useJUnitPlatform()
88+
finalizedBy tasks.jacocoTestReport
89+
}
90+
91+
tasks.named('jacocoTestReport', JacocoReport) {
92+
dependsOn test
93+
reports {
94+
xml.required.set(true)
95+
html.required.set(true)
96+
}
97+
sourceDirectories.setFrom(files(sourceSets.main.allSource.srcDirs))
98+
classDirectories.setFrom(files(sourceSets.main.output))
99+
100+
executionData.setFrom(
101+
layout.buildDirectory.file("jacoco/test.exec").map { it.asFile }
102+
)
68103
}
69104

70105
generateSwaggerUI {
@@ -81,10 +116,10 @@ generateSwaggerUI {
81116

82117
openapi3 {
83118
servers = [ // 서버 상황에 맞춰 추가 예정
84-
{
85-
url = "http://localhost:8080"
86-
description = "Local Server"
87-
}
119+
{
120+
url = "http://localhost:8080"
121+
description = "Local Server"
122+
}
88123
]
89124
title = "백암 순대 API" // 수정 예정
90125
description = "백암 순대 API" // 수정 예정

0 commit comments

Comments
 (0)