From 91f95d775da6acfeb502e6452375ad9fca1a3aa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=88=98=EC=A7=80=EB=8B=88?= Date: Tue, 19 Dec 2023 13:55:33 +0900 Subject: [PATCH 1/7] =?UTF-8?q?[chore]:=20core=EB=AA=A8=EB=93=88=EC=97=90?= =?UTF-8?q?=20data-jpa=20=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/core/build.gradle b/core/build.gradle index 2b004ab1..fef7dd2c 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,6 +1,7 @@ dependencies { runtimeOnly 'org.postgresql:postgresql' implementation 'org.springframework.boot:spring-boot-starter' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' } bootJar { enabled = false } From 99a620a1dee4443e7a072c84daff420509852775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=88=98=EC=A7=80=EB=8B=88?= Date: Tue, 19 Dec 2023 13:56:15 +0900 Subject: [PATCH 2/7] =?UTF-8?q?[feat]:=20common=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hooon/common/entity/TimeBaseEntity.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 core/src/main/java/dev/hooon/common/entity/TimeBaseEntity.java diff --git a/core/src/main/java/dev/hooon/common/entity/TimeBaseEntity.java b/core/src/main/java/dev/hooon/common/entity/TimeBaseEntity.java new file mode 100644 index 00000000..5b365c32 --- /dev/null +++ b/core/src/main/java/dev/hooon/common/entity/TimeBaseEntity.java @@ -0,0 +1,25 @@ +package dev.hooon.common.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.MappedSuperclass; +import lombok.Getter; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import java.time.LocalDateTime; + +@EntityListeners(AuditingEntityListener.class) +@MappedSuperclass +@Getter +public class TimeBaseEntity { + + @CreatedDate + @Column(name = "created_at") + protected LocalDateTime createdAt; + + @LastModifiedDate + @Column(name = "updated_at") + private LocalDateTime updatedAt; +} From c64e4249f15aa24866454b0a3e439807f51992b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=88=98=EC=A7=80=EB=8B=88?= Date: Tue, 19 Dec 2023 13:56:27 +0900 Subject: [PATCH 3/7] =?UTF-8?q?[feat]:=20user=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dev/hooon/user/domain/entity/User.java | 32 +++++++++++++++++++ .../hooon/user/domain/entity/UserRole.java | 14 ++++++++ 2 files changed, 46 insertions(+) create mode 100644 core/src/main/java/dev/hooon/user/domain/entity/User.java create mode 100644 core/src/main/java/dev/hooon/user/domain/entity/UserRole.java diff --git a/core/src/main/java/dev/hooon/user/domain/entity/User.java b/core/src/main/java/dev/hooon/user/domain/entity/User.java new file mode 100644 index 00000000..e7040c1e --- /dev/null +++ b/core/src/main/java/dev/hooon/user/domain/entity/User.java @@ -0,0 +1,32 @@ +package dev.hooon.user.domain.entity; + +import dev.hooon.common.entity.TimeBaseEntity; +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import static jakarta.persistence.EnumType.STRING; +import static jakarta.persistence.GenerationType.IDENTITY; + +@Entity +@Getter +@Table(name = "user_table") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class User extends TimeBaseEntity { + + @Id + @GeneratedValue(strategy = IDENTITY) + @Column(name = "user_id") + private Long id; + + @Column(name = "user_email", nullable = false, unique = true) + private String email; + + @Column(name = "user_name", nullable = false) + private String name; + + @Enumerated(STRING) + @Column(name = "user_role", nullable = false) + private UserRole userRole; +} diff --git a/core/src/main/java/dev/hooon/user/domain/entity/UserRole.java b/core/src/main/java/dev/hooon/user/domain/entity/UserRole.java new file mode 100644 index 00000000..24750c1d --- /dev/null +++ b/core/src/main/java/dev/hooon/user/domain/entity/UserRole.java @@ -0,0 +1,14 @@ +package dev.hooon.user.domain.entity; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum UserRole { + + BUYER("ROLE_BUYER"), + SELLER("ROLE_SELLER"); + + private final String role; +} From 42195fe0d36fa3b3a31e6dcafb51c60e8a4eb0da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=88=98=EC=A7=80=EB=8B=88?= Date: Tue, 19 Dec 2023 13:56:44 +0900 Subject: [PATCH 4/7] =?UTF-8?q?[feat]:=20show=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dev/hooon/show/domain/entity/Show.java | 40 ++++++++++++++ .../hooon/show/domain/entity/ShowPeriod.java | 24 +++++++++ .../hooon/show/domain/entity/ShowTime.java | 22 ++++++++ .../hooon/show/domain/entity/place/Place.java | 33 ++++++++++++ .../hooon/show/domain/entity/seat/Seat.java | 53 +++++++++++++++++++ .../show/domain/entity/seat/SeatGrade.java | 17 ++++++ .../domain/entity/seat/SeatPositionInfo.java | 25 +++++++++ .../show/domain/entity/seat/ShowRound.java | 24 +++++++++ .../show/domain/entity/showlike/ShowLike.java | 27 ++++++++++ 9 files changed, 265 insertions(+) create mode 100644 core/src/main/java/dev/hooon/show/domain/entity/Show.java create mode 100644 core/src/main/java/dev/hooon/show/domain/entity/ShowPeriod.java create mode 100644 core/src/main/java/dev/hooon/show/domain/entity/ShowTime.java create mode 100644 core/src/main/java/dev/hooon/show/domain/entity/place/Place.java create mode 100644 core/src/main/java/dev/hooon/show/domain/entity/seat/Seat.java create mode 100644 core/src/main/java/dev/hooon/show/domain/entity/seat/SeatGrade.java create mode 100644 core/src/main/java/dev/hooon/show/domain/entity/seat/SeatPositionInfo.java create mode 100644 core/src/main/java/dev/hooon/show/domain/entity/seat/ShowRound.java create mode 100644 core/src/main/java/dev/hooon/show/domain/entity/showlike/ShowLike.java diff --git a/core/src/main/java/dev/hooon/show/domain/entity/Show.java b/core/src/main/java/dev/hooon/show/domain/entity/Show.java new file mode 100644 index 00000000..f38d4454 --- /dev/null +++ b/core/src/main/java/dev/hooon/show/domain/entity/Show.java @@ -0,0 +1,40 @@ +package dev.hooon.show.domain.entity; + +import dev.hooon.common.entity.TimeBaseEntity; +import dev.hooon.show.domain.entity.place.Place; +import jakarta.persistence.*; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import static jakarta.persistence.ConstraintMode.NO_CONSTRAINT; +import static jakarta.persistence.FetchType.*; +import static jakarta.persistence.GenerationType.IDENTITY; +import static lombok.AccessLevel.PROTECTED; + +@Entity +@Getter +@Table(name = "show_table") +@NoArgsConstructor(access = PROTECTED) +public class Show extends TimeBaseEntity { + + @Id + @GeneratedValue(strategy = IDENTITY) + @Column(name = "show_id") + private Long id; + + @Embedded + private ShowPeriod showPeriod; + + @Embedded + private ShowTime showTime; + + @Column(name = "show_age", nullable = false) + private String showAge; + + @Column(name = "show_total_seats") + private int totalSeats; + + @ManyToOne(fetch = LAZY) + @JoinColumn(name = "show_place_id", nullable = false, foreignKey = @ForeignKey(value = NO_CONSTRAINT)) + private Place place; +} diff --git a/core/src/main/java/dev/hooon/show/domain/entity/ShowPeriod.java b/core/src/main/java/dev/hooon/show/domain/entity/ShowPeriod.java new file mode 100644 index 00000000..60bc87a3 --- /dev/null +++ b/core/src/main/java/dev/hooon/show/domain/entity/ShowPeriod.java @@ -0,0 +1,24 @@ +package dev.hooon.show.domain.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; + +import static lombok.AccessLevel.PROTECTED; + +@Getter +@Embeddable +@EqualsAndHashCode +@NoArgsConstructor(access = PROTECTED) +public class ShowPeriod { + + @Column(name = "show_start_date", nullable = false) + private LocalDate startDate; + + @Column(name = "show_end_date", nullable = false) + private LocalDate endDate; +} diff --git a/core/src/main/java/dev/hooon/show/domain/entity/ShowTime.java b/core/src/main/java/dev/hooon/show/domain/entity/ShowTime.java new file mode 100644 index 00000000..3daca5b6 --- /dev/null +++ b/core/src/main/java/dev/hooon/show/domain/entity/ShowTime.java @@ -0,0 +1,22 @@ +package dev.hooon.show.domain.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import static lombok.AccessLevel.PROTECTED; + +@Getter +@Embeddable +@EqualsAndHashCode +@NoArgsConstructor(access = PROTECTED) +public class ShowTime { + + @Column(name = "show_total_minutes", nullable = false) + private int totalMinutes; + + @Column(name = "show_intermission_minutes", nullable = false) + private int intermissionMinutes; +} diff --git a/core/src/main/java/dev/hooon/show/domain/entity/place/Place.java b/core/src/main/java/dev/hooon/show/domain/entity/place/Place.java new file mode 100644 index 00000000..2b53aebb --- /dev/null +++ b/core/src/main/java/dev/hooon/show/domain/entity/place/Place.java @@ -0,0 +1,33 @@ +package dev.hooon.show.domain.entity.place; + +import dev.hooon.common.entity.TimeBaseEntity; +import jakarta.persistence.*; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import static jakarta.persistence.GenerationType.IDENTITY; +import static lombok.AccessLevel.PROTECTED; + +@Entity +@Getter +@Table(name = "place_table") +@NoArgsConstructor(access = PROTECTED) +public class Place extends TimeBaseEntity { + + @Id + @GeneratedValue(strategy = IDENTITY) + @Column(name = "place_id") + private Long id; + + @Column(name = "place_name", nullable = false) + private String name; + + @Column(name = "place_contact_info") + private String contactInfo; + + @Column(name = "place_address", nullable = false) + private String address; + + @Column(name = "place_url") + private String placeUrl; +} diff --git a/core/src/main/java/dev/hooon/show/domain/entity/seat/Seat.java b/core/src/main/java/dev/hooon/show/domain/entity/seat/Seat.java new file mode 100644 index 00000000..b5a82377 --- /dev/null +++ b/core/src/main/java/dev/hooon/show/domain/entity/seat/Seat.java @@ -0,0 +1,53 @@ +package dev.hooon.show.domain.entity.seat; + +import dev.hooon.common.entity.TimeBaseEntity; +import dev.hooon.show.domain.entity.Show; +import jakarta.persistence.*; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; + +import static jakarta.persistence.ConstraintMode.NO_CONSTRAINT; +import static jakarta.persistence.EnumType.STRING; +import static jakarta.persistence.FetchType.LAZY; +import static jakarta.persistence.GenerationType.IDENTITY; +import static lombok.AccessLevel.PROTECTED; + +@Entity +@Getter +@Table(name = "seat_table") +@NoArgsConstructor(access = PROTECTED) +public class Seat extends TimeBaseEntity { + + @Id + @GeneratedValue(strategy = IDENTITY) + @Column(name = "seat_id") + private Long id; + + @ManyToOne(fetch = LAZY) + @JoinColumn(name = "seat_show_id", nullable = false, foreignKey = @ForeignKey(value = NO_CONSTRAINT)) + private Show show; + + @Enumerated(STRING) + @Column(name = "seat_grade", nullable = false) + private SeatGrade seatGrade; + + @Column(name = "seat_is_seat", nullable = false) + private boolean isSeat; + + @Embedded + private SeatPositionInfo positionInfo; + + @Column(name = "seat_price", nullable = false) + private int price; + + @Column(name = "seat_show_date", nullable = false) + private LocalDate showDate; + + @Embedded + private ShowRound showRound; + + @Column(name = "seat_is_booked", nullable = false) + private boolean isBooked; +} diff --git a/core/src/main/java/dev/hooon/show/domain/entity/seat/SeatGrade.java b/core/src/main/java/dev/hooon/show/domain/entity/seat/SeatGrade.java new file mode 100644 index 00000000..5f4bec93 --- /dev/null +++ b/core/src/main/java/dev/hooon/show/domain/entity/seat/SeatGrade.java @@ -0,0 +1,17 @@ +package dev.hooon.show.domain.entity.seat; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum SeatGrade { + + VIP("VIP석"), + R("R석"), + S("S석"), + A("A석"), + B("B석"); + + private final String description; +} diff --git a/core/src/main/java/dev/hooon/show/domain/entity/seat/SeatPositionInfo.java b/core/src/main/java/dev/hooon/show/domain/entity/seat/SeatPositionInfo.java new file mode 100644 index 00000000..df93c5db --- /dev/null +++ b/core/src/main/java/dev/hooon/show/domain/entity/seat/SeatPositionInfo.java @@ -0,0 +1,25 @@ +package dev.hooon.show.domain.entity.seat; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import static lombok.AccessLevel.PROTECTED; + +@Getter +@Embeddable +@EqualsAndHashCode +@NoArgsConstructor(access = PROTECTED) +public class SeatPositionInfo { + + @Column(name = "seat_sector") + private String sector; + + @Column(name = "seat_row", nullable = false) + private String row; + + @Column(name = "seat_col", nullable = false) + private int col; +} diff --git a/core/src/main/java/dev/hooon/show/domain/entity/seat/ShowRound.java b/core/src/main/java/dev/hooon/show/domain/entity/seat/ShowRound.java new file mode 100644 index 00000000..cd4fdd51 --- /dev/null +++ b/core/src/main/java/dev/hooon/show/domain/entity/seat/ShowRound.java @@ -0,0 +1,24 @@ +package dev.hooon.show.domain.entity.seat; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalTime; + +import static lombok.AccessLevel.PROTECTED; + +@Getter +@Embeddable +@EqualsAndHashCode +@NoArgsConstructor(access = PROTECTED) +public class ShowRound { + + @Column(name = "seat_show_round") + private int round; + + @Column(name = "seat_start_time") + private LocalTime startTime; +} diff --git a/core/src/main/java/dev/hooon/show/domain/entity/showlike/ShowLike.java b/core/src/main/java/dev/hooon/show/domain/entity/showlike/ShowLike.java new file mode 100644 index 00000000..51430d91 --- /dev/null +++ b/core/src/main/java/dev/hooon/show/domain/entity/showlike/ShowLike.java @@ -0,0 +1,27 @@ +package dev.hooon.show.domain.entity.showlike; + +import dev.hooon.common.entity.TimeBaseEntity; +import jakarta.persistence.*; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import static jakarta.persistence.GenerationType.IDENTITY; +import static lombok.AccessLevel.PROTECTED; + +@Entity +@Getter +@Table(name = "show_like_table") +@NoArgsConstructor(access = PROTECTED) +public class ShowLike extends TimeBaseEntity { + + @Id + @GeneratedValue(strategy = IDENTITY) + @Column(name = "show_like_id") + private Long id; + + @Column(name = "show_like_user_id", nullable = false) + private Long userId; + + @Column(name = "show_like_show_id", nullable = false) + private Long showId; +} From e3a1b0931bdaa5b3ecea35270e59168b15b706f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=88=98=EC=A7=80=EB=8B=88?= Date: Tue, 19 Dec 2023 13:56:57 +0900 Subject: [PATCH 5/7] =?UTF-8?q?[feat]:=20booking=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hooon/booking/domain/entity/Booking.java | 33 +++++++++++++++++++ .../hooon/booking/domain/entity/Ticket.java | 32 ++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 core/src/main/java/dev/hooon/booking/domain/entity/Booking.java create mode 100644 core/src/main/java/dev/hooon/booking/domain/entity/Ticket.java diff --git a/core/src/main/java/dev/hooon/booking/domain/entity/Booking.java b/core/src/main/java/dev/hooon/booking/domain/entity/Booking.java new file mode 100644 index 00000000..ebd0d83a --- /dev/null +++ b/core/src/main/java/dev/hooon/booking/domain/entity/Booking.java @@ -0,0 +1,33 @@ +package dev.hooon.booking.domain.entity; + +import dev.hooon.common.entity.TimeBaseEntity; +import dev.hooon.show.domain.entity.Show; +import dev.hooon.user.domain.entity.User; +import jakarta.persistence.*; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import static jakarta.persistence.ConstraintMode.NO_CONSTRAINT; +import static jakarta.persistence.FetchType.LAZY; +import static jakarta.persistence.GenerationType.IDENTITY; +import static lombok.AccessLevel.PROTECTED; + +@Entity +@Getter +@Table(name = "booking_table") +@NoArgsConstructor(access = PROTECTED) +public class Booking extends TimeBaseEntity { + + @Id + @GeneratedValue(strategy = IDENTITY) + @Column(name = "booking_id") + private Long id; + + @ManyToOne(fetch = LAZY) + @JoinColumn(name = "booking_user_id", nullable = false, foreignKey = @ForeignKey(value = NO_CONSTRAINT)) + private User user; + + @ManyToOne(fetch = LAZY) + @JoinColumn(name = "booking_show_id", nullable = false, foreignKey = @ForeignKey(value = NO_CONSTRAINT)) + private Show show; +} diff --git a/core/src/main/java/dev/hooon/booking/domain/entity/Ticket.java b/core/src/main/java/dev/hooon/booking/domain/entity/Ticket.java new file mode 100644 index 00000000..128da5a6 --- /dev/null +++ b/core/src/main/java/dev/hooon/booking/domain/entity/Ticket.java @@ -0,0 +1,32 @@ +package dev.hooon.booking.domain.entity; + +import dev.hooon.common.entity.TimeBaseEntity; +import dev.hooon.show.domain.entity.seat.Seat; +import jakarta.persistence.*; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import static jakarta.persistence.ConstraintMode.NO_CONSTRAINT; +import static jakarta.persistence.FetchType.LAZY; +import static jakarta.persistence.GenerationType.IDENTITY; +import static lombok.AccessLevel.*; + +@Entity +@Getter +@Table(name = "ticket_table") +@NoArgsConstructor(access = PROTECTED) +public class Ticket extends TimeBaseEntity { + + @Id + @GeneratedValue(strategy = IDENTITY) + @Column(name = "ticket_id") + private Long id; + + @ManyToOne(fetch = LAZY) + @JoinColumn(name = "ticket_booking_id", nullable = false, foreignKey = @ForeignKey(value = NO_CONSTRAINT)) + private Booking booking; + + @ManyToOne(fetch = LAZY) + @JoinColumn(name = "ticket_seat_id", nullable = false, foreignKey = @ForeignKey(value = NO_CONSTRAINT)) + private Seat seat; +} From 643cd12f0a632e4663e2a0a5597abdc8fec73f1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=88=98=EC=A7=84?= <71487608+ssssujini99@users.noreply.github.com> Date: Tue, 19 Dec 2023 22:13:27 +0900 Subject: [PATCH 6/7] =?UTF-8?q?[chore]:=20CICD=20=EC=84=B8=ED=8C=85=20(#15?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [chore]: build-ci 추가 * [chore]: test-ci 추가 * [fix]: 버그 수정 --- .github/workflows/build-ci.yml | 31 +++++++++++++++++++++++++++++++ .github/workflows/test-ci.yml | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 .github/workflows/build-ci.yml create mode 100644 .github/workflows/test-ci.yml diff --git a/.github/workflows/build-ci.yml b/.github/workflows/build-ci.yml new file mode 100644 index 00000000..27c87c25 --- /dev/null +++ b/.github/workflows/build-ci.yml @@ -0,0 +1,31 @@ +# 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: build CI + +on: + push: + branches: [ "dev" ] + pull_request: + branches: [ "dev" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Build with Gradle + uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 + with: + arguments: api:build -x test diff --git a/.github/workflows/test-ci.yml b/.github/workflows/test-ci.yml new file mode 100644 index 00000000..10f05832 --- /dev/null +++ b/.github/workflows/test-ci.yml @@ -0,0 +1,34 @@ +# 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: test CI + +on: + pull_request: + branches: [ "dev" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: test CI + uses: gradle/gradle-build-action@v2 + with: + arguments: test From 340782c6d3e915287d06c585caa431fda12bba34 Mon Sep 17 00:00:00 2001 From: EunChanNam <75837025+EunChanNam@users.noreply.github.com> Date: Tue, 19 Dec 2023 23:31:38 +0900 Subject: [PATCH 7/7] =?UTF-8?q?[chore]=20:=20=EA=B0=9C=EB=B0=9C=20?= =?UTF-8?q?=EB=B0=8F=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20DB=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=B6=94=EA=B0=80=20(#17)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: server, postgres db, redis 컨테이너를 * chore: 테스트 컨테이너 의존성 추가 * feat: 테스트 컨테이너 템플릿 추가 --- core/build.gradle | 3 ++ .../common/support/TestContainerSupport.java | 41 +++++++++++++++++++ docker-compose.yml | 37 +++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 core/src/test/java/dev/hooon/common/support/TestContainerSupport.java create mode 100644 docker-compose.yml diff --git a/core/build.gradle b/core/build.gradle index fef7dd2c..eaf538f6 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -2,6 +2,9 @@ dependencies { runtimeOnly 'org.postgresql:postgresql' implementation 'org.springframework.boot:spring-boot-starter' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + //테스트 컨테이너 + testImplementation "org.testcontainers:testcontainers:1.19.2" + testImplementation "org.testcontainers:postgresql:1.19.3" } bootJar { enabled = false } diff --git a/core/src/test/java/dev/hooon/common/support/TestContainerSupport.java b/core/src/test/java/dev/hooon/common/support/TestContainerSupport.java new file mode 100644 index 00000000..8771aafb --- /dev/null +++ b/core/src/test/java/dev/hooon/common/support/TestContainerSupport.java @@ -0,0 +1,41 @@ +package dev.hooon.common.support; + +import org.springframework.test.context.DynamicPropertyRegistry; +import org.springframework.test.context.DynamicPropertySource; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.PostgreSQLContainer; +import org.testcontainers.utility.DockerImageName; + +public abstract class TestContainerSupport { + + private static final String REDIS_IMAGE = "redis:latest"; + private static final String POSTGRES_IMAGE = "postgres:13-alpine"; + private static final int REDIS_PORT = 6379; + private static final int POSTGRES_PORT = 5432; + + private static final GenericContainer REDIS; + private static final PostgreSQLContainer POSTGRES; + + static { + REDIS = new GenericContainer<>(DockerImageName.parse(REDIS_IMAGE)) + .withExposedPorts(REDIS_PORT) + .withReuse(true); + POSTGRES = new PostgreSQLContainer<>(DockerImageName.parse(POSTGRES_IMAGE)) + .withExposedPorts(POSTGRES_PORT) + .withReuse(true); + + REDIS.start(); + POSTGRES.start(); + } + + @DynamicPropertySource + public static void overrideProps(DynamicPropertyRegistry registry){ + registry.add("spring.data.redis.host", REDIS::getHost); + registry.add("spring.data.redis.port", () -> String.valueOf(REDIS.getMappedPort(REDIS_PORT))); + + registry.add("spring.datasource.driver-class-name", POSTGRES::getDriverClassName); + registry.add("spring.datasource.url", POSTGRES::getJdbcUrl); + registry.add("spring.datasource.username", POSTGRES::getUsername); + registry.add("spring.datasource.password", POSTGRES::getPassword); + } +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..42113295 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,37 @@ +version: "3" +services: + server: + image: openjdk:17-alpine + container_name: spring_server + restart: always + depends_on: + - db-master + - redis + volumes: + - ./api/build/libs:/home + command: [ "java", "-jar", "/home/api-0.0.1-SNAPSHOT.jar" ] + ports: + - '8080:8080' + platform: linux/amd64 + + db-master: + image: postgres:13-alpine + container_name: master_db + environment: + POSTGRES_USER: ${MASTER_USER} + POSTGRES_PASSWORD: ${MASTER_PASSWORD} + POSTGRES_DB: master_db + ports: + - "5432:5432" + volumes: + - postgresql_data:/var/lib/postgresql/data + + redis: + image: redis:latest + container_name: redis + ports: + - '6379:6379' + platform: linux/amd64 + +volumes: + postgresql_data: \ No newline at end of file