Skip to content

fix: CD steps내에 versionName 추출 로직 변경#162

Merged
easyhooon merged 1 commit intodevelopfrom
BOOK-289-chore/#161
Aug 22, 2025
Merged

fix: CD steps내에 versionName 추출 로직 변경#162
easyhooon merged 1 commit intodevelopfrom
BOOK-289-chore/#161

Conversation

@easyhooon
Copy link
Copy Markdown
Contributor

@easyhooon easyhooon commented Aug 22, 2025

build-logic ApplicationConstants -> libs.version.toml

🔗 관련 이슈

📙 작업 설명

  • 제가 강제 업데이트 구현을 위해 여러 모듈에서 versionName을 가져올 수 있도록 libs.version.toml 내로 version 정보 및 앱에서 사용하는 상수들을 옮겨두었습니다.
  • 관련 변경사항에 의해 CD steps이 실패하여 CD steps 내에 versionName 추출 로직을 변경하였습니다.

🧪 테스트 내역 (선택)

  • 주요 기능 정상 동작 확인
  • 브라우저/기기에서 동작 확인
  • 엣지 케이스 테스트 완료
  • 기존 기능 영향 없음

📸 스크린샷 또는 시연 영상 (선택)

💬 추가 설명 or 리뷰 포인트 (선택)

Summary by CodeRabbit

  • Chores
    • Android 지속적 배포 파이프라인에서 앱 버전을 중앙 설정에서 추출하도록 조정하여 관리 일관성을 높였습니다.
    • 성공/실패 로그 메시지를 명확화해 배포 과정에서의 가시성과 문제 진단 용이성을 개선했습니다.
    • 버전 검증 및 출력 형식은 유지되어 기존 연동에 영향이 없습니다.
    • 결과적으로 빌드·배포 신뢰성과 안정성이 향상되며, 최종 사용자 기능이나 UI 변화는 없습니다.

build-logic ApplicationConstants -> libs.version.toml
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Aug 22, 2025

Walkthrough

Android CD 워크플로우에서 앱 버전 추출 소스를 ApplicationConstants.kt에서 gradle/libs.versions.toml로 변경하고, 이에 맞춰 grep/sed 패턴과 로그/에러 메시지를 TOML 기준으로 수정했습니다. 출력 방식(GITHUB_OUTPUTversion=v...)과 스텝 id는 유지됩니다.

Changes

