Skip to content

Commit ff0d77f

Browse files
authored
Merge pull request #33 from Bravest-opensource-project/ci/workflow-fourth-code-style
[ci/cd] add code style checker workflow
2 parents 99a51c4 + 1740065 commit ff0d77f

50 files changed

Lines changed: 1163 additions & 1138 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/auto-assign.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Java Code Style Check
2+
3+
on:
4+
pull_request:
5+
branches: ['**']
6+
push:
7+
branches: ['**']
8+
workflow_dispatch:
9+
10+
jobs:
11+
style-check:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v3
17+
18+
- name: Set up JDK 21
19+
uses: actions/setup-java@v3
20+
with:
21+
java-version: '21'
22+
distribution: 'temurin'
23+
24+
- name: Grant execute permission for gradlew
25+
run: chmod +x gradlew
26+
27+
- name: Run Spotless and Checkstyle
28+
run: |
29+
set -e
30+
./gradlew spotlessCheck --no-daemon
31+
./gradlew checkstyleMain checkstyleTest --no-daemon
32+
shell: bash
33+
34+
- name: Show summary
35+
run: |
36+
if [ $? -eq 0 ]; then
37+
echo "🎉 Code style checks passed!"
38+
else
39+
echo "❌ Code style violations detected!"
40+
echo "Please run './gradlew spotlessApply' locally and fix Checkstyle issues."
41+
exit 1
42+
fi
43+
shell: bash

build.gradle

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
id 'java'
33
id 'org.springframework.boot' version '3.5.7'
44
id 'io.spring.dependency-management' version '1.1.7'
5+
id 'com.diffplug.spotless' version '6.25.0'
56
}
67

