-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
183 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/com/prgrms/catchtable/common/exception/CommonException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/prgrms/catchtable/common/exception/ErrorCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/prgrms/catchtable/common/exception/ExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/prgrms/catchtable/common/exception/custom/BadRequestCustomException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/prgrms/catchtable/common/exception/custom/NotFoundCustomException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
13 changes: 0 additions & 13 deletions
13
src/test/java/com/prgrms/catchtable/CatchtableApplicationTests.java
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
src/test/java/com/prgrms/catchtable/common/restdocs/RestDocsSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |