Skip to content

[Chore] CI 워크플로우 추가 - #15

Merged
lydbsdud merged 7 commits into
developfrom
chore/ci
Apr 8, 2026
Merged

[Chore] CI 워크플로우 추가#15
lydbsdud merged 7 commits into
developfrom
chore/ci

Conversation

@lydbsdud

@lydbsdud lydbsdud commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator

🔗 Issue

closes #14

💬 Context

PR 시 자동으로 빌드·테스트를 수행하는 GitHub Actions CI 워크플로우를 추가합니다.
develop, main 브랜치 대상 PR이 생성되면 ktlint 검사 및 Gradle 빌드·테스트가 자동 실행됩니다.

🛠 Changes

  • .github/workflows/ci.yml — GitHub Actions CI 워크플로우 추가
  • ktlint 검사 (./gradlew ktlintCheck)
  • 빌드 및 테스트 (./gradlew build)

👀 Review Focus

  • CI 워크플로우 스텝 구성이 적절한지
  • ktlint 플러그인 설정은 별도 브랜치(chore/ktlint)에서 추가 예정이므로, 해당 브랜치에서 추가하지 않았습니다.
  • SUBMODULE_TOKEN 시크릿은 submodule 레포 접근 권한 확보 후 등록 예정입니다.

✅ Check List

  • Assignees 등록
  • Label 등록
  • CI 통과 확인

Comment prefix — P1: 필수 반영 / P2: 적극 고려 / P3: 사소한 의견

Summary by CodeRabbit

  • New Features

    • 풀 리퀘스트 대상 자동 CI 파이프라인 추가(Checkout·JDK 25 설정·Gradle 캐시 포함)
    • 정적분석(ktlint·detekt)·빌드·테스트·코버리지 리포트 실행 및 PR 코멘트 게시(전체 50%, 변경 파일 70%)
    • Dockerfile 존재 시 PR 기반 이미지 빌드 검증 자동화
  • Chores

    • 빌드 설정에 JaCoCo 및 관련 Gradle 태스크 통합
    • Kotlin 플러그인 버전 정리
  • Tests

    • 기존 로드 테스트에 불필요 경고 억제 주석 추가

Copilot AI review requested due to automatic review settings April 7, 2026 13:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

develop/main 대상으로 PR 생성 시 Gradle 기반 빌드·테스트(및 코드 스타일 검사)를 자동 실행하는 GitHub Actions CI 워크플로우를 추가합니다.

Changes:

  • PR 트리거(develop, main) 기반 CI 워크플로우 추가
  • JDK 25(Temurin) 및 Gradle 액션 세팅 후 Gradle 태스크 실행(ktlintCheck, build)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/workflows/ci.yml
@lydbsdud
lydbsdud requested review from eundeang and suker80 April 7, 2026 13:28

@eundeang eundeang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

토큰 문제만 해결하면 될거 같아요! 고생해써요 🫳🏻🫳🏻

@suker80

suker80 commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator

@claude 리뷰해줭

@claude

claude Bot commented Apr 7, 2026

Copy link
Copy Markdown

Claude finished @suker80's task in 1m 5s —— View job


CI 워크플로우 코드 리뷰

  • 워크플로우 파일 읽기
  • 리뷰 작성

.github/workflows/ci.yml에 대한 리뷰입니다.

전반적인 구성

기본적인 CI 파이프라인 구조는 잘 갖춰져 있습니다. 아래 몇 가지 개선 포인트를 공유합니다.


P1: SUBMODULE_TOKEN fallback 처리 필요 (line 19)

token: ${{ secrets.SUBMODULE_TOKEN }}

Copilot 리뷰에서도 지적된 부분인데, SUBMODULE_TOKEN 시크릿이 아직 등록되지 않은 상태라 현재 CI가 checkout 단계에서 실패합니다. 시크릿이 빈 값이면 github.token으로 fallback 되도록 수정이 필요합니다.

token: ${{ secrets.SUBMODULE_TOKEN != '' && secrets.SUBMODULE_TOKEN || github.token }}

