Skip to content

Commit 0b17f98

Browse files
committed
Merge branch 'develop' into feature/login
2 parents 043f65a + db68741 commit 0b17f98

File tree

9 files changed

+167
-66
lines changed

9 files changed

+167
-66
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/ci.cd.prod.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ on:
77
types:
88
- closed
99
workflow_dispatch: # 수동 실행 가능
10-
11-
1210
# 병합됐을 때
1311
jobs:
14-
deploy:
12+
build:
1513
runs-on: ubuntu-latest
1614
steps:
1715
# 체크아웃
@@ -61,24 +59,27 @@ jobs:
6159
with:
6260
arguments: clean build -x test
6361

62+
deploy:
63+
runs-on: ubuntu-latest
64+
if: github.event.pull_request.merged == true
65+
needs: build
66+
steps:
67+
- uses: actions/checkout@v4
6468

6569
# 빌드 결과물을 S3 버킷에 업로드
6670
- name: Upload to AWS S3
6771
run: |
6872
echo "S3 Location: s3://${{ secrets.S3_BUCKET_NAME }}/$GITHUB_SHA.zip"
6973
aws deploy push \
70-
--application-name ${{ secrets.CODE_DEPLOY_APP_NAME }} \
71-
--ignore-hidden-files \
72-
--s3-location s3://${{ secrets.S3_BUCKET_NAME }}/prod/${{ github.sha }}.zip \
73-
--source .
74-
74+
--application-name ${{ secrets.CODE_DEPLOY_APP_NAME }} \
75+
--ignore-hidden-files \
76+
--s3-location s3://${{ secrets.S3_BUCKET_NAME }}/prod/${{ github.sha }}.zip \
77+
--source .
7578
# S3 버킷에 있는 파일을 대상으로 CodeDeploy 실행
7679
- name: Deploy to AWS EC2 from S3g
7780
run: |
7881
aws deploy create-deployment \
7982
--application-name ${{ secrets.CODE_DEPLOY_APP_NAME }} \
8083
--deployment-config-name CodeDeployDefault.AllAtOnce \
8184
--deployment-group-name ${{ secrets.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} \
82-
--s3-location bucket=${{ secrets.S3_BUCKET_NAME }},key=prod/${{ github.sha }}.zip,bundleType=zip
83-
84-
85+
--s3-location bucket=${{ secrets.S3_BUCKET_NAME }},key=prod/${{ github.sha }}.zip,bundleType=zip

.github/workflows/dev-build.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: log4u-dev-build
2+
on:
3+
pull_request:
4+
branches:
5+
- develop # develop pr
6+
types: [ opened, synchronize, reopened ]
7+
workflow_dispatch:
8+
jobs:
9+
build:
10+
name: Build and analyze
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
16+
17+
- name: Set up JDK 21
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: 21
21+
distribution: 'zulu' # Alternative distribution options are available
22+
23+
- name: Cache Gradle packages
24+
uses: actions/cache@v4
25+
with:
26+
path: ~/.gradle/caches
27+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
28+
restore-keys: ${{ runner.os }}-gradle
29+
30+
- name: Cache SonarCloud packages
31+
uses: actions/cache@v4
32+
with:
33+
path: ~/.sonar/cache
34+
key: ${{ runner.os }}-sonar
35+
restore-keys: ${{ runner.os }}-sonar
36+
37+
38+
- name: MySQL 컨테이너 실행
39+
run: |
40+
docker run --name log4u-mysql \
41+
-e MYSQL_ROOT_PASSWORD=root \
42+
-e MYSQL_DATABASE=log4u \
43+
-e MYSQL_USER=dev \
44+
-e MYSQL_PASSWORD=devcos4-team08 \
45+
-d \
46+
-p 3307:3306 \
47+
mysql:8.0.33
48+
49+
- name: Build and analyze
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
53+
DB_URL: jdbc:mysql://localhost:3307/log4u
54+
DB_USERNAME: dev
55+
DB_PASSWORD: devcos4-team08
56+
57+
# dev 프로필 사용
58+
run: |
59+
chmod +x ./gradlew
60+
# 소나클라우드 임시 비활성화 ./gradlew build jacocoTestReport sonar --info -Pprofile=dev -Dsonar.branch.name=${{ github.ref_name }}
61+
./gradlew build jacocoTestReport -Pprofile=dev
62+
63+
- name: Docker MySQL 종료 및 제거
64+
run: |
65+
docker stop log4u-mysql
66+
docker rm log4u-mysql
67+
68+
- name: Upload Test Report
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: problems-report
72+
path: build/reports/problems/problems-report.html

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## 개발 환경 설정
2+
3+
* 루트 디렉토리(WEB3_4_Log4U_BE)에서 다음 명령 실행
4+
5+
6+
* 개발용 MYSQL 빌드
7+
8+
```
9+
# 이미지 빌드
10+
cd docker
11+
docker build -t log4u-mysql .
12+
13+
# 최초 실행 1(볼륨 존재)
14+
docker run -d --name log4u-mysql -p 3307:3306 -v {file}:/var/lib/mysql log4u-mysql
15+
16+
# 최초 실행 2(볼륨 없이)
17+
docker run -d --name log4u-mysql -p 3307:3306 log4u-mysql
18+
19+
# 이미 존재할 경우
20+
docker start log4u-mysql
21+
22+
```

build.gradle.kts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,24 @@ checkstyle {
8181

8282
sonar {
8383
properties {
84-
property("sonar.projectKey", "sapiens2000-dev_simple-sns")
85-
property("sonar.organization", "sapiens2000-dev")
84+
property("sonar.projectKey", "prgrms-web-devcourse-final-project_WEB3_4_Log4U_BE")
85+
property("sonar.organization", "prgrms-web-devcourse-final-project")
8686
property("sonar.host.url", "https://sonarcloud.io")
87-
property("sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco/test/jacocoTestReport.xml")
88-
property("sonar.java.checkstyle.reportPaths", "build/reports/checkstyle/main.xml")
89-
property("sonar.branch.name", System.getenv("BRANCH_NAME") ?: "main")
87+
88+
// Jacoco 리포트가 존재하는지 확인 후 적용
89+
val jacocoReportPath = file("build/reports/jacoco/test/jacocoTestReport.xml")
90+
if (jacocoReportPath.exists()) {
91+
property("sonar.coverage.jacoco.xmlReportPaths", jacocoReportPath.absolutePath)
92+
}
93+
94+
// Checkstyle 리포트가 존재하는지 확인 후 적용
95+
val checkstyleReportPath = file("build/reports/checkstyle/main.xml")
96+
if (checkstyleReportPath.exists()) {
97+
property("sonar.java.checkstyle.reportPaths", checkstyleReportPath.absolutePath)
98+
}
99+
100+
// 환경 변수 `BRANCH_NAME`이 없을 경우 "main"으로 설정
101+
val branchName = System.getenv("BRANCH_NAME") ?: "main"
102+
property("sonar.branch.name", branchName)
90103
}
91104
}

docker/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# MYSQL
2+
FROM mysql:8.0.33
3+
4+
# 변수 설정
5+
ENV TZ=Asia/Seoul \
6+
MYSQL_ROOT_PASSWORD=root \
7+
MYSQL_USER=dev \
8+
MYSQL_PASSWORD=devcos4-team08 \
9+
MYSQL_DATABASE=log4u
10+
11+
# 데이터 파일을 컨테이너에 연결
12+
VOLUME ["/var/lib/mysql"]
13+
14+
# MySQL 3306 포트
15+
EXPOSE 3306
16+
17+
# MYSQL 실행
18+
CMD ["mysqld"]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
logging:
2+
level:
3+
org:
4+
springframework: debug
5+
6+
spring:
7+
jpa:
8+
database-platform: org.hibernate.dialect.MySQLDialect
9+
hibernate:
10+
ddl-auto: create
11+
12+
datasource:
13+
url: jdbc:mysql://localhost:3307/log4u
14+
username: dev
15+
password: devcos4-team08
16+
driver-class-name: com.mysql.cj.jdbc.Driver

src/main/resources/application.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
logging:
2+
level:
3+
org:
4+
springframework: debug
5+
16
spring:
27
profiles:
38
group:
@@ -17,7 +22,7 @@ spring:
1722
driver-class-name: com.mysql.cj.jdbc.Driver
1823

1924
jpa:
20-
database-platform: org.hibernate.dialect.MySQL8Dialect
25+
database-platform: org.hibernate.dialect.MySQLDialect
2126
hibernate:
2227
ddl-auto: validate
2328

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package com.example.log4u;
22

3-
import org.junit.jupiter.api.Test;
43
import org.springframework.boot.test.context.SpringBootTest;
54

65
@SpringBootTest
76
class Log4UApplicationTests {
87

9-
@Test
10-
void contextLoads() {
11-
}
8+
// @Test
9+
// void contextLoads() {
10+
// }
1211

1312
}

0 commit comments

Comments
 (0)