Skip to content

Conversation

@move-hoon
Copy link
Member

@move-hoon move-hoon commented Apr 21, 2025

Related issue 🛠

Work Description ✏️

진행사항

  • lambda CI/CD 구축을 완료했습니다.

✅ CI 설명 (sentry-notifier-lambda-ci)

이 워크플로우는 Pull Request 시점에서 코드 품질을 검증하는 데에만 초점을 맞춘 CI입니다.

  • 실행 조건: main 브랜치로 PR이 생성될 때.
  • 주요 작업:
  • JDK 21과 Gradle을 설치.
    • .env 파일을 생성하여 Webhook 환경 변수 주입.
    • ./gradlew check 명령으로 컴파일 및 테스트 수행.
  • 설계 이유:
    • Sentry 알림 전용 Lambda 프로젝트는 규모가 작고, 배포 없이 코드 정합성과 테스트만 확인하면 충분합니다.
    • 별도 아티팩트 빌드/저장 없이 빠르게 테스트 피드백을 받을 수 있는 구조로 설계했습니다.
    • 이 단계에서는 아티팩트 생성이나 저장소 업로드, 배포 등의 작업은 하지 않습니다.

✅ CD 설명 (sentry-notifier-lambda-cd)

이 워크플로우는 main 브랜치에 push될 때 실제 Lambda로 배포까지 책임지는 CD입니다.

  • 실행 조건: main 브랜치로 push 되었을 때.
  • 주요 작업:
    • JDK 21, Gradle 설치 및 .env 생성 (CI와 동일).
    • ./gradlew build를 통해 shadow JAR 빌드 (즉, 실제 배포용 아티팩트 생성).
    • aws lambda update-function-code 명령을 통해 직접 Lambda에 배포.
    • 성공 및 실패 여부에 따라 Slack으로 알림 전송.
  • 설계 이유:
    • 프로젝트 자체가 매우 경량이고, 단일 책임을 가지는 Lambda이므로 별도의 저장소(S3, ECR 등)를 중간에 둘 필요가 없다고 생각했습니다.
    • 오히려 S3/ECR을 사용하면 보안 관리, 비용, IAM 정책 등의 추가 리소스 관리가 필요하므로 오히려 불필요한 복잡도만 증가할 것이라 판단했습니다.
    • aws lambda update-function-code 명령을 사용하면 GitHub Actions 내에서 직접 빌드한 JAR을 즉시 배포할 수 있으므로, 배포 파이프라인이 더 단순하고 효율적입니다.

✅ 결론: 왜 아티팩트를 저장하지 않고 바로 배포했는가?

Sentry Notifier 프로젝트는 단일 기능을 수행하는 경량 Lambda로, 별도의 저장소(S3, ECR 등)를 통해 아티팩트를 관리하고 전달하는 방식은 오히려 불필요한 리소스와 복잡성을 유발한다고 생각했습니다.
따라서 CI에서는 테스트만 진행하고, CD에서 직접 빌드한 JAR을 aws lambda update-function-code 명령을 통해 중간 저장소 없이 Lambda로 바로 배포하는 구조를 채택했습니다.

Trouble Shooting ⚽️

  • None

@move-hoon move-hoon self-assigned this Apr 21, 2025
@move-hoon move-hoon linked an issue Apr 21, 2025 that may be closed by this pull request
1 task
@height
Copy link

height bot commented Apr 21, 2025

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

@coderabbitai
Copy link

coderabbitai bot commented Apr 21, 2025

Summary by CodeRabbit

  • New Features
    • GitHub Actions 기반의 CI(테스트) 및 CD(배포) 자동화 워크플로우가 추가되었습니다.
    • AWS Lambda 배포 및 배포 성공/실패 시 Slack 알림이 자동 전송됩니다.
  • Documentation
    • README에 시스템 아키텍처 이미지와 포맷 개선이 반영되었습니다.

Walkthrough

이 변경사항은 서버리스 함수의 배포 프로세스 자동화를 위해 GitHub Actions 기반의 CI/CD 파이프라인을 추가하는 데 중점을 두고 있습니다. 두 개의 워크플로우 파일이 새롭게 도입되어, 하나는 메인 브랜치에 푸시될 때 AWS Lambda에 배포(CD), 다른 하나는 풀 리퀘스트 생성 시 빌드 및 테스트(CI)를 수행합니다. 또한, README 파일이 포맷 개선과 시스템 아키텍처 이미지 추가를 통해 업데이트되었습니다.

Changes