PR 본문에서 "SUBMODULE_TOKEN 시크릿은 submodule 레포 접근 권한 확보 후 등록 예정"이라고 언급하셨는데, 그 전까지는 fallback 처리를 해두는 게 안전합니다.

Fix this →


P1: ktlintCheck 태스크 미존재 (line 31)

- name: Run ktlint
  run: ./gradlew ktlintCheck

build.gradle.kts를 확인해보니 현재 ktlint 플러그인이 등록되어 있지 않습니다. 따라서 ./gradlew ktlintCheck를 실행하면 "Task 'ktlintCheck' not found" 오류로 CI가 실패합니다.

PR 본문에서 "ktlint 플러그인 설정은 chore/ktlint 브랜치에서 추가 예정"이라고 하셨는데, 해당 브랜치가 머지되기 전까지는 이 스텝이 항상 실패합니다. 아래 중 하나를 선택해 주세요:

  • (권장) ktlint 스텝을 주석 처리하거나 제거한 뒤 chore/ktlint 머지 후 다시 추가
  • ./gradlew check로 대체 (현재 설정에서 동작하는 태스크)

Fix this →


P2: JDK 25 사용 (line 24)

java-version: '25'

JDK 25는 현재(2026-04) Early Access 단계입니다. build.gradle.kts의 toolchain 설정과 일치하긴 하지만, Temurin 배포판이 JDK 25 EA를 안정적으로 지원하는지 확인이 필요합니다. LTS인 JDK 21로 내려가거나, 최소한 early-access: true 옵션을 명시적으로 추가하는 것을 고려해 보세요.

- name: Set up JDK 25
  uses: actions/setup-java@v4
  with:
    java-version: '25'
    distribution: 'temurin'
    check-latest: true

P3: Gradle 캐시 활용

gradle/actions/setup-gradle@v4는 기본적으로 Gradle 캐시를 활성화하므로 별도 설정 없이도 빌드 속도 향상이 됩니다. 현재 구성으로도 괜찮습니다.


P3: ./gradlew build에 테스트 포함 여부

./gradlew build는 기본적으로 test 태스크를 포함합니다. 다만 현재 프로젝트에 DB(MySQL) 의존성이 있는데(runtimeOnly("com.mysql:mysql-connector-j")), 통합 테스트가 있다면 CI에서 DB 연결 실패로 테스트가 깨질 수 있습니다. 현재는 테스트 코드가 없거나 단위 테스트만 있을 것 같지만, 향후 DB 연동 테스트 추가 시 testcontainers 혹은 인메모리 DB 설정을 고려해 주세요.


요약

우선순위 항목 상태
P1 SUBMODULE_TOKEN fallback 처리 수정 필요
P1 ktlintCheck 태스크 미존재 수정 필요 (혹은 임시 제거)
P2 JDK 25 EA 안정성 확인 검토 권장
P3 향후 DB 테스트 대비 참고 사항

@suker80 suker80 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

나중에 서브모듈 토큰 저것만 수정하면 될듯~!

@github-actions github-actions Bot added the 🗑️ CHORE 빌드 수정, 패키지 수정 등 label Apr 7, 2026
@sunwon12

sunwon12 commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

CI 개선 제안

현재 워크플로우에 아래 4가지를 추가하면 좋을 것 같습니다.

1. JaCoCo 테스트 커버리지 PR 코멘트

  • ./gradlew build./gradlew build jacocoTestReport로 변경
  • madrapps/jacoco-report@v1.7.1로 PR에 커버리지 리포트 자동 코멘트
  • 전체 50% / 변경 파일 70% 임계값 설정 (조정 가능)
  • permissionspull-requests: write 추가 필요

2. Detekt 정적 분석

  • ./gradlew detekt 스텝 추가
  • ktlint는 포맷팅, detekt는 코드 스멜/복잡도/잠재 버그 탐지로 역할이 보완적

3. Docker 이미지 빌드 검증

  • PR 단계에서 docker build만 수행 (push 없음)
  • Dockerfile 깨짐을 머지 전에 잡을 수 있음

