Skip to content

Commit

Permalink
Merge branch 'dev' into feat/#4
Browse files Browse the repository at this point in the history
  • Loading branch information
dlswns2480 committed Dec 25, 2023
2 parents b4c47f9 + 4202c8c commit 0c4cc05
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 16 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# 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: CI Backend

on:
push:
branches: [ "main", "dev" ]
pull_request:
branches: [ "main", "dev" ]

permissions:
contents: read
checks: write
pull-requests: write

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: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# gradle 권한 부여
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
shell: bash

# 빌드
- name: Build with Gradle
run: ./gradlew build

# 테스트 결과 PR 코멘트에 등록
- name: Register the test results as PR comments
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: '**/build/test-results/test/TEST-*.xml'

# 테스트 실패시 코드 라인에 대한 체크 추가
- name: If test fail, add check comment on failed code line
uses: mikepenz/action-junit-report@v3
if: always()
with:
report_paths: '**/build/test-results/test/TEST-*.html'
37 changes: 34 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ configurations {
compileOnly {
extendsFrom annotationProcessor
}
asciidoctorExt
}

repositories {
Expand All @@ -36,16 +37,46 @@ dependencies {
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
testImplementation 'org.springframework.security:spring-security-test'

//test contrainer
testImplementation "org.testcontainers:testcontainers:1.19.2"
testImplementation "org.testcontainers:junit-jupiter:1.19.2"
testImplementation "org.testcontainers:mysql:1.19.2"
testImplementation 'org.testcontainers:jdbc:1.18.3'

// RestDocs
asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'

}

tasks.named('test') {
outputs.dir snippetsDir
useJUnitPlatform()
}

tasks.named('asciidoctor') {
ext { // 전역 변수
snippetsDir = file('build/generated-snippets')
}

test {
outputs.dir snippetsDir
}

asciidoctor {
inputs.dir snippetsDir
configurations 'asciidoctorExt'

sources {//특정 파일만 html로 생성
include("**/index.adoc")
}
baseDirFollowsSourceFile() //다른 adoc 파일을 include할 때 경로를 baseDir로 맞춤
dependsOn test
}

bootJar {
dependsOn asciidoctor
from("${asciidoctor.outputDir}") {
into 'static/docs'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.prgrms.catchtable.common.exception;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public class CommonException extends RuntimeException {

private final ErrorCode errorCode;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.prgrms.catchtable.common.exception;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum ErrorCode {
NOT_EXIST_MEMBER("존재하지 않는 아이디입니다.");

private final String message;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.prgrms.catchtable.common.exception;

import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ExceptionHandler {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.prgrms.catchtable.common.exception.custom;

import com.prgrms.catchtable.common.exception.CommonException;
import com.prgrms.catchtable.common.exception.ErrorCode;

public class BadRequestCustomException extends CommonException {

public BadRequestCustomException(ErrorCode errorCode) {
super(errorCode);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.prgrms.catchtable.common.exception.custom;

import com.prgrms.catchtable.common.exception.CommonException;
import com.prgrms.catchtable.common.exception.ErrorCode;

public class NotFoundCustomException extends CommonException {

public NotFoundCustomException(ErrorCode errorCode) {
super(errorCode);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.prgrms.catchtable.common.restdocs;

import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.restdocs.RestDocumentationContextProvider;
import org.springframework.restdocs.RestDocumentationExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;

@ExtendWith(RestDocumentationExtension.class)
public abstract class RestDocsSupport {

protected MockMvc mockMvc;
protected ObjectMapper objectMapper = new ObjectMapper();


@BeforeEach
void setUp(RestDocumentationContextProvider provider) {
this.mockMvc = MockMvcBuilders.standaloneSetup(initController())
.apply(documentationConfiguration(provider))
.build();
}

protected abstract Object initController();
}

0 comments on commit 0c4cc05

Please sign in to comment.