파일/경로 변경 요약
.github/workflows/ci.yml,
.github/workflows/cd.yml
GitHub Actions 기반 CI 및 CD 워크플로우 신규 추가. CI는 PR 대상 빌드/테스트, CD는 main 브랜치 배포 및 Slack 알림 포함.
README.md 시스템 아키텍처 섹션 및 이미지 추가, 포맷 개선, 불릿 포인트 강조 등 문서화 개선.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant GitHub Actions
    participant AWS Lambda
    participant Slack

    Developer->>GitHub Actions: main 브랜치에 push
    GitHub Actions->>GitHub Actions: 코드 checkout, JDK/Gradle 세팅, .env 생성
    GitHub Actions->>GitHub Actions: Gradle 빌드(shadowJar)
    GitHub Actions->>AWS Lambda: Lambda 코드 배포
    alt 배포 성공
        GitHub Actions->>Slack: 성공 알림 전송
    else 배포 실패
        GitHub Actions->>Slack: 실패 알림 전송
    end
Loading

Assessment against linked issues

Objective (이슈 번호) Addressed Explanation
서버리스 함수의 배포 프로세스 자동화를 위한 GitHub Actions CI/CD 구축 (#5)

Poem

🐰
깡총깡총 토끼가 코드를 짓네,
CI도 CD도 자동화했네!
Lambda로 점프, 슬랙엔 소식,
빌드와 배포가 이젠 손쉽지.
README도 반짝, 아키텍처 한눈에,
토끼는 기뻐서 귀를 쫑긋 세우네!


🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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: 0

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

16-33: 중복 스텝 재사용 액션 제안: JDK 설정, Gradle 캐싱, .env 생성 같은 공통 스텝을 컴포지트 액션 또는 재사용 가능한 워크플로우로 분리하면 유지보수성이 향상됩니다.

.github/workflows/cd.yml (1)

34-36: Shadow JAR 빌드 명시 고려: ./gradlew build 대신 ./gradlew shadowJar를 명시하면 빌드 의도를 더 명확히 전달할 수 있습니다.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9051caa and b6e1e14.

📒 Files selected for processing (3)
  • .github/workflows/cd.yml (1 hunks)
  • .github/workflows/ci.yml (1 hunks)
  • README.md (1 hunks)
🔇 Additional comments (15)
README.md (2)

13-16: 리스트 항목 가독성 향상: 굵은 텍스트를 사용하여 주요 기술 결정이 강조되어 문서의 가독성이 개선되었습니다.


24-26: 시스템 아키텍처 다이어그램 추가: 시각적 다이어그램을 통해 서비스 구조를 명확히 전달할 수 있어 유용합니다.

.github/workflows/ci.yml (6)

3-7: PR 기반 CI 트리거 적절성: main 브랜치 대상 PR에서만 실행되도록 설정하여 불필요한 빌드를 방지하고 효율성을 높였습니다.


10-13: 권한 최소화 설정: permissions: contents: read 로 레파지토리 콘텐츠 읽기 권한만 부여하여 보안을 강화했습니다.


16-21: JDK 21 설정 일관성: Corretto 21을 명시해 Lambda 런타임 환경과 버전 호환성을 확보했습니다.


22-24: Gradle 캐싱 사용: 빌드 속도를 단축하기 위해 Gradle 캐시 액션을 활용한 점이 적절합니다.


25-33: 환경 변수 주입 방식 검증 필요: src/main/resources/.env 파일 생성 후 애플리케이션이 이를 올바르게 로드하는지 구현상 확인이 필요합니다.


35-38: 컴파일 및 테스트 실행 확인: ./gradlew check로 컴파일과 테스트를 수행해 CI 핵심 역할을 충실히 이행하고 있습니다.

.github/workflows/cd.yml (7)

3-7: 푸시 기반 CD 트리거 적절성: main 브랜치로의 푸시 시 자동 배포되도록 설정하여 운영 효율성을 높였습니다.


15-20: JDK 21 구성 일관성: CI 워크플로우와 동일한 Corretto 21을 사용해 환경 차이를 최소화했습니다.


21-23: Gradle 캐싱 사용: 빌드 시간을 줄이기 위해 캐시 설정이 잘 적용되었습니다.


24-32: 환경 변수 주입 일관성 확인: CI와 동일한 .env 파일 생성 방식을 사용하지만, CD 전용 Slack Webhook 설정과 충돌 여부를 검증해야 합니다.


37-43: AWS 인증 설정 적절: AWS 자격 증명을 시크릿으로 안전하게 관리하고 configure-aws-credentials 액션을 활용해 안정적으로 설정했습니다.


44-50: 배포 아티팩트 경로 검증 필요: build/libs/sentry-webhook-shadow.jar 경로와 실제 생성된 JAR 파일명이 일치하는지 확인해주세요.


51-73: Slack 알림 구성 적절: 성공/실패 경우를 구분한 색상 메시지로 전송해 배포 모니터링 편의성을 높였습니다.

@move-hoon move-hoon merged commit ed577ee into main Apr 21, 2025
2 checks passed
@move-hoon move-hoon deleted the feat/#5 branch May 12, 2025 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: lambda CI/CD 구축

2 participants