Skip to content

Commit

Permalink
refactor: CI turbo로 프론트, 백엔드 동시 수행
Browse files Browse the repository at this point in the history
  • Loading branch information
ezcolin2 committed Nov 16, 2024
1 parent b5a320d commit 318fbe6
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 160 deletions.
242 changes: 119 additions & 123 deletions .github/workflows/ci-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- develop

jobs:
setup-backend:
setup:
runs-on: ubuntu-latest
outputs:
cache-key: ${{ steps.cache-backend-deps.outputs.cache-hit }}
Expand All @@ -22,50 +22,49 @@ jobs:
with:
node-version: "23"

# 백엔드 의존성 캐시 설정
# turbo 의존성 캐시 설정
- name: Cache Yarn dependencies for backend
id: cache-backend-deps
id: cache-deps
uses: actions/cache@v3
with:
path: apps/backend/node_modules
key: ${{ runner.os }}-backend-yarn-${{ hashFiles('apps/backend/yarn.lock') }}
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}

# 백엔드 의존성 설치
# turbo 의존성 설치
- name: Install backend dependencies
if: steps.cache-backend-deps.outputs.cache-hit != 'true'
working-directory: ./apps/backend
run: yarn install

setup-frontend:
runs-on: ubuntu-latest
outputs:
cache-key: ${{ steps.cache-frontend-deps.outputs.cache-hit }}
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "23"

# 프론트엔드 의존성 캐시 설정
- name: Cache Yarn dependencies for frontend
id: cache-frontend-deps
uses: actions/cache@v3
with:
path: apps/frontend/node_modules
key: ${{ runner.os }}-frontend-yarn-${{ hashFiles('apps/frontend/yarn.lock') }}

# 프론트엔드 의존성 설치
- name: Install frontend dependencies
if: steps.cache-frontend-deps.outputs.cache-hit != 'true'
working-directory: ./apps/frontend
if: steps.cache-deps.outputs.cache-hit != 'true'
run: yarn install

backend-lint:
# setup:
# runs-on: ubuntu-latest
# outputs:
# cache-key: ${{ steps.cache-deps.outputs.cache-hit }}
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3

# - name: Set up Node.js
# uses: actions/setup-node@v3
# with:
# node-version: "23"

# # 프론트엔드 의존성 캐시 설정
# - name: Cache Yarn dependencies for frontend
# id: cache-deps
# uses: actions/cache@v3
# with:
# path: node_modules
# key: ${{ runner.os }}-frontend-yarn-${{ hashFiles('yarn.lock') }}

# # 프론트엔드 의존성 설치
# - name: Install frontend dependencies
# if: steps.cache-frontend-deps.outputs.cache-hit != 'true'
# working-directory: ./apps/frontend
# run: yarn install

lint:
runs-on: ubuntu-latest
needs: setup-backend
needs: setup
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -75,57 +74,56 @@ jobs:
with:
node-version: "23"

# 백엔드 의존성 캐시 복원
# 의존성 캐시 복원
- name: Restore Yarn dependencies for backend
uses: actions/cache@v3
with:
path: apps/backend/node_modules
key: ${{ runner.os }}-backend-yarn-${{ hashFiles('apps/backend/yarn.lock') }}
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}

# 백엔드 린트 실행
- name: Run backend lint
working-directory: ./apps/backend
- name: Run lint
run: yarn lint
continue-on-error: true

# 백엔드 린트 경고 포스트
- name: Post backend lint warning if any
if: failure()
run: echo "⚠️ 백엔드 lint 실행 도중 경고가 발생했습니다. 확인해주세요."

frontend-lint:
run: echo "⚠️ lint 실행 도중 경고가 발생했습니다. 확인해주세요."

# frontend-lint:
# runs-on: ubuntu-latest
# needs: setup-frontend
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3

# - name: Set up Node.js
# uses: actions/setup-node@v3
# with:
# node-version: "23"

# # 프론트엔드 의존성 캐시 복원
# - name: Restore Yarn dependencies for frontend
# uses: actions/cache@v3
# with:
# path: apps/frontend/node_modules
# key: ${{ runner.os }}-frontend-yarn-${{ hashFiles('apps/frontend/yarn.lock') }}

# # 프론트엔드 린트 실행
# - name: Run frontend lint
# working-directory: ./apps/frontend
# run: yarn lint
# continue-on-error: true