4. Gradle Build Cache 최적화

  • setup-gradlecache-read-only: ${{ github.ref != 'refs/heads/main' }} 추가
  • main 외 브랜치에서는 캐시 읽기만 → 캐시 오염 방지 + 빌드 속도 개선

사전 세팅 필요

  • build.gradle.ktsjacoco, detekt 플러그인 적용
  • 프로젝트 루트에 Dockerfile 존재
  • 커버리지 임계값은 프로젝트 상황에 맞게 조정
수정된 ci.yml 전체
name: CI

on:
  pull_request:
    branches: [ develop, main ]

permissions:
  contents: read
  pull-requests: write  # JaCoCo 커버리지 코멘트용

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          submodules: recursive
          token: ${{ secrets.SUBMODULE_TOKEN != '' && secrets.SUBMODULE_TOKEN || github.token }}

      - name: Set up JDK 25
        uses: actions/setup-java@v4
        with:
          java-version: '25'
          distribution: 'temurin'

      # ── Gradle Setup (Build Cache 포함) ──
      - name: Setup Gradle
        uses: gradle/actions/setup-gradle@v4
        with:
          cache-read-only: ${{ github.ref != 'refs/heads/main' }}

      # ── Lint ──
      - name: Run ktlint
        run: ./gradlew ktlintCheck

      # ── Detekt (정적 분석) ──
      - name: Run Detekt
        run: ./gradlew detekt

      # ── Build & Test + JaCoCo 리포트 생성 ──
      - name: Build and Test
        run: ./gradlew build jacocoTestReport

      # ── JaCoCo 커버리지 PR 코멘트 ──
      - name: JaCoCo Coverage Report
        if: github.event_name == 'pull_request'
        uses: madrapps/jacoco-report@v1.7.1
        with:
          paths: '**/build/reports/jacoco/test/jacocoTestReport.xml'
          token: ${{ secrets.GITHUB_TOKEN }}
          min-coverage-overall: 50
          min-coverage-changed-files: 70
          title: '📊 테스트 커버리지 리포트'
          update-comment: true

      # ── Docker 이미지 빌드 검증 ──
      - name: Docker Build (verification only)
        run: |
          docker build -t ${{ github.repository }}:pr-${{ github.event.pull_request.number }} .

@coderabbitai

coderabbitai Bot commented Apr 8, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 18f07103-acd0-47cc-bb47-57da2fa5b918

📥 Commits

Reviewing files that changed from the base of the PR and between 5a8644e and aef9209.

📒 Files selected for processing (2)
  • build.gradle.kts
  • src/main/kotlin/com/team2/server/common/filter/MdcLoggingFilter.kt
💤 Files with no reviewable changes (1)
  • src/main/kotlin/com/team2/server/common/filter/MdcLoggingFilter.kt
🚧 Files skipped from review as they are similar to previous changes (1)
  • build.gradle.kts

Walkthrough

develop/main 대상 PR에서 실행되는 GitHub Actions CI 워크플로우를 추가하고 Gradle 설정에 detekt, jacoco 및 테스트-리포트 후속 처리를 도입했습니다. 소스 코드에서는 테스트 어노테이션과 사소한 포맷 변경만 있습니다.

Changes

Cohort / File(s) Summary
CI/CD 워크플로우
.github/workflows/ci.yml
신규 GitHub Actions 워크플로우 추가: PR(develop/main) 트리거, 서브모듈 체크아웃(선택적 SUBMODULE_TOKEN), Temurin JDK 25 설정, Gradle 캐시 구성, ktlintCheck, detekt, ./gradlew build jacocoTestReport 실행, JaCoCo XML 리포트를 PR 코멘트로 게시(전체 50% / 변경 파일 70% 임계), Dockerfile 존재 시 PR 번호 태그 도커 빌드 검증.
빌드 설정
build.gradle.kts
Kotlin 플러그인 버전 조정(복수 변경), dev.detekt(v2.0.0-alpha.2) 및 jacoco 플러그인 추가, 모든 Test 태스크에 finalizedBy(tasks.jacocoTestReport) 연결, jacocoTestReport에서 XML/HTML 리포트 활성화.
테스트 코드(사소함)
src/test/kotlin/com/team2/server/ServerApplicationTests.kt
테스트 메서드 contextLoads()@Suppress("EmptyFunctionBlock") 애노테이션 추가(기능 변경 없음).
리팩토링(포맷)
src/main/kotlin/com/team2/server/common/filter/MdcLoggingFilter.kt
클래스 본문 내 불필요한 빈 줄 제거(로직 변경 없음).

Sequence Diagram(s)

sequenceDiagram
    participant GH as GitHub
    participant GHA as GitHub\ Actions
    participant Repo as Repository
    participant Gradle as Gradle
    participant Detekt as Detekt
    participant JaCoCo as JaCoCo
    participant Docker as Docker

    GH->>GHA: PR to develop/main triggers workflow
    GHA->>Repo: Checkout repo (with submodules, optional token)
    GHA->>Gradle: Setup JDK 25 & Gradle cache
    GHA->>Detekt: Run detekt
    Detekt-->>GHA: Analysis results
    GHA->>Gradle: Run ktlintCheck
    Gradle-->>GHA: Lint results
    GHA->>Gradle: ./gradlew build jacocoTestReport
    Gradle->>JaCoCo: Generate XML/HTML reports
    JaCoCo-->>GHA: Coverage reports
    GHA->>GH: Post/update PR comment with coverage (overall 50%, changed 70%)
    alt Dockerfile present
        GHA->>Docker: Build image (tagged with PR number)
        Docker-->>GHA: Build result
    end
    GHA-->>GH: Workflow status
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 주요 변경사항인 CI 워크플로우 추가를 명확하게 나타내고 있습니다.
Linked Issues check ✅ Passed PR의 모든 코드 변경사항이 연결된 이슈 #14의 요구사항을 충족하고 있으며, 추가로 JaCoCo, Detekt, Docker 검증 등의 권장사항도 구현되었습니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 CI 워크플로우 구축 및 관련 Gradle 설정에 범위 내에 있으며, 비교적 경미한 코드 정리(빈줄 제거) 외에 범위를 벗어난 변경은 없습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/ci

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/ci.yml:
- Line 32: The cache-read-only expression currently uses github.ref !=
'refs/heads/main' which is always true for pull_request events; change the logic
for the cache-read-only key so PRs are evaluated against github.base_ref
(compare base branch name to "main") while non-PR events continue to use
github.ref (compare to 'refs/heads/main'), e.g. implement a conditional using
github.event_name to pick github.base_ref != "main" for pull_request events and
github.ref != "refs/heads/main" otherwise so cache writes are enabled when the
target is main.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 5d9f2993-988d-47d3-b01a-5fc0c40c6010

📥 Commits

Reviewing files that changed from the base of the PR and between 3018c83 and c38e00e.

📒 Files selected for processing (3)
  • .github/workflows/ci.yml
  • build.gradle.kts
  • src/test/kotlin/com/team2/server/ServerApplicationTests.kt

