-
Notifications
You must be signed in to change notification settings - Fork 3
refactor: 깃허브 이벤트 발행 위치 변경 #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Walkthrough이 변경은 Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant GitHubPushService
participant GitHubClient
participant EventPublisher
User->>GitHubPushService: pushSolutionToRepo(ctx)
GitHubPushService->>GitHubClient: isSourceCodeNewOrChanged(req)
alt 코드 변경 없음
GitHubClient-->>GitHubPushService: false
GitHubPushService-->>User: (아무 작업 없음, 조기 종료)
else 코드 변경 있음
GitHubClient-->>GitHubPushService: true
GitHubPushService->>EventPublisher: publish(GitPushStatusStarted)
GitHubPushService->>GitHubClient: commitAndPushToRepo(req)
GitHubClient-->>GitHubPushService: (push 완료)
GitHubPushService->>EventPublisher: publish(GitPushStatusSucceeded)
end
Estimated code review effort2 (~15분) Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/main/java/org/ezcode/codetest/infrastructure/github/GitHubClientImpl.java (1)
31-44: 중복 계산 최적화를 고려해보세요.
commitAndPushToRepo에서codeBlobSha를 다시 계산하고 있는데,isSourceCodeNewOrChanged에서 이미 계산했으므로 중복입니다. 성능상 큰 문제는 아니지만 최적화할 수 있습니다.다음과 같이 최적화할 수 있습니다:
public void commitAndPushToRepo(GitHubPushRequest req) { - String codeBlobSha = blobCalculator.calculateBlobSha(req.sourceCode()); + String codeBlobSha = blobCalculator.calculateBlobSha(req.sourceCode()); List<Map<String, Object>> entries = templateBuilder.buildGitTreeEntries(req, codeBlobSha); // ... 나머지 로직 }또는
GitHubPushRequest에codeBlobSha를 캐시하는 방법도 고려할 수 있습니다.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
src/main/java/org/ezcode/codetest/application/submission/model/SubmissionContext.java(0 hunks)src/main/java/org/ezcode/codetest/application/submission/port/GitHubClient.java(1 hunks)src/main/java/org/ezcode/codetest/application/submission/service/GitHubPushService.java(1 hunks)src/main/java/org/ezcode/codetest/domain/problem/model/entity/Testcase.java(1 hunks)src/main/java/org/ezcode/codetest/infrastructure/github/GitHubClientImpl.java(1 hunks)src/test/java/org/ezcode/codetest/application/submission/GitHubPushServiceTest.java(3 hunks)src/test/java/org/ezcode/codetest/infrastructure/github/GitHubClientTest.java(2 hunks)
🧠 Learnings (1)
📓 Common learnings
Learnt from: thezz9
PR: ezcode-my/backend#114
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubApiClient.java:159-165
Timestamp: 2025-06-28T02:03:38.693Z
Learning: User thezz9's service (ezcode) targets Korean users exclusively ("찐 한국인밖에 안 옴"), so Korean language hardcoding in commit messages and UI elements is intentional and appropriate for their use case.
Learnt from: thezz9
PR: ezcode-my/backend#36
File: src/main/java/org/ezcode/codetest/domain/submission/dto/SubmissionData.java:47-58
Timestamp: 2025-06-06T07:59:41.806Z
Learning: SubmissionData.withAggregatedStats() 메서드에서 testCaseList는 상위 프로세스(base() 메서드의 problemInfo.testcaseList())에서 이미 null 체크가 처리되어 오므로 추가적인 null 체크가 불필요함
Learnt from: thezz9
PR: ezcode-my/backend#75
File: src/main/java/org/ezcode/codetest/application/submission/aop/CodeReviewLockAspect.java:25-41
Timestamp: 2025-06-19T06:37:57.845Z
Learning: User thezz9 tends to skip validation for scenarios they consider unlikely to occur, but is willing to implement defensive programming practices when suggested for code robustness.
Learnt from: thezz9
PR: ezcode-my/backend#114
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubApiClient.java:93-96
Timestamp: 2025-06-28T02:04:24.957Z
Learning: User thezz9 sometimes temporarily uses less secure or inconsistent exception handling (like RuntimeException with raw error bodies) for debugging purposes when error messages are being hidden in the normal application flow, but acknowledges this as technical debt and fixes it once debugging is complete.
Learnt from: thezz9
PR: ezcode-my/backend#132
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubContentBuilder.java:72-72
Timestamp: 2025-07-02T09:39:31.485Z
Learning: User thezz9 prefers to proceed with breaking changes to path structures when it improves the organization, rather than maintaining backward compatibility or implementing migration strategies.
💤 Files with no reviewable changes (1)
- src/main/java/org/ezcode/codetest/application/submission/model/SubmissionContext.java
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: thezz9
PR: ezcode-my/backend#114
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubApiClient.java:159-165
Timestamp: 2025-06-28T02:03:38.693Z
Learning: User thezz9's service (ezcode) targets Korean users exclusively ("찐 한국인밖에 안 옴"), so Korean language hardcoding in commit messages and UI elements is intentional and appropriate for their use case.
Learnt from: thezz9
PR: ezcode-my/backend#36
File: src/main/java/org/ezcode/codetest/domain/submission/dto/SubmissionData.java:47-58
Timestamp: 2025-06-06T07:59:41.806Z
Learning: SubmissionData.withAggregatedStats() 메서드에서 testCaseList는 상위 프로세스(base() 메서드의 problemInfo.testcaseList())에서 이미 null 체크가 처리되어 오므로 추가적인 null 체크가 불필요함
Learnt from: thezz9
PR: ezcode-my/backend#75
File: src/main/java/org/ezcode/codetest/application/submission/aop/CodeReviewLockAspect.java:25-41
Timestamp: 2025-06-19T06:37:57.845Z
Learning: User thezz9 tends to skip validation for scenarios they consider unlikely to occur, but is willing to implement defensive programming practices when suggested for code robustness.
Learnt from: thezz9
PR: ezcode-my/backend#114
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubApiClient.java:93-96
Timestamp: 2025-06-28T02:04:24.957Z
Learning: User thezz9 sometimes temporarily uses less secure or inconsistent exception handling (like RuntimeException with raw error bodies) for debugging purposes when error messages are being hidden in the normal application flow, but acknowledges this as technical debt and fixes it once debugging is complete.
Learnt from: thezz9
PR: ezcode-my/backend#132
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubContentBuilder.java:72-72
Timestamp: 2025-07-02T09:39:31.485Z
Learning: User thezz9 prefers to proceed with breaking changes to path structures when it improves the organization, rather than maintaining backward compatibility or implementing migration strategies.
🔇 Additional comments (11)
src/main/java/org/ezcode/codetest/domain/problem/model/entity/Testcase.java (1)
61-62: 방어적 프로그래밍 개선이 잘 적용되었습니다.
getInput()메서드와 동일한 패턴으로 null 체크를 추가하여NullPointerException발생을 방지했습니다. 일관성 있고 안전한 구현입니다.src/main/java/org/ezcode/codetest/application/submission/port/GitHubClient.java (1)
7-7: 인터페이스 개선이 잘 구현되었습니다.소스코드 변경 여부 확인 로직을 별도 메서드로 분리하여 단일 책임 원칙을 준수하고, 불필요한 푸시 작업을 방지할 수 있게 되었습니다.
src/main/java/org/ezcode/codetest/application/submission/service/GitHubPushService.java (1)
32-41: GitHub 이벤트 발행 위치 변경이 적절히 구현되었습니다.소스코드 변경 여부를 먼저 확인한 후 실제 푸시가 필요한 경우에만 이벤트를 발행하도록 최적화되었습니다. 불필요한 GitHub API 호출과 이벤트 발행을 방지하는 효율적인 구조입니다.
src/test/java/org/ezcode/codetest/application/submission/GitHubPushServiceTest.java (2)
108-138: 새로운 테스트 케이스가 잘 구현되었습니다.코드 변경이 없을 때의 동작을 정확히 검증하고 있습니다. 푸시 작업과 이벤트 발행이 모두 생략되는지 확인하는 적절한 테스트입니다.
159-159: 기존 테스트 업데이트가 적절합니다.새로 추가된
isSourceCodeNewOrChanged메서드를true로 모킹하여 기존 테스트의 의도된 동작을 유지하도록 잘 수정되었습니다.Also applies to: 195-195
src/main/java/org/ezcode/codetest/infrastructure/github/GitHubClientImpl.java (1)
23-28: 소스코드 변경 검증 메서드가 잘 구현되었습니다.기존
commitAndPushToRepo에서 초기 반환 로직을 적절히 분리했습니다. 메서드명과 반환값이 명확하고 로직도 정확합니다.src/test/java/org/ezcode/codetest/infrastructure/github/GitHubClientTest.java (5)
59-62: 리팩터링에 맞춰 테스트가 잘 개선되었습니다.
isSourceCodeNewOrChanged메서드 분리에 따라 테스트도 해당 메서드를 직접 호출하여 검증하도록 변경되어 테스트 의도가 더 명확해졌습니다.
79-79: mock 설정 순서 개선이 적절합니다.실행 순서에 맞게 mock 설정을 재배치한 것으로 보이며, 테스트 가독성 향상에 도움이 됩니다.
97-99: 변수 도입으로 테스트 가독성이 향상되었습니다.하드코딩된 문자열 대신 의미있는 변수명을 사용하여 테스트의 의도가 더 명확해졌습니다.
103-104: sourceCode 변수 활용으로 일관성이 개선되었습니다.setup에서 정의한
sourceCode변수를 일관되게 사용하여 테스트의 통일성이 향상되었습니다.
107-117: mock 설정과 검증 로직이 체계적으로 개선되었습니다.변수를 활용한 mock 설정과 검증으로 테스트의 추적성과 유지보수성이 향상되었습니다.
깃허브 이벤트 발행 위치 변경 및 테스트 코드 수정했습니다.
output 이 null 일 때의 방어코드도 추가했습니다
Summary by CodeRabbit
신규 기능
버그 수정
테스트
리팩터링