# # 프론트엔드 린트 경고 포스트
# - name: Post frontend lint warning if any
# if: failure()
# run: echo "⚠️ 프론트엔드 lint 실행 도중 경고가 발생했습니다. 확인해주세요."

build:
runs-on: ubuntu-latest
needs: setup-frontend
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "23"

# 프론트엔드 의존성 캐시 복원
- name: Restore Yarn dependencies for frontend
uses: actions/cache@v3
with:
path: apps/frontend/node_modules
key: ${{ runner.os }}-frontend-yarn-${{ hashFiles('apps/frontend/yarn.lock') }}

# 프론트엔드 린트 실행
- name: Run frontend lint
working-directory: ./apps/frontend
run: yarn lint
continue-on-error: true

# 프론트엔드 린트 경고 포스트
- name: Post frontend lint warning if any
if: failure()
run: echo "⚠️ 프론트엔드 lint 실행 도중 경고가 발생했습니다. 확인해주세요."

backend-build:
runs-on: ubuntu-latest
needs: setup-backend
needs: setup
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -136,56 +134,55 @@ jobs:
node-version: "23"
# 루트 의존성 캐시 설정
- name: Cache Yarn dependencies for root
id: cache-root-deps
id: cache-deps
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-root-yarn-${{ hashFiles('yarn.lock') }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}

# 루트 의존성 설치
- name: Install root dependencies
if: steps.cache-root-deps.outputs.cache-hit != 'true'
run: yarn install

# 백엔드 의존성 캐시 복원
- name: Restore Yarn dependencies for backend
uses: actions/cache@v3
with:
path: apps/backend/node_modules
key: ${{ runner.os }}-backend-yarn-${{ hashFiles('apps/backend/yarn.lock') }}
# - name: Install root dependencies
# if: steps.cache-root-deps.outputs.cache-hit != 'true'
# run: yarn install

# 백엔드 빌드 실행
- name: Run backend build
working-directory: ./apps/backend
run: yarn build
# # 백엔드 의존성 캐시 복원
# - name: Restore Yarn dependencies for backend
# uses: actions/cache@v3
# with:
# path: apps/backend/node_modules
# key: ${{ runner.os }}-backend-yarn-${{ hashFiles('apps/backend/yarn.lock') }}

frontend-build:
runs-on: ubuntu-latest
needs: setup-frontend
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "23"

# 프론트엔드 의존성 캐시 복원
- name: Restore Yarn dependencies for frontend
uses: actions/cache@v3
with:
path: apps/frontend/node_modules
key: ${{ runner.os }}-frontend-yarn-${{ hashFiles('apps/frontend/yarn.lock') }}

# 프론트엔드 빌드 실행
- name: Run frontend build
working-directory: ./apps/frontend
# 백엔드 빌드 실행
- name: Run build
run: yarn build

backend-test:
# frontend-build:
# runs-on: ubuntu-latest
# needs: setup-frontend
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3

# - name: Set up Node.js
# uses: actions/setup-node@v3
# with:
# node-version: "23"

# # 프론트엔드 의존성 캐시 복원
# - name: Restore Yarn dependencies for frontend
# uses: actions/cache@v3
# with:
# path: apps/frontend/node_modules
# key: ${{ runner.os }}-frontend-yarn-${{ hashFiles('apps/frontend/yarn.lock') }}

# # 프론트엔드 빌드 실행
# - name: Run frontend build
# working-directory: ./apps/frontend
# run: yarn build

test:
runs-on: ubuntu-latest
needs: [setup-backend, backend-build]
needs: [setup, build]
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -195,14 +192,13 @@ jobs:
with:
node-version: "23"

# 백엔드 의존성 캐시 복원
- name: Restore Yarn dependencies for backend
# 의존성 캐시 복원
- name: Restore Yarn dependencies
uses: actions/cache@v3
with:
path: apps/backend/node_modules
key: ${{ runner.os }}-backend-yarn-${{ hashFiles('apps/backend/yarn.lock') }}
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}

# 백엔드 테스트 실행
- name: Run backend tests
working-directory: ./apps/backend
# 테스트 실행
- name: Run tests
run: yarn test
Loading

0 comments on commit 318fbe6

Please sign in to comment.