Skip to content

Conversation

@LeeCh0129
Copy link

@LeeCh0129 LeeCh0129 commented Jun 22, 2025

📌 변경 사항 개요

기존 CI/CD 파이프라인의 메모리 사용량을 90% 절약하여 t2.micro 환경에서 안정적으로 동작하도록 최적화

✨ 요약

  • CI: npm ci → 글로벌 ESLint 방식으로 변경
  • Deploy: warmup 단계 분리 및 스마트 메모리 관리
  • 성능: 500MB → 50MB 메모리 사용량 달성

📝 상세 내용

CI 최적화

  • 실행 시간: 10분 → 2분
  • 메모리: 500MB → 50MB (90% 절약)
  • 📁 검사 범위: 전체 → 변경된 파일만

Deploy 최적화

  • warmup 단계로 환경 사전 체크
  • 빌드 캐시 크기 기반 스마트 정리
  • 메모리 모니터링 및 자동 정리

🔗 관련 이슈

메모리 부족으로 인한 CI/CD 실패 문제 해결

✅ 체크리스트

  • 브랜치 네이밍 컨벤션을 준수했습니다
  • 커밋 컨벤션을 준수했습니다
  • 메모리 최적화를 검증했습니다

💡 참고 사항

Summary by CodeRabbit

  • 워크플로우 개선
    • 린트 검사 속도가 크게 향상되어 변경된 JavaScript 및 TypeScript 파일만 빠르게 검사합니다.
    • 배포 프로세스가 두 단계(warmup, deploy)로 분리되어 안정성이 높아졌습니다.
    • 배포 로그 및 헬스 체크가 개선되어 더 명확한 상태 확인이 가능합니다.
    • 배포 트리거가 main 브랜치로 제한되고, 환경 변수 DOCKER_CONTAINER_NAME이 추가되었습니다.

@LeeCh0129 LeeCh0129 self-assigned this Jun 22, 2025
@LeeCh0129 LeeCh0129 added the ♻️Refactor 리팩토링 label Jun 22, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jun 22, 2025

"""

Walkthrough

GitHub Actions 워크플로우가 리팩토링되었습니다. ESLint 검사 작업은 변경된 파일만 빠르게 검사하도록 간소화되었고, 배포 워크플로우는 환경 점검(warmup)과 배포(deploy)로 분리되었으며, 하드코딩된 값이 변수로 대체되고, 일부 작업이 스크립트 실행으로 대체되었습니다.

Changes

파일/경로 변경 요약
.github/workflows/ci.yml ESLint 검사 작업을 단일 스크립트로 단순화, 타임아웃 2분으로 단축, checkout 액션 v4로 업그레이드
.github/workflows/deploy.yml 단일 deploy 작업을 warmup과 deploy로 분리, deploy가 warmup에 의존, 배포 단계 스크립트화, 변수 사용 확대

Sequence Diagram(s)

sequenceDiagram
    participant GitHub Actions
    participant Runner

    GitHub Actions->>Runner: warmup job 실행 (환경 점검)
    Runner-->>GitHub Actions: warmup 완료
    GitHub Actions->>Runner: deploy job 실행 (deploy.sh 실행)
    Runner->>Runner: 컨테이너 상태 확인 및 health check
    Runner-->>GitHub Actions: 배포 및 상태 보고
Loading

Possibly related PRs

  • CoPlay-FE/coplan#36: ESLint GitHub Actions 워크플로우를 변경하여, Node.js 설정이나 의존성 설치 없이 변경된 파일만 검사하도록 단순화한 PR로, 동일 파일을 직접 수정함.

Suggested labels

🔧Chore

Suggested reviewers

  • dkslel1225
  • yuj2n

Poem

깡충깡충 토끼가 워크플로우를 정리해요,
빠른 린트 체크, 배포도 두 단계로 나눠요.
하드코딩은 안녕, 변수로 인사해요!
새로워진 흐름에 귀가 쫑긋,
토끼는 오늘도 코드를 사랑해요.
🐇✨
"""


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (3)
.github/workflows/ci.yml (1)

18-18: 불필요한 트레일링 스페이스 제거
YAMLlint에서 지적된 공백을 삭제해 주세요.

-      - name: Lightning fast lint check··
+      - name: Lightning fast lint check
.github/workflows/deploy.yml (2)

38-40: 하드코딩된 경로 개선 제안
cd /home/ubuntu/coplan 절대 경로 대신 $GITHUB_WORKSPACE를 사용해 러너마다 유연하게 조정하세요.

-          cd /home/ubuntu/coplan
+          cd $GITHUB_WORKSPACE

17-18: 불필요한 트레일링 스페이스 제거
YAMLlint에서 지적된 whoamidocker --version 라인의 끝 공백을 삭제해 주세요.