Cohort / File(s) Change Summary
CD 버전 추출 소스 변경
.github/workflows/android-cd.yml
versionName 추출 대상 파일을 ApplicationConstants.ktgradle/libs.versions.toml로 변경, grep 키를 VERSION_NAMEversionName, sed 패턴을 TOML 형식에 맞게 수정, 관련 로그/에러 메시지 문구를 TOML 기준으로 업데이트. 출력 형식과 스텝 id 유지.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
CD 플로우 내 versionName 추출 로직 변경 (#161)

Poem

릴리즈 들판에 톰엘 길, 살짝 방향을 트니
grep과 sed 콧노래, 버전 이름을 줍네 🎵
kt는 쉬고 toml이 뿅—앞줄에서 빛나니,
나, 코드토끼, 팡! 태그 달고 뜁니다 🚀
v번호 주머니에 쏙, 배포길 가볍다 봄! 🐇

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch BOOK-289-chore/#161

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.

❤️ Share
🪧 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@github-actions github-actions Bot added the 🐞 fix Something isn't working label Aug 22, 2025
@github-actions github-actions Bot requested a review from seoyoon513 August 22, 2025 00:59
@easyhooon easyhooon changed the title fix: cd flow 내에 versionName 추출 방식 변경 fix: CD steps내에 versionName 추출 로직 변경 Aug 22, 2025
Copy link
Copy Markdown

@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: 1

🧹 Nitpick comments (2)
.github/workflows/android-cd.yml (2)

49-51: 출력 안전성/로그 가독성 소폭 개선 제안

단일 라인이어도 printf로 출력하면 개행/공백 이슈를 예방할 수 있고, 로그에는 정확한 소스 경로를 남기는 편이 추적에 유리합니다.

-                    echo "version=v${VERSION}" >> "$GITHUB_OUTPUT"
-                    echo "Version extracted from toml: v${VERSION}"
+                    printf "version=v%s\n" "$VERSION" >> "$GITHUB_OUTPUT"
+                    echo "Version extracted from gradle/libs.versions.toml: v${VERSION}"

41-51: 대안: TOML 파서를 사용해 형식 의존성 최소화

가능하다면 셸 정규식 대신 TOML 파싱으로 형식 변화(공백, 주석, 순서) 내성을 높이는 방법을 고려해 주세요. GitHub 호스트 런너는 Python 3.11+가 기본 제공되므로 tomllib로 파싱 가능합니다.

예시(참고용):

VERSION=$(
  python - <<'PY'
import sys, tomllib
with open("gradle/libs.versions.toml","rb") as f:
    data = tomllib.load(f)
# versionName의 위치가 [versions] 섹션에 있다면:
print(data.get("versions", {}).get("versionName",""))
PY
)

위와 같이 추출한 뒤 현재의 -z "$VERSION" 체크를 그대로 유지하면 됩니다.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5a0aa4a and a1894ce.

📒 Files selected for processing (1)
  • .github/workflows/android-cd.yml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: ci-build
🔇 Additional comments (1)
.github/workflows/android-cd.yml (1)

7-11: 트리거 브랜치 확인 필요: 현재 PR은 develop 대상이지만 워크플로우는 main에만 반응

PR 메타데이터상 대상 브랜치가 develop입니다. 본 워크플로우는 pull_requestbranches: [main]에만 트리거되어 이 PR에서는 실행되지 않을 수 있습니다. 의도된 설정인지 확인 부탁드립니다.

필요 시:

 on:
   pull_request:
     branches:
-            - main
+            - main
+            - develop

Comment on lines +44 to 47
VERSION=$(grep "versionName" gradle/libs.versions.toml | sed -E 's/.*versionName\s*=\s*"([^"]+)".*/\1/')
if [[ -z "$VERSION" ]]; then
echo "Error: ApplicationConstants.kt에서 VERSION_NAME 값을 추출하지 못했습니다." >&2
echo "Error: toml에서 versionName 값을 추출하지 못했습니다." >&2
exit 1
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

pipefail + grep|sed 파이프라인으로 인해 커스텀 에러 메시지 전에 스텝이 종료될 수 있음

set -euo pipefail 상태에서 grep이 매치를 못 찾으면 파이프라인이 즉시 실패하여 아래의 -z "$VERSION" 체크와 에러 로그가 실행되지 않습니다. 또한 현재 패턴은 주석/여러 매치에 취약합니다. grep을 제거하고 sed 단독(첫 매치만)으로 앵커링된 패턴을 사용해 안전하게 추출하는 편이 좋습니다. 파일 존재 여부도 선제 체크해 주세요.

적용 제안:

-                    VERSION=$(grep "versionName" gradle/libs.versions.toml | sed -E 's/.*versionName\s*=\s*"([^"]+)".*/\1/')
+                    # 파일 존재 여부 확인
+                    if [[ ! -f gradle/libs.versions.toml ]]; then
+                      echo "Error: gradle/libs.versions.toml 파일을 찾을 수 없습니다." >&2
+                      exit 1
+                    fi
+                    # 주석/여러 매치 대비: 첫 번째 유효한 versionName만 추출
+                    VERSION=$(sed -nE 's/^[[:space:]]*versionName[[:space:]]*=[[:space:]]*"([^"]+)".*/\1/p' gradle/libs.versions.toml | head -n1)
                     if [[ -z "$VERSION" ]]; then
                       echo "Error: toml에서 versionName 값을 추출하지 못했습니다." >&2
                       exit 1
                     fi
📝 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
VERSION=$(grep "versionName" gradle/libs.versions.toml | sed -E 's/.*versionName\s*=\s*"([^"]+)".*/\1/')
if [[ -z "$VERSION" ]]; then
echo "Error: ApplicationConstants.kt에서 VERSION_NAME 값을 추출하지 못했습니다." >&2
echo "Error: toml에서 versionName 값을 추출하지 못했습니다." >&2
exit 1
# 파일 존재 여부 확인
if [[ ! -f gradle/libs.versions.toml ]]; then
echo "Error: gradle/libs.versions.toml 파일을 찾을 수 없습니다." >&2
exit 1
fi
# 주석/여러 매치 대비: 첫 번째 유효한 versionName만 추출
VERSION=$(sed -nE 's/^[[:space:]]*versionName[[:space:]]*=[[:space:]]*"([^"]+)".*/\1/p' gradle/libs.versions.toml | head -n1)
if [[ -z "$VERSION" ]]; then
echo "Error: toml에서 versionName 값을 추출하지 못했습니다." >&2
exit 1
fi
🤖 Prompt for AI Agents
.github/workflows/android-cd.yml around lines 44 to 47: the current pipeline
uses grep|sed which can cause early exit under set -euo pipefail and is fragile
to comments/multiple matches; replace the grep|sed pipeline by first checking
that gradle/libs.versions.toml exists, then use a single sed invocation that
anchors to the versionName key and extracts only the first quoted value (so
comments or multiple matches won't break it), assign that to VERSION, and then
check if VERSION is empty and emit the custom error and exit non‑zero.

Copy link
Copy Markdown
Contributor

@seoyoon513 seoyoon513 left a comment

Choose a reason for hiding this comment

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

👍👍

@easyhooon easyhooon merged commit d8fcc92 into develop Aug 22, 2025
7 checks passed
@easyhooon easyhooon deleted the BOOK-289-chore/#161 branch August 22, 2025 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 fix Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BOOK-289/chore] CD steps내에 versionName 추출 로직 변경

2 participants