From 887b0e90494001ddf57d004a251f19644e682c4d Mon Sep 17 00:00:00 2001 From: mjk25 Date: Tue, 18 Mar 2025 21:23:09 +0900 Subject: [PATCH 1/2] =?UTF-8?q?init:=20postgreSQL=20=EC=97=B0=EA=B2=B0=20#?= =?UTF-8?q?25?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/build.gradle | 5 +++++ backend/src/main/resources/application.properties | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) delete mode 100644 backend/src/main/resources/application.properties diff --git a/backend/build.gradle b/backend/build.gradle index a7d5830d..ba7743d6 100644 --- a/backend/build.gradle +++ b/backend/build.gradle @@ -22,6 +22,11 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' testImplementation 'org.springframework.boot:spring-boot-starter-test' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + + implementation 'org.springframework.boot:spring-boot-starter-jdbc' // Spring JDBC 의존성 추가 + // https://mvnrepository.com/artifact/org.postgresql/postgresql + implementation 'org.postgresql:postgresql:42.7.3' // PostgreSQL JDBC 드라이버 의존성 추가 + runtimeOnly 'org.postgresql:postgresql:42.7.3' // 실행 시에만 필요한 의존성 추가 } tasks.named('test') { diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties deleted file mode 100644 index 3ca17a4e..00000000 --- a/backend/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -spring.application.name=backend From 7637f45b5843d4d069c71a1d98e6dbc685fb7d90 Mon Sep 17 00:00:00 2001 From: mjk25 Date: Tue, 18 Mar 2025 21:55:55 +0900 Subject: [PATCH 2/2] fix: fix PostgreSQL CI error #25 --- .github/workflows/backend-ci.yml | 48 +++++++++++++++----------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml index 4a07a9b2..9de36fac 100644 --- a/.github/workflows/backend-ci.yml +++ b/.github/workflows/backend-ci.yml @@ -1,10 +1,3 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle - name: Backend CI on: @@ -17,7 +10,6 @@ on: jobs: build: - runs-on: ubuntu-latest permissions: contents: read @@ -25,6 +17,21 @@ jobs: run: working-directory: ./backend + services: + postgres: + image: postgres:15 + env: + POSTGRES_USER: testuser + POSTGRES_PASSWORD: testpassword + POSTGRES_DB: testdb + ports: + - 5432:5432 + options: >- + --health-cmd "pg_isready -U testuser -d testdb" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: - uses: actions/checkout@v4 - name: Set up JDK 21 @@ -33,8 +40,6 @@ jobs: java-version: '21' distribution: 'temurin' - # Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies. - # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md - name: Grant execute permission for gradlew run: chmod +x gradlew @@ -42,21 +47,16 @@ jobs: uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 - name: Build with Gradle Wrapper - run: ./gradlew build + run: ./gradlew build -x test - # NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html). - # If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version. - # - # - name: Setup Gradle - # uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 - # with: - # gradle-version: '8.9' - # - # - name: Build with Gradle 8.9 - # run: gradle build + - name: Run Tests + env: + SPRING_DATASOURCE_URL: jdbc:postgresql://localhost:5432/testdb + SPRING_DATASOURCE_USERNAME: testuser + SPRING_DATASOURCE_PASSWORD: testpassword + run: ./gradlew test dependency-submission: - runs-on: ubuntu-latest permissions: contents: write @@ -72,10 +72,8 @@ jobs: java-version: '21' distribution: 'temurin' - # Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies. - # See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md - name: Generate and submit dependency graph uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 with: gradle-version: '8.12.1' - build-root-directory: ./backend + build-root-directory: ./backend \ No newline at end of file