-          whoami                
-          docker --version       
+          whoami
+          docker --version
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6c170a2 and 8c1778d.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml (1 hunks)
  • .github/workflows/deploy.yml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/deploy.yml

[error] 17-17: trailing spaces

(trailing-spaces)


[error] 18-18: trailing spaces

(trailing-spaces)

🔇 Additional comments (2)
.github/workflows/ci.yml (2)

12-12: 타임아웃 최소값 검증 필요
2분으로 설정된 timeout-minutes: 2가 글로벌 ESLint 검사 단계를 안정적으로 완료할 수 있는지 확인해 주세요.


16-16: Node.js 및 ESLint 글로벌 설치 여부 확인
setup-node 단계가 제거되면서, 셀프호스티드 러너에 Node.js와 ESLint CLI가 설치돼 있지 않으면 명령이 실패합니다.

Comment on lines 48 to 51
if docker ps | grep -q $DOCKER_CONTAINER_NAME; then
echo "✅ Deployment completed!"
docker logs --tail 5 $DOCKER_CONTAINER_NAME
echo "🌐 https://coplan.work" # ✅ HTTPS
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

환경 변수 인용 및 기본값 검증
$DOCKER_CONTAINER_NAME이 설정되지 않으면 오류가 발생할 수 있습니다. 변수 인용 및 미설정 시 실패 로직을 추가하세요.

-          if docker ps | grep -q $DOCKER_CONTAINER_NAME; then
+          if [ -z "${DOCKER_CONTAINER_NAME:-}" ]; then
+            echo "❌ DOCKER_CONTAINER_NAME이 설정되지 않았습니다."
+            exit 1
+          fi
+          if docker ps | grep -q "$DOCKER_CONTAINER_NAME"; then
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if docker ps | grep -q $DOCKER_CONTAINER_NAME; then
echo "✅ Deployment completed!"
docker logs --tail 5 $DOCKER_CONTAINER_NAME
echo "🌐 https://coplan.work" # ✅ HTTPS
if [ -z "${DOCKER_CONTAINER_NAME:-}" ]; then
echo "❌ DOCKER_CONTAINER_NAME이 설정되지 않았습니다."
exit 1
fi
if docker ps | grep -q "$DOCKER_CONTAINER_NAME"; then
echo "✅ Deployment completed!"
docker logs --tail 5 $DOCKER_CONTAINER_NAME
echo "🌐 https://coplan.work" # ✅ HTTPS
🤖 Prompt for AI Agents
In .github/workflows/deploy.yml around lines 48 to 51, the script uses the
environment variable $DOCKER_CONTAINER_NAME without quotes or validation, which
can cause errors if the variable is unset or contains spaces. Fix this by
quoting the variable references like "$DOCKER_CONTAINER_NAME" and add a check
before this block to verify that $DOCKER_CONTAINER_NAME is set and non-empty,
exiting with an error message if it is not.

free -h # 메모리 상태 사전 체크
docker ps # 현재 컨테이너 상태
deploy:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

배포 조건에 머지 여부 확인 로직 추가 필요
현재 PR Close 시점에 무조건 배포됩니다. 머지된 경우에만 실행되도록 if: github.event.pull_request.merged == true를 추가하세요.

  deploy:
-   needs: warmup # ✅ warmup 완료 후 실행
+   needs: warmup # ✅ warmup 완료 후 실행
+   if: github.event.pull_request.merged == true
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
deploy:
deploy:
needs: warmup # ✅ warmup 완료 후 실행
if: github.event.pull_request.merged == true
🤖 Prompt for AI Agents
In .github/workflows/deploy.yml at line 22, the deploy job currently runs
unconditionally when a PR is closed. To ensure deployment only occurs if the PR
was merged, add the condition `if: github.event.pull_request.merged == true` to
the deploy job definition. This will restrict the deployment step to run only
when the PR merge event is confirmed.

Copy link

@coderabbitai coderabbitai bot left a 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 (7)
.github/workflows/ci.yml (3)

39-49: 메모리 기반 파일 추출 임계값 로직

  • 200MB 이하일 때 상한 10 파일, PR 크기가 30개 초과 시 30 파일 제한은 합리적입니다.
  • head -$MAX_FILES 대신 head -n $MAX_FILES를 사용해 POSIX 호환성을 높이세요.

Also applies to: 51-51


72-76: 파일 수 및 메모리 추정 로직
wc -w 대신 wc -l로 파일 개수를 세면 파일 경로에 공백이 있을 때도 정확합니다.


12-12: 트레일링 공백 제거
YAML 파일에서 트레일링 스페이스는 lint 에러를 발생시킵니다. 해당 라인의 공백을 제거하세요.

Also applies to: 18-18, 32-32, 35-35, 37-37, 50-50, 52-52

.github/workflows/deploy.yml (4)

