From b4040ee2fcc7423ba50c5e08db1122a715ec8e85 Mon Sep 17 00:00:00 2001 From: songhyeonpk Date: Sun, 16 Mar 2025 15:59:00 +0900 Subject: [PATCH 1/6] =?UTF-8?q?chore:=20h2=20=EC=9D=98=EC=A1=B4=EC=84=B1?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 -- 1 file changed, 2 deletions(-) diff --git a/build.gradle b/build.gradle index 7bdb570..2c5d574 100644 --- a/build.gradle +++ b/build.gradle @@ -36,13 +36,11 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-mail' - runtimeOnly 'com.h2database:h2' runtimeOnly 'org.postgresql:postgresql' compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' implementation 'io.hypersistence:hypersistence-utils-hibernate-63:3.9.3' - // Validation implementation 'org.springframework.boot:spring-boot-starter-validation' From 125e25d9d26055ae217174edf6b6fcc2a75ad7c3 Mon Sep 17 00:00:00 2001 From: songhyeonpk Date: Sun, 16 Mar 2025 15:59:47 +0900 Subject: [PATCH 2/6] =?UTF-8?q?chore:=20*.sql=20=ED=8C=8C=EC=9D=BC=20.giti?= =?UTF-8?q?gnore=20=EB=93=B1=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ca66177..5f9f806 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,7 @@ out/ .vscode/ ### env ### -.env \ No newline at end of file +.env + +### sql ### +*.sql \ No newline at end of file From c49f6aac7a175cb78cb86c3b67ce4a3f4f10f5e9 Mon Sep 17 00:00:00 2001 From: songhyeonpk Date: Sun, 16 Mar 2025 16:00:22 +0900 Subject: [PATCH 3/6] =?UTF-8?q?fix:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=ED=99=98=EA=B2=BD=20=EB=A1=9C=EA=B7=B8=20profile=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/logback-spring.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index e5d5a77..b0c786a 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -37,7 +37,7 @@ - + From 774eed6c306d499a10407b7d07a71efa71fce131 Mon Sep 17 00:00:00 2001 From: songhyeonpk Date: Sun, 16 Mar 2025 16:02:19 +0900 Subject: [PATCH 4/6] =?UTF-8?q?feat:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=ED=99=98=EA=B2=BD=EC=97=90=EC=84=9C=20=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=BB=A8=ED=85=8C=EC=9D=B4=EB=84=88=EB=A5=BC=20?= =?UTF-8?q?=EC=8B=A4=ED=96=89=ED=95=98=EA=B8=B0=20=EC=9C=84=ED=95=9C=20doc?= =?UTF-8?q?ker-compose-test.yml=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose-test.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 docker-compose-test.yml diff --git a/docker-compose-test.yml b/docker-compose-test.yml new file mode 100644 index 0000000..7d58b49 --- /dev/null +++ b/docker-compose-test.yml @@ -0,0 +1,14 @@ +services: + redis: + image: "redis:alpine" + ports: + - "6379:6379" + + postgres: + image: "postgres:alpine" + ports: + - "5432:5432" + environment: + POSTGRES_USER: test + POSTGRES_PASSWORD: test + POSTGRES_DB: "ftm_test_db" # DB 자동 생성 \ No newline at end of file From cb6b3042fb36abd3eb2c230677b9e22a4e268a76 Mon Sep 17 00:00:00 2001 From: songhyeonpk Date: Sun, 16 Mar 2025 17:52:29 +0900 Subject: [PATCH 5/6] =?UTF-8?q?chore:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=ED=99=98=EA=B2=BD=20db=20=EB=B3=80=EA=B2=BD=EC=97=90=20?= =?UTF-8?q?=EB=94=B0=EB=9D=BC=20=EC=84=A4=EC=A0=95=20=EB=B0=8F=20=EC=84=B8?= =?UTF-8?q?=ED=8C=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ftm/server/ServerApplicationTests.java | 5 +++++ src/test/resources/application-test.yml | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/ftm/server/ServerApplicationTests.java b/src/test/java/com/ftm/server/ServerApplicationTests.java index 5b67a07..325a20e 100644 --- a/src/test/java/com/ftm/server/ServerApplicationTests.java +++ b/src/test/java/com/ftm/server/ServerApplicationTests.java @@ -1,11 +1,16 @@ package com.ftm.server; import org.junit.jupiter.api.Test; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.TestPropertySource; @SpringBootTest +@ActiveProfiles("test") @TestPropertySource(locations = "file:.env") +@AutoConfigureTestDatabase( + replace = AutoConfigureTestDatabase.Replace.NONE) // 테스트 시 내장된 인메모리 DB를 사용하지 않는다는 설정 class ServerApplicationTests { @Test diff --git a/src/test/resources/application-test.yml b/src/test/resources/application-test.yml index 2f35b9c..5adcf85 100644 --- a/src/test/resources/application-test.yml +++ b/src/test/resources/application-test.yml @@ -4,14 +4,24 @@ spring: on-profile: "test" datasource: - url: jdbc:h2:mem:testDb;MODE=POSTGRESQL + url: jdbc:postgresql://localhost:5432/ftm_test_db + username: test + password: test + driver-class-name: org.postgresql.Driver jpa: - database-platform: org.hibernate.dialect.H2Dialect + database-platform: org.hibernate.dialect.PostgreSQLDialect hibernate: ddl-auto: none show-sql: true properties : hibernate: format_sql: true - default_batch_fetch_size: 1000 \ No newline at end of file + default_batch_fetch_size: 1000 + + sql: + init: + mode: always + schema-locations: classpath:test-schema.sql + data-locations: classpath:test-data.sql + From 4cf325345145b0a67ccc7d4bec0d3cde16c53cda Mon Sep 17 00:00:00 2001 From: songhyeonpk Date: Sun, 16 Mar 2025 17:53:37 +0900 Subject: [PATCH 6/6] =?UTF-8?q?chore:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=ED=99=98=EA=B2=BD=20db=20=EB=B3=80=EA=B2=BD=EC=97=90=20?= =?UTF-8?q?=EB=94=B0=EB=9D=BC=20=EC=9B=8C=ED=81=AC=ED=94=8C=EB=A1=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/develop_build_deploy.yml | 10 ++++++++++ .github/workflows/develop_pull_request.yml | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/.github/workflows/develop_build_deploy.yml b/.github/workflows/develop_build_deploy.yml index 2806e0d..7d8d7d9 100644 --- a/.github/workflows/develop_build_deploy.yml +++ b/.github/workflows/develop_build_deploy.yml @@ -25,6 +25,16 @@ jobs: java-version: '17' distribution: 'temurin' + # 테스트 환경에서 필요한 컨테이너 실행 (redis, postgres) + - name: Run Containers + run: docker compose -f ./docker-compose-test.yml up -d + + # 테스트 환경에서 필요한 스키마, 데이터 등록 + - name: Apply Schema and Data + run: | + echo "${{ secrets.SCHEMA_SQL }}" > src/test/resources/test-schema.sql + echo "${{ secrets.DATA_SQL }}" > src/test/resources/test-data.sql + # Gradlew 실행 권한 허용 - name: Grant Execute Permission for Gradlew run: chmod +x ./gradlew diff --git a/.github/workflows/develop_pull_request.yml b/.github/workflows/develop_pull_request.yml index 3085223..aebb5cd 100644 --- a/.github/workflows/develop_pull_request.yml +++ b/.github/workflows/develop_pull_request.yml @@ -20,6 +20,16 @@ jobs: java-version: '17' distribution: 'temurin' + # 테스트 환경에서 필요한 컨테이너 실행 (redis, postgres) + - name: Run Containers + run: docker compose -f ./docker-compose-test.yml up -d + + # 테스트 환경에서 필요한 스키마, 데이터 등록 + - name: Apply Schema and Data + run: | + echo "${{ secrets.SCHEMA_SQL }}" > src/test/resources/test-schema.sql + echo "${{ secrets.DATA_SQL }}" > src/test/resources/test-data.sql + # Gradlew 실행 권한 허용 - name: Grant Execute Permission for Gradlew run: chmod +x ./gradlew