Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: ci-test

on:
pull_request:
branches:
- main

jobs:
build_and_test:
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write

# DB 환경 테스트를 위한 MariaDB 환경 설정
services:
mariadb:
image: mariadb:11.4
env:
MARIADB_DATABASE: test_spoonsuits
MARIADB_ROOT_PASSWORD: ${{ secrets.DB_ROOT_PASSWORD }}
MARIADB_USER: ${{ secrets.DB_USERNAME }}
MARIADB_PASSWORD: ${{ secrets.DB_PASSWORD }}
ports:
# runner : docker container (MariaDB)
- 3306:3306
options: >-
--health-cmd "healthcheck.sh --connect --innodb_initialized"
--health-interval 10s
--health-timeout 5s
--health-retries 3

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up JDK version
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: 'gradle'

- name: create application.yml
# touch : 파일이 없을 경우 새 파일을 생성하는 리눅스 명령어
# ehco ... > ... : 값을 오른쪽에 명시된 파일 내부로 복사
run: |
cd ./spoonsuits-local-test/src/main/resources
touch ./application.yml
touch ./application-secret.yml
echo "${{ secrets.APPLICATION }}" > ./application.yml
echo "${{ secrets.APPLICATION_SECRET }}" > ./application-secret.yml

- name: Grant execute permission for gradlew
run: chmod +x ./spoonsuits-local-test/gradlew

# Gradle로 build 시, build.gradle에 설정한 내용에 의해
# 'test', 'jacocoTestReport', 'jacocoTestCoverageVerification' task들이 순차적으로 자동 실행된다.
- name: Build with Gradle to get a result of test
run: ./spoonsuits-local-test/gradlew build -PenableLocalTest=true

# 테스트 결과를 PR comment로 출력
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
# 이전 task에서 테스트 실패 시 task도 실패하는데, 이 task의 성공 여부에 상관없이 무조건 이 작업을 실행.
if: always()
with:
files: |
spoonsuits-local-test/build/test-results/test/TEST-*.xml
3 changes: 2 additions & 1 deletion spoonsuits-local-test/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ out/
### VS Code ###
.vscode/

gradle.properties
gradle.properties
application-*.yml
25 changes: 12 additions & 13 deletions spoonsuits-local-test/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
spring:
application:
name: spoonsuits-local-test
profiles:
include: secret, local
datasource:
driver-class-name: org.mariadb.jdbc.Driver
url: jdbc:mariadb://127.0.0.1:3308/test_festival
username: root
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.MariaDBDialect

jwt:
issuer: kimquel@good
secretKey: this-is-for-jwt-secret-key-which-has-very-long-length
token:
access:
expiry: PT5M
cookie-name: access-token
refresh:
expiry: PT10M
cookie-name: refresh-token
hibernate:
ddl-auto: create-drop
defer-datasource-initialization: true
sql:
init:
# schema.sql, data.sql 스크립트를 이용한 SQL DB 초기화 시,
# 기본적으로는 임베디드 인메모리 DB에 대해서만 이 초기화가 자동 실행된다고 함.
# 항상 SQL DB 초기화되게끔 하고자 한다면 spring.sql.init.mode=always로 설정.
# 반대로 항상 초기화를 끄고자 한다면 never로 설정.
mode: always
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
-- 테스트용 DB 및 데이터

-- test_festival 데이터베이스 구조 내보내기
CREATE DATABASE IF NOT EXISTS `test_festival`;
USE `test_festival`;

-- 테이블 test_festival.fake_festival 구조 내보내기
CREATE TABLE IF NOT EXISTS `fake_festival` (
`ID` int(11) NOT NULL,
`TITLE` varchar(100) NOT NULL,
`ORIGIN` varchar(100) NOT NULL,
`CONTENT` varchar(1000) NOT NULL,
`IMAGE` varchar(50) NOT NULL,
`STARTDATE` date NOT NULL,
`ENDDATE` date NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- 테이블 데이터 test_festival.fake_festival:~50 rows (대략적) 내보내기
INSERT INTO `fake_festival` (`ID`, `TITLE`, `ORIGIN`, `CONTENT`, `IMAGE`, `STARTDATE`, `ENDDATE`) VALUES
(1, 'Move Over, Darling', 'https://pagesperso-orange.fr/eleifend/quam/a.json', 'Proin interdum mauris non ligula pellentesque ultrices. Phasellus id sapien in sapien iaculis congue. Vivamus metus arcu, adipiscing molestie, hendrerit at, vulputate vitae, nisl.', 'http://dummyimage.com/133x102.png/dddddd/000000', '2024-07-07', '2024-07-13'),
(2, 'A Thousand Times Goodnight', 'https://google.pl/sollicitudin/vitae/consectetuer/eget/rutrum/at/lorem.jsp', 'Nam ultrices, libero non mattis pulvinar, nulla pede ullamcorper augue, a suscipit nulla elit ac nulla. Sed vel enim sit amet nunc viverra dapibus. Nulla suscipit ligula in lacus.', 'http://dummyimage.com/152x233.png/ff4444/ffffff', '2024-11-07', '2024-11-13'),
Expand Down
10 changes: 10 additions & 0 deletions spoonsuits-local-test/src/main/resources/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CREATE TABLE IF NOT EXISTS `fake_festival` (
`ID` int(11) NOT NULL,
`TITLE` varchar(100) NOT NULL,
`ORIGIN` varchar(100) NOT NULL,
`CONTENT` varchar(1000) NOT NULL,
`IMAGE` varchar(50) NOT NULL,
`STARTDATE` date NOT NULL,
`ENDDATE` date NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
Loading