From 8cc7d14a7bfbbfc52672fd2357228c6f2c3f6ac6 Mon Sep 17 00:00:00 2001 From: kyum-q <109158497+kyum-q@users.noreply.github.com> Date: Wed, 16 Oct 2024 16:20:40 +0900 Subject: [PATCH 01/11] =?UTF-8?q?refactor(rds):=20DataSourceConfig?= =?UTF-8?q?=EB=A5=BC=20=EB=AA=A8=EB=93=A0=20=ED=99=98=EA=B2=BD=EC=97=90=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9=EB=90=98=EB=8F=84=EB=A1=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../codezap/global/rds/DataSourceConfig.java | 1 - .../src/main/resources/application-local.yml | 26 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/codezap/global/rds/DataSourceConfig.java b/backend/src/main/java/codezap/global/rds/DataSourceConfig.java index 989cbfd99..fa1f9a6d6 100644 --- a/backend/src/main/java/codezap/global/rds/DataSourceConfig.java +++ b/backend/src/main/java/codezap/global/rds/DataSourceConfig.java @@ -21,7 +21,6 @@ @Configuration @RequiredArgsConstructor -@Profile("prod") @EnableJpaRepositories(basePackages = "codezap") public class DataSourceConfig { diff --git a/backend/src/main/resources/application-local.yml b/backend/src/main/resources/application-local.yml index e74358d99..a44bc9a62 100644 --- a/backend/src/main/resources/application-local.yml +++ b/backend/src/main/resources/application-local.yml @@ -2,5 +2,31 @@ spring: output: ansi: enabled: always + datasource: + write: + jdbc-url: ${MYSQL_WRITER_URL} + username: ${MYSQL_USER} + password: ${MYSQL_PASSWORD} + driver-class-name: com.mysql.cj.jdbc.Driver + read: + jdbc-url: ${MYSQL_READER_URL} + username: ${MYSQL_USER} + password: ${MYSQL_PASSWORD} + driver-class-name: com.mysql.cj.jdbc.Driver + flyway: + enabled: false + locations: classpath:db/migration + url: ${MYSQL_WRITER_URL} + username: ${MYSQL_USER} + password: ${MYSQL_PASSWORD} + jpa: + # open-in-view: false + hibernate: + ddl-auto: validate + properties: + hibernate: + dialect: codezap.template.repository.FullTextSearchMySQLDialect + data.web.pageable.one-indexed-parameters: true + cors: allowed-origins: http://localhost:3000 From 260a914555e4a04d388d040c9fd423f143af48d4 Mon Sep 17 00:00:00 2001 From: kyum-q <109158497+kyum-q@users.noreply.github.com> Date: Wed, 16 Oct 2024 17:00:33 +0900 Subject: [PATCH 02/11] =?UTF-8?q?refactor(rds):=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EA=B0=92=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/resources/application-local.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/backend/src/main/resources/application-local.yml b/backend/src/main/resources/application-local.yml index a44bc9a62..3eb3a47a0 100644 --- a/backend/src/main/resources/application-local.yml +++ b/backend/src/main/resources/application-local.yml @@ -16,9 +16,6 @@ spring: flyway: enabled: false locations: classpath:db/migration - url: ${MYSQL_WRITER_URL} - username: ${MYSQL_USER} - password: ${MYSQL_PASSWORD} jpa: # open-in-view: false hibernate: From 655d1ad936c625bf896650a3ff22e468ddcb4f27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B2=BD=EB=AF=B8?= <109158497+kyum-q@users.noreply.github.com> Date: Wed, 16 Oct 2024 17:05:33 +0900 Subject: [PATCH 03/11] =?UTF-8?q?refactor(workflows):=20=20DB=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=ED=99=98=EA=B2=BD=20=EB=B3=80=EC=88=98=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend_ci.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/backend_ci.yml b/.github/workflows/backend_ci.yml index ceb015d92..95e186535 100644 --- a/.github/workflows/backend_ci.yml +++ b/.github/workflows/backend_ci.yml @@ -23,9 +23,12 @@ jobs: mysql database: ${{ secrets.MYSQL_DATABASE }} mysql root password: ${{ secrets.MYSQL_PASSWORD }} - - name: DB 설정 파일 가져오기 - working-directory: ./backend/src/main/resources - run: echo "${{ secrets.APPLICATION_DB_YAML }}" > application-db.yml + - name: 환경 변수 등록 + run: | + export MYSQL_WRITER_URL=${{ secrets.MYSQL_WRITER_URL }} + export MYSQL_READER_URL=${{ secrets.MYSQL_READER_URL }} + export MYSQL_USER=${{ secrets.MYSQL_USER }} + export MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }} - name: gradle 캐싱 uses: gradle/actions/setup-gradle@v4 From 12fdad8fcd097f8b7c09f6c8ecbb8ed2ffd5492d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B2=BD=EB=AF=B8?= <109158497+kyum-q@users.noreply.github.com> Date: Wed, 16 Oct 2024 17:11:59 +0900 Subject: [PATCH 04/11] =?UTF-8?q?fix(workflows):=20=ED=99=98=EA=B2=BD=20?= =?UTF-8?q?=EB=B3=80=EC=88=98=20=EC=84=A4=EC=A0=95=20=EB=A1=9C=EC=A7=81=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/backend_ci.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/backend_ci.yml b/.github/workflows/backend_ci.yml index 95e186535..8187fbb32 100644 --- a/.github/workflows/backend_ci.yml +++ b/.github/workflows/backend_ci.yml @@ -22,14 +22,7 @@ jobs: mysql version: ${{ secrets.MYSQL_VERSION }} mysql database: ${{ secrets.MYSQL_DATABASE }} mysql root password: ${{ secrets.MYSQL_PASSWORD }} - - - name: 환경 변수 등록 - run: | - export MYSQL_WRITER_URL=${{ secrets.MYSQL_WRITER_URL }} - export MYSQL_READER_URL=${{ secrets.MYSQL_READER_URL }} - export MYSQL_USER=${{ secrets.MYSQL_USER }} - export MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }} - + - name: gradle 캐싱 uses: gradle/actions/setup-gradle@v4 @@ -40,5 +33,10 @@ jobs: distribution: temurin - name: 테스트 코드 실행 + env: + MYSQL_WRITER_URL: ${{ secrets.MYSQL_WRITER_URL }} + MYSQL_READER_URL: ${{ secrets.MYSQL_READER_URL }} + MYSQL_USER: ${{ secrets.MYSQL_USER }} + MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }} run: ./gradlew test working-directory: ./backend From c895984bc09720785e83ab45034b9702a4aa3e99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B2=BD=EB=AF=B8?= <109158497+kyum-q@users.noreply.github.com> Date: Wed, 16 Oct 2024 17:57:54 +0900 Subject: [PATCH 05/11] =?UTF-8?q?fix(workflows):=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EA=B0=80=EC=A0=B8=EC=98=A4=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend_ci.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/backend_ci.yml b/.github/workflows/backend_ci.yml index 8187fbb32..6fe354bde 100644 --- a/.github/workflows/backend_ci.yml +++ b/.github/workflows/backend_ci.yml @@ -22,7 +22,11 @@ jobs: mysql version: ${{ secrets.MYSQL_VERSION }} mysql database: ${{ secrets.MYSQL_DATABASE }} mysql root password: ${{ secrets.MYSQL_PASSWORD }} - + + - name: 설정 파일 가져오기 + working-directory: ./backend/src/main/resources + run: echo "${{ secrets.APPLICATION_YAML }}" > application-local.yml + - name: gradle 캐싱 uses: gradle/actions/setup-gradle@v4 @@ -33,10 +37,5 @@ jobs: distribution: temurin - name: 테스트 코드 실행 - env: - MYSQL_WRITER_URL: ${{ secrets.MYSQL_WRITER_URL }} - MYSQL_READER_URL: ${{ secrets.MYSQL_READER_URL }} - MYSQL_USER: ${{ secrets.MYSQL_USER }} - MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }} run: ./gradlew test working-directory: ./backend From eab94644a09cb710485607b2c060eb61727853a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=AC=EC=9A=B0?= Date: Wed, 16 Oct 2024 19:04:01 +0900 Subject: [PATCH 06/11] =?UTF-8?q?fix:=20ci=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend_ci.yml | 3 +++ backend/src/main/resources/application-local.yml | 2 +- backend/src/main/resources/application.yml | 1 - .../java/codezap/global/repository/JpaRepositoryTest.java | 3 ++- .../repository/TemplateSearchJpaRepositoryTest.java | 3 ++- backend/src/test/resources/application-local.yml | 6 ------ backend/src/test/resources/application.yml | 5 ----- 7 files changed, 8 insertions(+), 15 deletions(-) delete mode 100644 backend/src/test/resources/application-local.yml delete mode 100644 backend/src/test/resources/application.yml diff --git a/.github/workflows/backend_ci.yml b/.github/workflows/backend_ci.yml index 6fe354bde..25b723047 100644 --- a/.github/workflows/backend_ci.yml +++ b/.github/workflows/backend_ci.yml @@ -39,3 +39,6 @@ jobs: - name: 테스트 코드 실행 run: ./gradlew test working-directory: ./backend + + - name: 환경변수 주입 + run: ${{ secrets.APPLICATION_YML }} diff --git a/backend/src/main/resources/application-local.yml b/backend/src/main/resources/application-local.yml index 3eb3a47a0..a7bf79934 100644 --- a/backend/src/main/resources/application-local.yml +++ b/backend/src/main/resources/application-local.yml @@ -19,7 +19,7 @@ spring: jpa: # open-in-view: false hibernate: - ddl-auto: validate + ddl-auto: create properties: hibernate: dialect: codezap.template.repository.FullTextSearchMySQLDialect diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml index 520dec2c9..d9638774d 100644 --- a/backend/src/main/resources/application.yml +++ b/backend/src/main/resources/application.yml @@ -2,4 +2,3 @@ spring: profiles: active: - local - - db diff --git a/backend/src/test/java/codezap/global/repository/JpaRepositoryTest.java b/backend/src/test/java/codezap/global/repository/JpaRepositoryTest.java index ae0a82880..b19273b96 100644 --- a/backend/src/test/java/codezap/global/repository/JpaRepositoryTest.java +++ b/backend/src/test/java/codezap/global/repository/JpaRepositoryTest.java @@ -11,12 +11,13 @@ import codezap.global.DatabaseIsolation; import codezap.global.auditing.JpaAuditingConfiguration; +import codezap.global.rds.DataSourceConfig; @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @DataJpaTest @DatabaseIsolation -@Import(JpaAuditingConfiguration.class) +@Import({JpaAuditingConfiguration.class, DataSourceConfig.class}) @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) public @interface JpaRepositoryTest { } diff --git a/backend/src/test/java/codezap/template/repository/TemplateSearchJpaRepositoryTest.java b/backend/src/test/java/codezap/template/repository/TemplateSearchJpaRepositoryTest.java index 8ab41a644..5b50b71ba 100644 --- a/backend/src/test/java/codezap/template/repository/TemplateSearchJpaRepositoryTest.java +++ b/backend/src/test/java/codezap/template/repository/TemplateSearchJpaRepositoryTest.java @@ -21,6 +21,7 @@ import codezap.category.domain.Category; import codezap.category.repository.CategoryRepository; import codezap.global.auditing.JpaAuditingConfiguration; +import codezap.global.rds.DataSourceConfig; import codezap.member.domain.Member; import codezap.member.repository.MemberRepository; import codezap.tag.domain.Tag; @@ -28,7 +29,7 @@ import codezap.template.domain.Template; @DataJpaTest -@Import(JpaAuditingConfiguration.class) +@Import({JpaAuditingConfiguration.class, DataSourceConfig.class}) @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) @Sql(scripts = "classpath:search.sql", executionPhase = ExecutionPhase.BEFORE_TEST_CLASS) class TemplateSearchJpaRepositoryTest { diff --git a/backend/src/test/resources/application-local.yml b/backend/src/test/resources/application-local.yml deleted file mode 100644 index e74358d99..000000000 --- a/backend/src/test/resources/application-local.yml +++ /dev/null @@ -1,6 +0,0 @@ -spring: - output: - ansi: - enabled: always -cors: - allowed-origins: http://localhost:3000 diff --git a/backend/src/test/resources/application.yml b/backend/src/test/resources/application.yml deleted file mode 100644 index 520dec2c9..000000000 --- a/backend/src/test/resources/application.yml +++ /dev/null @@ -1,5 +0,0 @@ -spring: - profiles: - active: - - local - - db From fc15a10b66dc9c62a93161f601ef6911ec264d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=AC=EC=9A=B0?= Date: Wed, 16 Oct 2024 19:52:45 +0900 Subject: [PATCH 07/11] =?UTF-8?q?fix:=20ci=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend_ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/backend_ci.yml b/.github/workflows/backend_ci.yml index 25b723047..aa1c1fdea 100644 --- a/.github/workflows/backend_ci.yml +++ b/.github/workflows/backend_ci.yml @@ -36,9 +36,10 @@ jobs: java-version: 17 distribution: temurin + - name: 환경변수 주입 + run: ${{ secrets.APPLICATION_YML }} + working-directory: ./backend/src/main/resources + - name: 테스트 코드 실행 run: ./gradlew test working-directory: ./backend - - - name: 환경변수 주입 - run: ${{ secrets.APPLICATION_YML }} From a9840717a6015b7d3c6659af482141558b3a76bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=AC=EC=9A=B0?= Date: Wed, 16 Oct 2024 20:03:48 +0900 Subject: [PATCH 08/11] =?UTF-8?q?fix:=20ci=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend_ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backend_ci.yml b/.github/workflows/backend_ci.yml index aa1c1fdea..1bb617ee4 100644 --- a/.github/workflows/backend_ci.yml +++ b/.github/workflows/backend_ci.yml @@ -38,7 +38,7 @@ jobs: - name: 환경변수 주입 run: ${{ secrets.APPLICATION_YML }} - working-directory: ./backend/src/main/resources + working-directory: ./backend/src/test/resources - name: 테스트 코드 실행 run: ./gradlew test From e9314e7a6f729ed5d1e9e914ef3b3d87fb8f8247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=AC=EC=9A=B0?= Date: Wed, 16 Oct 2024 20:07:56 +0900 Subject: [PATCH 09/11] =?UTF-8?q?fix:=20ci=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend_ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/backend_ci.yml b/.github/workflows/backend_ci.yml index 1bb617ee4..4b583437f 100644 --- a/.github/workflows/backend_ci.yml +++ b/.github/workflows/backend_ci.yml @@ -23,10 +23,6 @@ jobs: mysql database: ${{ secrets.MYSQL_DATABASE }} mysql root password: ${{ secrets.MYSQL_PASSWORD }} - - name: 설정 파일 가져오기 - working-directory: ./backend/src/main/resources - run: echo "${{ secrets.APPLICATION_YAML }}" > application-local.yml - - name: gradle 캐싱 uses: gradle/actions/setup-gradle@v4 From 3a9bcc2b8848c2d9abc76445beb53f98406bb6eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=AC=EC=9A=B0?= Date: Wed, 16 Oct 2024 20:29:52 +0900 Subject: [PATCH 10/11] =?UTF-8?q?refactor:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20sql=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/test/resources/clear.sql | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 backend/src/test/resources/clear.sql diff --git a/backend/src/test/resources/clear.sql b/backend/src/test/resources/clear.sql deleted file mode 100644 index 4efb79f11..000000000 --- a/backend/src/test/resources/clear.sql +++ /dev/null @@ -1,15 +0,0 @@ -DELETE FROM thumbnail; -DELETE FROM sourceCode; -DELETE FROM template_tag; -DELETE FROM tag; -DELETE FROM template; -DELETE FROM category; -DELETE FROM member; - -ALTER TABLE thumbnail ALTER COLUMN id RESTART WITH 1; -ALTER TABLE sourceCode ALTER COLUMN id RESTART WITH 1; -ALTER TABLE template_tag ALTER COLUMN template_id RESTART WITH 1; -ALTER TABLE tag ALTER COLUMN id RESTART WITH 1; -ALTER TABLE template ALTER COLUMN id RESTART WITH 1; -ALTER TABLE category ALTER COLUMN id RESTART WITH 1; -ALTER TABLE member ALTER COLUMN id RESTART WITH 1; From ffd898fde7d16c74dd2a0699882a14ea320397ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=AC=EC=9A=B0?= Date: Wed, 16 Oct 2024 20:33:45 +0900 Subject: [PATCH 11/11] chore: add gitignore --- backend/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/.gitignore b/backend/.gitignore index d4af9460a..7aa169eb4 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -20,7 +20,7 @@ out/ .DS_Store ### YAML ### -application-db.yml +src/test/resources/application.yml ### compose ### docker/app/*.jar