diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6eae6a8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,94 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + # Job 1: Build & Type Check + build: + name: Build & Type Check + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Type check & Build + run: npm run build + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: dist + path: dist/ + retention-days: 7 + + # Job 2: Lint + lint: + name: Lint + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Run ESLint + run: npm run lint + + # Job 3: Bundle Size Check + bundle-size: + name: Bundle Size Check + runs-on: ubuntu-latest + needs: build + timeout-minutes: 10 + + steps: + - name: Download build artifact + uses: actions/download-artifact@v4 + with: + name: dist + path: dist/ + + - name: Check bundle size + env: + BUNDLE_SIZE_THRESHOLD: 500 + run: | + BUNDLE_SIZE_BYTES=$(find dist -type f -printf '%s\n' | awk '{sum += $1} END {print sum + 0}') + BUNDLE_SIZE_KB=$(( (BUNDLE_SIZE_BYTES + 1023) / 1024 )) + THRESHOLD_BYTES=$(( BUNDLE_SIZE_THRESHOLD * 1024 )) + echo "Bundle size: ${BUNDLE_SIZE_KB}KB (${BUNDLE_SIZE_BYTES} bytes)" + if [ "$BUNDLE_SIZE_BYTES" -gt "$THRESHOLD_BYTES" ]; then + echo "::warning::Bundle size ${BUNDLE_SIZE_KB}KB exceeds ${BUNDLE_SIZE_THRESHOLD}KB threshold." + else + echo "✅ Bundle size ${BUNDLE_SIZE_KB}KB is within threshold" + fi