[Feat] 판매페이지 API 연동 #203
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PR Build Test | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| build-test: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Enable Corepack | |
| run: corepack enable | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: 'yarn' | |
| - name: Set Yarn version | |
| run: corepack prepare yarn@4.10.3 --activate | |
| - name: Generate cache key | |
| id: cache-key | |
| run: echo "value=${{ hashFiles('**/yarn.lock', '**/vite.config.ts', '**/tsconfig.json') }}" >> $GITHUB_OUTPUT | |
| - name: Cache node_modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: node_modules | |
| key: ${{ runner.os }}-yarn-${{ steps.cache-key.outputs.value }} | |
| restore-keys: | | |
| ${{ runner.os }}-yarn- | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Type check | |
| id: type-check | |
| run: yarn tsc --noEmit | |
| - name: Lint check | |
| id: lint | |
| run: | | |
| yarn lint --max-warnings 0 --format json > lint-results.json || { | |
| echo "LINT_FAILED=true" >> $GITHUB_OUTPUT | |
| exit 1 | |
| } | |
| - name: Format check | |
| id: format | |
| run: yarn format:check | |
| - name: Run tests | |
| id: test | |
| run: yarn test --run | |
| - name: Build app | |
| id: build | |
| run: yarn build | |
| - name: Build size check | |
| run: | | |
| BUILD_SIZE_KB=$(du -sk build/client | cut -f1) | |
| BUILD_SIZE_MB=$((BUILD_SIZE_KB / 1024)) | |
| echo "Build size: ${BUILD_SIZE_MB}MB" | |
| if [ $BUILD_SIZE_MB -gt 10 ]; then | |
| echo "Build size is larger than 10MB: ${BUILD_SIZE_MB}MB" | |
| echo "Consider code splitting or removing unused dependencies" | |
| elif [ $BUILD_SIZE_MB -gt 5 ]; then | |
| echo "Build size is moderate: ${BUILD_SIZE_MB}MB" | |
| else | |
| echo "Build size is optimal: ${BUILD_SIZE_MB}MB" | |
| fi | |
| - name: Upload build artifacts | |
| id: artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-test-files | |
| path: build/client/ | |
| retention-days: 1 | |
| - name: Comment build results on PR | |
| if: always() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| let comment = '## PR 검증 결과\n\n'; | |
| // TypeScript 체크 결과 | |
| const typeCheckStatus = '${{ steps.type-check.outcome }}'; | |
| if (typeCheckStatus === 'success') { | |
| comment += '✅ **TypeScript**: 통과\n'; | |
| } else { | |
| comment += '❌ **TypeScript**: 실패\n'; | |
| } | |
| // Lint 체크 결과 | |
| const lintStatus = '${{ steps.lint.outcome }}'; | |
| const lintFailed = '${{ steps.lint.outputs.LINT_FAILED }}'; | |
| if (lintFailed === 'true') { | |
| comment += '⚠️ **ESLint**: 문제 발견\n'; | |
| } else if (lintStatus === 'success') { | |
| comment += '✅ **ESLint**: 통과\n'; | |
| } else { | |
| comment += '❌ **ESLint**: 실패\n'; | |
| } | |
| // Prettier 체크 결과 | |
| const formatStatus = '${{ steps.format.outcome }}'; | |
| if (formatStatus === 'success') { | |
| comment += '✅ **Prettier**: 통과\n'; | |
| } else { | |
| comment += '❌ **Prettier**: 포맷 필요\n'; | |
| } | |
| // 테스트 결과 | |
| const testStatus = '${{ steps.test.outcome }}'; | |
| if (testStatus === 'success') { | |
| comment += '✅ **Test**: 통과\n'; | |
| } else { | |
| comment += '❌ **Test**: 실패\n'; | |
| } | |
| // 빌드 결과 | |
| const buildStatus = '${{ steps.build.outcome }}'; | |
| if (buildStatus === 'success') { | |
| comment += '✅ **Build**: 성공\n'; | |
| // 빌드 크기 정보 | |
| try { | |
| const stats = fs.statSync('build/client'); | |
| if (stats.isDirectory()) { | |
| const { execSync } = require('child_process'); | |
| const sizeKB = execSync('du -sk build/client | cut -f1', { encoding: 'utf8' }).trim(); | |
| const sizeMB = Math.round(parseInt(sizeKB) / 1024); | |
| if (sizeMB > 10) { | |
| comment += `⚠️ **Build Size**: ${sizeMB}MB (10MB 초과)\n`; | |
| } else if (sizeMB > 5) { | |
| comment += `**Build Size**: ${sizeMB}MB\n`; | |
| } else { | |
| comment += `**Build Size**: ${sizeMB}MB\n`; | |
| } | |
| } | |
| } catch (error) { | |
| comment += '**Build Size**: 측정 불가\n'; | |
| } | |
| } else { | |
| comment += '❌ **Build**: 실패\n'; | |
| } | |
| // ESLint 상세 결과 | |
| if (lintFailed === 'true') { | |
| let lintResults = []; | |
| try { | |
| const data = fs.readFileSync('lint-results.json', 'utf8'); | |
| lintResults = JSON.parse(data); | |
| } catch (error) { | |
| console.log('No lint results file found'); | |
| } | |
| let errorCount = 0; | |
| let warningCount = 0; | |
| for (const result of lintResults) { | |
| if (result.messages && result.messages.length > 0) { | |
| for (const message of result.messages) { | |
| if (message.severity === 2) errorCount++; | |
| else warningCount++; | |
| } | |
| } | |
| } | |
| if (errorCount > 0 || warningCount > 0) { | |
| comment += `\n### ESLint 상세\n`; | |
| comment += `- Errors: ${errorCount}\n`; | |
| comment += `- Warnings: ${warningCount}\n\n`; | |
| for (const result of lintResults) { | |
| if (result.messages && result.messages.length > 0) { | |
| comment += `**${result.filePath.replace(process.cwd() + '/', '')}**\n`; | |
| for (const message of result.messages.slice(0, 5)) { | |
| const severity = message.severity === 2 ? 'Error' : 'Warning'; | |
| comment += `- ${severity} (Line ${message.line}): ${message.message} \`${message.ruleId || 'unknown'}\`\n`; | |
| } | |
| if (result.messages.length > 5) { | |
| comment += `... and ${result.messages.length - 5} more issues\n`; | |
| } | |
| comment += '\n'; | |
| } | |
| } | |
| } | |
| } | |
| await github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: comment | |
| }); |