21-24: GitHub 컨텍스트 직접 사용 보안 검토
${{ github.event.pull_request.title }} 등 사용자 입력에 직접 의존한 인라인 스크립트는 잠재적 인젝션 위험이 있습니다. 환경 변수로 분리한 뒤, 적절히 인용해 사용하거나 검증 로직을 추가하세요.


50-52: 절대 경로 하드코딩 개선 제안
cd /home/ubuntu/coplan 대신 ${{ github.workspace }}나 환경 변수로 경로를 관리하면 이식성을 높일 수 있습니다.


59-67: 컨테이너 검사 시 변수 인용
$DOCKER_CONTAINER_NAME 사용 시 따옴표를 추가해 예기치 않은 공백이나 특수문자 이슈를 방지하세요.

-if docker ps | grep -q $DOCKER_CONTAINER_NAME; then
+if docker ps | grep -q "$DOCKER_CONTAINER_NAME"; then

또한 docker logs 호출부에도 "$DOCKER_CONTAINER_NAME" 인용을 일관되게 적용하세요.


27-28: 트레일링 공백 제거
whoami , docker --version 행에 트레일링 스페이스가 존재합니다. YAML lint 오류를 방지하려면 제거하세요.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 67d35eb and a230106.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml (1 hunks)
  • .github/workflows/deploy.yml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/ci.yml

[error] 32-32: trailing spaces

(trailing-spaces)


[error] 35-35: trailing spaces

(trailing-spaces)


[error] 37-37: trailing spaces

(trailing-spaces)


[error] 50-50: trailing spaces

(trailing-spaces)


[error] 52-52: trailing spaces

(trailing-spaces)

.github/workflows/deploy.yml

[error] 27-27: trailing spaces

(trailing-spaces)


[error] 28-28: trailing spaces

(trailing-spaces)

🪛 actionlint (1.7.7)
.github/workflows/deploy.yml

19-19: "github.event.pull_request.title" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions for more details

(expression)

🔇 Additional comments (11)
.github/workflows/ci.yml (7)

12-12: 타임아웃 재검토 필요
현재 timeout-minutes: 2는 변경된 파일만 검사하는 워크플로우에 충분히 짧을 수 있지만, JS/TS 파일이 많은 경우 타임아웃이 발생할 수 있습니다. 실제 평균 실행 시간을 측정해보고, 안정적인 범위로 조정하세요.


16-16: actions/checkout@v4 및 fetch-depth 검증
actions/checkout@v4로 버전 업그레이드된 점이 좋습니다. 하지만 fetch-depth: 2가 베이스 브랜치 비교에 충분한 이력을 확보하는지 확인이 필요합니다.

Also applies to: 18-18


25-26: 메모리 체크 로직 적절성 검토
free -m | grep ^Mem | awk '{print $7}'으로 사용 가능한 메모리를 확인하는 방식은 일반적이지만, self-hosted 러너 환경에 따라 필드 위치가 달라질 수 있습니다. 다른 러너에서 일관되게 동작하는지 검증하세요.


28-34: PR/Push 이벤트 분기 로직 적절
PR 이벤트 시 베이스 브랜치와 비교하도록 git diff origin/$BASE_BRANCH...HEAD를 사용한 점이 정확합니다. push 이벤트용 HEAD~1 분기 또한 fallback으로 적절하지만, 복수 커밋 PR은 PR 이벤트 분기로만 처리됨을 확인했습니다.


57-62: 푸시 이벤트 fallback 확인
푸시 이벤트에서 HEAD~1이 존재하지 않을 경우 마지막 5개 파일을 대상으로 검색하는 로직이 안전장치로 적절합니다.


66-69: 변경 파일 없을 때 즉시 종료
[ -z "$CHANGED_FILES" ] 체크 후 exit 0로 종결하는 방식은 불필요한 실행을 방지해 효율적입니다.


78-78: ESLint 실행 방식
변경 파일만 npx eslint $CHANGED_FILES로 검사하는 아이디어가 메모리 최적화 목표에 부합합니다.

.github/workflows/deploy.yml (4)

6-6: 배포 트리거 브랜치 제한 확인
branches: [main]로 명시적으로 main 브랜치만 배포하도록 수정된 점이 의도에 부합합니다.


9-9: 환경 변수 DOCKER_CONTAINER_NAME 선언
전역 envDOCKER_CONTAINER_NAME을 선언해 일관된 참조가 가능해진 점이 좋습니다.


16-17: 러너 및 타임아웃 설정 확인
self-hosted 러너와 timeout-minutes: 3 설정은 빠른 warmup 단계에 적합합니다. 실제 warmup 단계 수행 시간을 모니터링해서 필요 시 조정하세요.


40-41: actions/checkout@v4 적용
actions/checkout@v4로 업그레이드된 점이 CI와 일관되어 안정적입니다.

@LeeCh0129 LeeCh0129 merged commit 41090e2 into develop Jun 22, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

♻️Refactor 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants