Skip to content

[Feat/#131] CI코드수정#132

Merged
hooni0918 merged 7 commits intodevelopfrom
feat/#131-CI코드수정
Jul 31, 2025

Hidden character warning

The head ref may contain hidden characters: "feat/#131-CI\ucf54\ub4dc\uc218\uc815"
Merged

[Feat/#131] CI코드수정#132
hooni0918 merged 7 commits intodevelopfrom
feat/#131-CI코드수정

Conversation

@hooni0918
Copy link
Member

@hooni0918 hooni0918 commented Jul 29, 2025

🔗 연결된 이슈

📄 작업 내용

  • CI 의 속도를좀 끌어올려보았습니다.

변경전
스크린샷 2025-07-29 오후 2 31 28


변경후
스크린샷 2025-07-29 오후 2 31 23

💻 주요 코드 설명

CI 최적화

기존 CI

기존 ci.yml 파일은 캐시 없이 매번 모든 의존성을 새로 설치하는 구조였습니다

name: CI (Lint + Test)
on:
  pull_request:
    branches: [main, develop, release/**]

jobs:
  ci:
    runs-on: macos-latest
    permissions:
      pull-requests: write
    steps:
      - uses: actions/checkout@v3

      # ❌ 캐시 없음 - 매번 새로 설치
      - name: Set up Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: '3.1'

      # ❌ 순차 실행 - 시간 낭비
      - name: Install dependencies
        run: bundle install
      - name: Install SwiftLint
        run: brew install swiftlint
      - name: Install mise
        run: brew install mise

      - name: Enable idiomatic version files for ruby
        run: mise settings add idiomatic_version_file_enable_tools ruby

주요 병목점

1. 캐시 부재: 매번 동일한 의존성을 새로 다운로드

  • Ruby gems 200+ 패키지 매번 설치 (2-3분)
  • Homebrew 패키지 매번 설치 (1-2분)
  • Tuist 의존성 매번 resolve (1-2분)

2. 순차 실행: 병렬 가능한 작업을 순서대로 실행

  • bundle installbrew installmise install 순차 대기
  • 총 설치 시간이 모두 누적됨

3. 환경 최적화 부재: 불필요한 작업들 실행

  • Homebrew 자동 업데이트로 시간 낭비
  • Bundle 병렬 설정 없음

TO-BE

수정한 ci.yml

name: CI (Lint + Test)
on:
  pull_request:
    branches: [main, develop, release/**]
  push:
    branches: [feat/**]  # ✅ 테스트용 트리거 추가 (사실 큰 관계는 없습니다 나중에 테스트하기 편한용)

# ✅ 환경 최적화 추가
env:
  HOMEBREW_NO_AUTO_UPDATE: 1  # Homebrew 자동 업데이트 비활성화
  BUNDLE_JOBS: 4               # Bundle 병렬 작업
  BUNDLE_RETRY: 3              # 실패 시 재시도

jobs:
  ci:
    runs-on: macos-latest
    timeout-minutes: 30        # ✅ 빠른 실패 - 30분 초과 시 종료 (근데 이럴일이 있을까..ㅋㅋ)
    permissions:
      pull-requests: write
    steps:
      - uses: actions/checkout@v3

      # ✅ 스마트 캐싱 시스템 추가
      - name: Cache Ruby gems
        uses: actions/cache@v3
        with:
          path: vendor/bundle
          key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
          restore-keys: |
            ${{ runner.os }}-gems-

      - name: Cache mise tools
        uses: actions/cache@v3
        with:
          path: ~/.local/share/mise
          key: ${{ runner.os }}-mise-${{ hashFiles('.mise.toml', 'Tuist/Dependencies.swift') }}

      - name: Cache Tuist dependencies
        uses: actions/cache@v3
        with:
          path: |
            Tuist/Dependencies
            ~/.tuist/Cache
          key: ${{ runner.os }}-tuist-${{ hashFiles('Tuist/Dependencies.swift') }}

      # ✅ 병렬 처리 최적화
      - name: Install dependencies in parallel
        run: |
          bundle config set --local path 'vendor/bundle'
          bundle config set --local jobs 4

          # 백그라운드에서 brew 설치 시작
          (brew install swiftlint mise) &
          BREW_PID=$!

          # 동시에 bundle install 실행
          bundle install --jobs 4 --retry 3

          # brew 완료까지 대기
          wait $BREW_PID

      # ✅ PATH 문제 해결
      - name: Enable idiomatic version files for ruby
        run: |
          export PATH="/opt/homebrew/bin:$PATH"
          mise settings add idiomatic_version_file_enable_tools ruby

핵심 개선사항

1. 캐시 도입으로 기존 다운받은 의존성들 다시 다운 X

  • vendor/bundle: Ruby gems 캐시
  • ~/.local/share/mise: mise tools 캐시
  • Tuist/Dependencies: Tuist SPM 의존성 캐시

2. 병렬 처리

# 기존: 순차 실행 (4-5분)
bundle install     # 2분 대기
brew install       # 1분 대기
mise install       # 1분 대기

# 개선: 병렬 실행 (2분)
(brew install swiftlint mise) &  # 백그라운드
bundle install --jobs 4          # 동시 실행
wait                             # 완료 대기

3. timeout 사용

  • timeout-minutes: 30: 무한 대기 방지

4. 환경 최적화: 불필요한 작업 제거

  • HOMEBREW_NO_AUTO_UPDATE: 1: 자동 업데이트 비활성화
  • BUNDLE_JOBS: 4: Bundle 병렬 설치 활성화

👀 기타 더 이야기해볼 점

기존 코드에서 Test코드를 사용해서 해당 테스트가 우선으로 실행되는 방식으로 도전해보려 햇는데 이 방식은 테스트 커버리지가 올라와야 의미가 있을것 같아서 보류했습니다. 그때까지 킵고잉~

✔️ CI Completed

  • ✅ Build: Completed

✔️ CI Completed

  • ✅ Build: Completed

@hooni0918 hooni0918 requested review from SijongKim93 and k-nh July 29, 2025 05:32
@hooni0918 hooni0918 self-assigned this Jul 29, 2025
@hooni0918 hooni0918 added fix 버그나 오류 해결 시 사용 jihoon 나는 지훈 labels Jul 29, 2025
@hooni0918 hooni0918 merged commit 1fcddb7 into develop Jul 31, 2025
1 check passed
@hooni0918 hooni0918 deleted the feat/#131-CI코드수정 branch July 31, 2025 12:14
@hooni0918 hooni0918 changed the title Feat/#131 ci코드수정 [Feat/#131] CI코드수정 Jul 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix 버그나 오류 해결 시 사용 jihoon 나는 지훈

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] CI코드 수정

1 participant