diff --git a/.github/workflows/fe-ci-storybook.yml b/.github/workflows/fe-ci-storybook.yml index 7194d6a7..e11a5dc6 100644 --- a/.github/workflows/fe-ci-storybook.yml +++ b/.github/workflows/fe-ci-storybook.yml @@ -9,62 +9,44 @@ on: paths: - 'src/frontend/packages/ui/**' - '../workflows/fe-ci-storybook.yml' + push: + branches: + - fe-refac/fe-ci + # paths: + # - 'src/frontend/packages/ui/**' concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + group: '${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}' cancel-in-progress: true jobs: changes: - if: ${{ github.actor != 'l10nbot' }} # Avoid running for 'l10nbot' + if: "${{ github.actor != 'l10nbot' }}" runs-on: ubuntu-latest - timeout-minutes: 15 - + timeout-minutes: 10 steps: - - name: Check out code + - name: Checkout Code uses: actions/checkout@v4 with: - fetch-depth: 2 + fetch-depth: 1 - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: 22 - - - uses: pnpm/action-setup@v3 - with: - version: 8 + node-version: 20 + # 캐시 옵션 제거 (pnpm 캐시는 별도로 설치 단계에서 관리) + # cache: 'pnpm' + # cache-dependency-path: 'src/frontend/pnpm-lock.yaml' - - name: Cache dependencies - uses: actions/cache/restore@v4 + - name: Setup pnpm + uses: pnpm/action-setup@v4 with: - path: | - ~/.pnpm-store - **/node_modules - src/frontend/node_modules - key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm- - - - name: Install pnpm - run: npm install -g pnpm + version: 9.12.3 - name: Install dependencies - run: | - cd src/frontend - pnpm install --strict-peer-dependencies=false --no-frozen-lockfile - pnpm add turbo --save-dev -w - - - name: CI - run: | - cd src/frontend - pnpm turbo typescript lint format build-storybook --parallel + working-directory: src/frontend + run: pnpm install --frozen-lockfile --prefer-offline - required: - needs: [changes] - if: always() - runs-on: ubuntu-latest - steps: - - name: fail if conditional jobs failed - if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped') || contains(needs.*.result, 'cancelled') - run: exit 1 + - name: Build Storybook + working-directory: src/frontend + run: pnpm turbo build-storybook --parallel diff --git a/.github/workflows/fe-ci.yml b/.github/workflows/fe-ci.yml index d1fd41f4..19bdecb3 100644 --- a/.github/workflows/fe-ci.yml +++ b/.github/workflows/fe-ci.yml @@ -8,13 +8,9 @@ on: - main paths: - 'src/frontend/**' - - '!src/frontend/packages/ui/**' - - '../workflows/fe-ci.yml' # push: # branches: - # - fe-feat/ci-storybook - # paths: - # - '!src/frontend/packages/ui/**' + # - fe-refac/fe-ci concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -22,55 +18,28 @@ concurrency: jobs: changes: - if: ${{ github.actor != 'l10nbot' }} # Avoid running for 'l10nbot' + if: ${{ github.actor != 'l10nbot' }} runs-on: ubuntu-latest - timeout-minutes: 15 - + timeout-minutes: 10 steps: - - name: Check out code + - name: Checkout Code uses: actions/checkout@v4 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 with: - fetch-depth: 2 + version: 9.12.3 - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: 22 - - - uses: pnpm/action-setup@v3 - with: - version: 8 - - - name: Cache dependencies - uses: actions/cache/restore@v4 - with: - path: | - ~/.pnpm-store - **/node_modules - src/frontend/node_modules - key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm- + node-version: 20 + cache: 'pnpm' + cache-dependency-path: 'src/frontend/pnpm-lock.yaml' - - name: Install pnpm - run: npm install -g pnpm - - - name: Install dependencies - run: | - cd src/frontend - pnpm install --strict-peer-dependencies=false --no-frozen-lockfile - pnpm add turbo --save-dev -w - - - name: CI + - name: Install, Lint, and Build + working-directory: src/frontend run: | - cd src/frontend - pnpm turbo typescript lint format build --parallel - - required: - needs: [changes] - if: always() - runs-on: ubuntu-latest - steps: - - name: fail if conditional jobs failed - if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped') || contains(needs.*.result, 'cancelled') - run: exit 1 + pnpm install --frozen-lockfile --prefer-offline + pnpm turbo lint --filter=web --filter=@workspace/ui --parallel + pnpm turbo build --filter=web --parallel diff --git a/.github/workflows/fe-save-cache-on-merge.yml b/.github/workflows/fe-save-cache-on-merge.yml new file mode 100644 index 00000000..58fb9716 --- /dev/null +++ b/.github/workflows/fe-save-cache-on-merge.yml @@ -0,0 +1,69 @@ +name: Save Cache on PR Merge + +on: + pull_request: + types: [closed] + branches: + - main + - dev + # push: + # branches: + # - fe-refac/fe-ci + +jobs: + save-cache: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Setup pnpm + uses: pnpm/action-setup@v3 + with: + version: 8 + + - name: Install dependencies + run: | + cd src/frontend + pnpm install --strict-peer-dependencies=false --no-frozen-lockfile + pnpm add turbo --save-dev -w + + - name: Build for updating .turbo cache (optional) + run: | + cd src/frontend + pnpm turbo build --parallel + + # 디렉터리 존재 여부 보장: 캐시 저장 전에 해당 경로가 없으면 생성 + - name: Ensure caching directories exist + run: | + mkdir -p ~/.pnpm-store + mkdir -p src/frontend/apps/web/.turbo + mkdir -p src/frontend/packages/ui/.turbo + + - name: Save pnpm store cache + if: always() + uses: actions/cache@v4 + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-pnpm-${{ hashFiles('src/frontend/pnpm-lock.yaml') }} + + - name: Save Turborepo cache for web app + if: always() + uses: actions/cache@v4 + with: + path: src/frontend/apps/web/.turbo + key: ${{ runner.os }}-turbo-web-${{ hashFiles('src/frontend/pnpm-lock.yaml') }} + + - name: Save Turborepo cache for ui package + if: always() + uses: actions/cache@v4 + with: + path: src/frontend/packages/ui/.turbo + key: ${{ runner.os }}-turbo-ui-${{ hashFiles('src/frontend/pnpm-lock.yaml') }} diff --git a/src/frontend/turbo.json b/src/frontend/turbo.json index f6e651bb..e70772d3 100644 --- a/src/frontend/turbo.json +++ b/src/frontend/turbo.json @@ -19,28 +19,30 @@ "tasks": { "build": { "dependsOn": ["^build"], - "inputs": ["$TURBO_DEFAULT$", ".env*"], - "outputs": [".next/**"] + "inputs": ["$TURBO_DEFAULT$"], + "outputs": ["./apps/web/.next/**"], + "cache": true, + "persistent": true }, "build-storybook": { "dependsOn": ["^build-storybook"], - "inputs": ["$TURBO_DEFAULT$", ".env*"], - "outputs": ["storybook-static/**"], + "inputs": ["$TURBO_DEFAULT$"], + "outputs": ["./packages/ui/storybook-static/**"], "cache": true, "persistent": false }, "storybook": { "dependsOn": ["^storybook"], - "inputs": ["$TURBO_DEFAULT$", ".env*"], - "outputs": ["storybook-static/**"], + "inputs": ["$TURBO_DEFAULT$"], + "outputs": ["./packages/ui/storybook-static/**"], "cache": true, "persistent": false }, "lint": { "dependsOn": ["^lint"], "inputs": ["$TURBO_DEFAULT$", "**/*.{js,ts,jsx,tsx}"], - "cache": false, - "persistent": false + "cache": true, + "persistent": true }, "dev": { "cache": false,