Comment thread .github/workflows/ci.yml Outdated
@lydbsdud lydbsdud self-assigned this Apr 8, 2026
lydbsdud and others added 6 commits April 8, 2026 21:31
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- JaCoCo 테스트 커버리지 PR 코멘트 추가
- Detekt 정적 분석 스텝 추가
- Docker 빌드 검증 스텝 추가 (Dockerfile 존재 시)
- Gradle Build Cache 최적화 (main 외 캐시 읽기 전용)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Kotlin 2.3.0으로 설정 (Detekt 호환)
- Detekt 2.0.0-alpha.2, ktlint 1.6.0 적용
- JaCoCo 커버리지 PR 코멘트 추가
- Docker 빌드 검증 스텝 추가 (Dockerfile 존재 시)
- Gradle Build Cache 최적화

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PR 이벤트에서 github.ref가 항상 refs/pull/*/merge라서
main 타겟 PR에서도 캐시 쓰기가 비활성화되는 문제 수정

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
.github/workflows/ci.yml (1)

32-32: ⚠️ Potential issue | 🟠 Major

cache-read-only 조건식이 PR에서 항상 true가 될 수 있습니다.

Line 32 조건은 pull_request에서 github.refrefs/pull/.../merge인 점 때문에 의도와 다르게 캐시 쓰기가 계속 막힐 수 있습니다. 이전 리뷰 지적과 동일한 유형으로 보입니다.

수정안
-          cache-read-only: ${{ github.event_name == 'pull_request' && github.base_ref != 'main' || github.ref != 'refs/heads/main' }}
+          cache-read-only: ${{ (github.event_name == 'pull_request' && github.base_ref != 'main') || (github.event_name != 'pull_request' && github.ref != 'refs/heads/main') }}
In GitHub Actions, for `pull_request` events, what are the exact formats/values of `github.ref` and `github.base_ref`?
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/ci.yml at line 32, The current `cache-read-only` boolean
expression improperly evaluates `github.ref` for `pull_request` events causing
cache to remain read-only; update the condition so it first checks
`github.event_name == 'pull_request'` and in that branch only consults
`github.base_ref != 'main'`, otherwise (when not a pull_request) consult
`github.ref != 'refs/heads/main'`; modify the `cache-read-only` expression
accordingly (ensure proper grouping/parentheses) so PRs use `github.base_ref`
and non-PR runs use `github.ref`.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@build.gradle.kts`:
- Line 64: There is an extraneous blank line causing ktlintKotlinScriptCheck to
fail; remove the empty line (the unnecessary whitespace) at the location around
the build script where the blank line appears (previously at line 64) so the
Kotlin script has no redundant empty line and ktlint passes; ensure there are no
other adjacent stray blank lines in the same block or top-level of the
build.gradle.kts file.
- Line 8: Replace the alpha Detekt plugin version with the stable release:
locate the plugin declaration id("dev.detekt") version "2.0.0-alpha.2" in
build.gradle.kts and change the version string to "1.23.8" so the project uses
the stable Detekt release for CI/production.

---

Duplicate comments:
In @.github/workflows/ci.yml:
- Line 32: The current `cache-read-only` boolean expression improperly evaluates
`github.ref` for `pull_request` events causing cache to remain read-only; update
the condition so it first checks `github.event_name == 'pull_request'` and in
that branch only consults `github.base_ref != 'main'`, otherwise (when not a
pull_request) consult `github.ref != 'refs/heads/main'`; modify the
`cache-read-only` expression accordingly (ensure proper grouping/parentheses) so
PRs use `github.base_ref` and non-PR runs use `github.ref`.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 431197df-edf8-467e-9b70-b879c79ae51d

📥 Commits

Reviewing files that changed from the base of the PR and between d16ebe8 and 5a8644e.

📒 Files selected for processing (3)
  • .github/workflows/ci.yml
  • build.gradle.kts
  • src/test/kotlin/com/team2/server/ServerApplicationTests.kt
✅ Files skipped from review due to trivial changes (1)
  • src/test/kotlin/com/team2/server/ServerApplicationTests.kt

Comment thread build.gradle.kts
Comment thread build.gradle.kts Outdated
- Kotlin 2.3.0 호환을 위해 dev.detekt:2.0.0-alpha.2 사용 (1.23.8은 Kotlin 2.0.21 기준)
- MdcLoggingFilter 클래스 본문 첫 줄 공백 제거 (ktlint 위반)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown

📊 테스트 커버리지 리포트

Overall Project 11.54%
File Coverage
MdcLoggingFilter.kt 7.5% 🍏

@lydbsdud
lydbsdud merged commit f57583a into develop Apr 8, 2026
5 checks passed
@lydbsdud
lydbsdud deleted the chore/ci branch April 8, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🗑️ CHORE 빌드 수정, 패키지 수정 등

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Chore] CI 워크플로우 추가

5 participants