Skip to content

Commit 6798fde

Browse files
authored
Merge pull request #26 from kookmin-sw/init/25
[Backend] init: postgreSQL 연결
2 parents 00c7f51 + 7637f45 commit 6798fde

File tree

3 files changed

+28
-26
lines changed

3 files changed

+28
-26
lines changed

.github/workflows/backend-ci.yml

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
# This workflow uses actions that are not certified by GitHub.
2-
# They are provided by a third-party and are governed by
3-
# separate terms of service, privacy policy, and support
4-
# documentation.
5-
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
6-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
7-
81
name: Backend CI
92

103
on:
@@ -17,14 +10,28 @@ on:
1710

1811
jobs:
1912
build:
20-
2113
runs-on: ubuntu-latest
2214
permissions:
2315
contents: read
2416
defaults:
2517
run:
2618
working-directory: ./backend
2719

20+
services:
21+
postgres:
22+
image: postgres:15
23+
env:
24+
POSTGRES_USER: testuser
25+
POSTGRES_PASSWORD: testpassword
26+
POSTGRES_DB: testdb
27+
ports:
28+
- 5432:5432
29+
options: >-
30+
--health-cmd "pg_isready -U testuser -d testdb"
31+
--health-interval 10s
32+
--health-timeout 5s
33+
--health-retries 5
34+
2835
steps:
2936
- uses: actions/checkout@v4
3037
- name: Set up JDK 21
@@ -33,30 +40,23 @@ jobs:
3340
java-version: '21'
3441
distribution: 'temurin'
3542

36-
# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
37-
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
3843
- name: Grant execute permission for gradlew
3944
run: chmod +x gradlew
4045

4146
- name: Setup Gradle
4247
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
4348

4449
- name: Build with Gradle Wrapper
45-
run: ./gradlew build
50+
run: ./gradlew build -x test
4651

47-
# NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html).
48-
# If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version.
49-
#
50-
# - name: Setup Gradle
51-
# uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
52-
# with:
53-
# gradle-version: '8.9'
54-
#
55-
# - name: Build with Gradle 8.9
56-
# run: gradle build
52+
- name: Run Tests
53+
env:
54+
SPRING_DATASOURCE_URL: jdbc:postgresql://localhost:5432/testdb
55+
SPRING_DATASOURCE_USERNAME: testuser
56+
SPRING_DATASOURCE_PASSWORD: testpassword
57+
run: ./gradlew test
5758

5859
dependency-submission:
59-
6060
runs-on: ubuntu-latest
6161
permissions:
6262
contents: write
@@ -72,10 +72,8 @@ jobs:
7272
java-version: '21'
7373
distribution: 'temurin'
7474

75-
# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
76-
# See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md
7775
- name: Generate and submit dependency graph
7876
uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
7977
with:
8078
gradle-version: '8.12.1'
81-
build-root-directory: ./backend
79+
build-root-directory: ./backend

backend/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ dependencies {
2222
implementation 'org.springframework.boot:spring-boot-starter-web'
2323
testImplementation 'org.springframework.boot:spring-boot-starter-test'
2424
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
25+
26+
implementation 'org.springframework.boot:spring-boot-starter-jdbc' // Spring JDBC 의존성 추가
27+
// https://mvnrepository.com/artifact/org.postgresql/postgresql
28+
implementation 'org.postgresql:postgresql:42.7.3' // PostgreSQL JDBC 드라이버 의존성 추가
29+
runtimeOnly 'org.postgresql:postgresql:42.7.3' // 실행 시에만 필요한 의존성 추가
2530
}
2631

2732
tasks.named('test') {

backend/src/main/resources/application.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)