78
group = 'opensource'
@@ -65,3 +66,27 @@ dependencies {
6566
tasks.named('test') {
6667
useJUnitPlatform()
6768
}
69+
70+
apply plugin: 'checkstyle'
71+
72+
checkstyle {
73+
toolVersion = '10.12.0'
74+
configFile = file('config/checkstyle/google_checks.xml')
75+
}
76+
77+
tasks.withType(Checkstyle) {
78+
reports {
79+
xml.required.set(true)
80+
html.required.set(true)
81+
}
82+
}
83+
84+
// Spotless 적용
85+
apply plugin: 'com.diffplug.spotless'
86+
87+
spotless {
88+
java {
89+
googleJavaFormat()
90+
target 'src/**/*.java'
91+
}
92+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5+
6+
<module name="Checker">
7+
<module name="TreeWalker">
8+
<!-- 최소 규칙만 적용 -->
9+
</module>
10+
</module>

src/main/java/opensource/bravest/BravestApplication.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
@SpringBootApplication
77
public class BravestApplication {
88

9-
public static void main(String[] args) {
10-
SpringApplication.run(BravestApplication.class, args);
11-
}
12-
9+
public static void main(String[] args) {
10+
SpringApplication.run(BravestApplication.class, args);
11+
}
1312
}
Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package opensource.bravest.domain.chatList.controller;
22

3+
import static opensource.bravest.domain.chatList.dto.ChatListDto.ChatListCreateRequest;
34
import static opensource.bravest.domain.chatList.dto.ChatListDto.ChatListResponse;
45
import static opensource.bravest.domain.chatList.dto.ChatListDto.ChatListUpdateRequest;
5-
import static opensource.bravest.domain.chatList.dto.ChatListDto.ChatListCreateRequest;
66

7+
import jakarta.validation.Valid;
8+
import java.util.List;
9+
import lombok.RequiredArgsConstructor;
710
import opensource.bravest.domain.chatList.service.ChatListService;
811
import opensource.bravest.global.apiPayload.ApiResponse;
912
import org.springframework.web.bind.annotation.DeleteMapping;
@@ -15,47 +18,42 @@
1518
import org.springframework.web.bind.annotation.RequestMapping;
1619
import org.springframework.web.bind.annotation.RestController;
1720

18-
import lombok.RequiredArgsConstructor;
19-
import org.springframework.http.HttpStatus;
20-
import org.springframework.http.ResponseEntity;
21-
import jakarta.validation.Valid;
22-
import java.util.List;
23-
2421
@RestController
2522
@RequestMapping("/chatlists")
2623
@RequiredArgsConstructor
2724
public class ChatListController {
2825

29-
private final ChatListService chatListService;
30-
31-
@PostMapping
32-
public ApiResponse<ChatListResponse> createChatList(@Valid @RequestBody ChatListCreateRequest request) {
33-
ChatListResponse response = chatListService.createChatList(request);
34-
return ApiResponse.onSuccess(response);
35-
}
36-
37-
@GetMapping("/room/{roomId}")
38-
public ApiResponse<List<ChatListResponse>> getChatListsByRoomId(@PathVariable Long roomId) {
39-
List<ChatListResponse> response = chatListService.getChatListsByRoomId(roomId);
40-
return ApiResponse.onSuccess(response);
41-
}
42-
43-
@GetMapping("/{id}")
44-
public ApiResponse<ChatListResponse> getChatListById(@PathVariable Long id) {
45-
ChatListResponse response = chatListService.getChatListById(id);
46-
return ApiResponse.onSuccess(response);
47-
}
48-
49-
@PutMapping("/{id}")
50-
public ApiResponse<ChatListResponse> updateChatList(@PathVariable Long id,
51-
@Valid @RequestBody ChatListUpdateRequest request) {
52-
ChatListResponse response = chatListService.updateChatList(id, request);
53-
return ApiResponse.onSuccess(response);
54-
}
55-
56-
@DeleteMapping("/{id}")
57-
public ApiResponse<Void> deleteChatList(@PathVariable Long id) {
58-
chatListService.deleteChatList(id);
59-
return ApiResponse.onSuccess(null);
60-
}
61-
}
26+
private final ChatListService chatListService;
27+
28+
@PostMapping
29+
public ApiResponse<ChatListResponse> createChatList(
30+
@Valid @RequestBody ChatListCreateRequest request) {
31+
ChatListResponse response = chatListService.createChatList(request);
32+
return ApiResponse.onSuccess(response);
33+
}
34+
35+
@GetMapping("/room/{roomId}")
36+
public ApiResponse<List<ChatListResponse>> getChatListsByRoomId(@PathVariable Long roomId) {
37+
List<ChatListResponse> response = chatListService.getChatListsByRoomId(roomId);
38+
return ApiResponse.onSuccess(response);
39+
}
40+
41+
@GetMapping("/{id}")
42+
public ApiResponse<ChatListResponse> getChatListById(@PathVariable Long id) {
43+
ChatListResponse response = chatListService.getChatListById(id);
44+
return ApiResponse.onSuccess(response);
45+
}
46+
47+
@PutMapping("/{id}")
48+
public ApiResponse<ChatListResponse> updateChatList(
49+
@PathVariable Long id, @Valid @RequestBody ChatListUpdateRequest request) {
50+
ChatListResponse response = chatListService.updateChatList(id, request);
51+
return ApiResponse.onSuccess(response);
52+
}
53+
54+
@DeleteMapping("/{id}")
55+
public ApiResponse<Void> deleteChatList(@PathVariable Long id) {
56+
chatListService.deleteChatList(id);
57+
return ApiResponse.onSuccess(null);
58+
}
59+
}
Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,51 @@
11
package opensource.bravest.domain.chatList.dto;
22

3-
import jakarta.validation.constraints.NotBlank;
4-
import jakarta.validation.constraints.NotNull;
3+
import java.time.LocalDateTime;
54
import lombok.Builder;
65
import lombok.Getter;
76
import lombok.Setter;
87
import opensource.bravest.domain.chatList.entity.ChatList;
98

10-
import java.time.LocalDateTime;
119
public class ChatListDto {
1210

13-
// 1. 아이디어 생성 요청 DTO (Create Request)
14-
@Getter
15-
@Setter
16-
public static class ChatListCreateRequest {
17-
18-
private Long roomId;
19-
20-
private String content;
21-
22-
private Long registeredBy;
23-
}
24-
25-
// 2. 아이디어 수정 요청 DTO (Update Request)
26-
@Getter
27-
@Setter
28-
public static class ChatListUpdateRequest {
29-
30-
// 아이디어 내용 수정만 가정
31-
private String content;
32-
}
33-
34-
@Getter
35-
@Builder
36-
public static class ChatListResponse {
37-
private Long id;
38-
private Long roomId;
39-
private String content;
40-
private Long registeredBy;
41-
private LocalDateTime createdAt;
42-
43-
public static ChatListResponse fromEntity(ChatList chatList) {
44-
return ChatListResponse.builder()
45-
.id(chatList.getId())
46-
.roomId(chatList.getRoomId())
47-
.content(chatList.getContent())
48-
.registeredBy(chatList.getRegisteredBy().getId())
49-
.createdAt(chatList.getCreatedAt())
50-
.build();
51-
}
11+
// 1. 아이디어 생성 요청 DTO (Create Request)
12+
@Getter
13+
@Setter
14+
public static class ChatListCreateRequest {
15+
16+
private Long roomId;
17+
18+
private String content;
19+
20+
private Long registeredBy;
21+
}
22+
23+
// 2. 아이디어 수정 요청 DTO (Update Request)
24+
@Getter
25+
@Setter
26+
public static class ChatListUpdateRequest {
27+
28+
// 아이디어 내용 수정만 가정
29+
private String content;
30+
}
31+
32+
@Getter
33+
@Builder
34+
public static class ChatListResponse {
35+
private Long id;
36+
private Long roomId;
37+
private String content;
38+
private Long registeredBy;
39+
private LocalDateTime createdAt;
40+
41+
public static ChatListResponse fromEntity(ChatList chatList) {
42+
return ChatListResponse.builder()
43+
.id(chatList.getId())
44+
.roomId(chatList.getRoomId())
45+
.content(chatList.getContent())
46+
.registeredBy(chatList.getRegisteredBy().getId())
47+
.createdAt(chatList.getCreatedAt())
48+
.build();
5249
}
53-
}
50+
}
51+
}

0 commit comments

Comments
 (0)