From 3cfcd0cd786b77ba519b60ffe4e4c34750502105 Mon Sep 17 00:00:00 2001 From: Ritikydv1 Date: Sat, 7 Mar 2026 17:38:35 +0530 Subject: [PATCH 1/3] ci: add build, lint and bundle size check workflow --- .github/workflows/ci.yml | 82 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..579b81c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,82 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + # Job 1: Build & Type Check + build: + name: Build & Type Check + runs-on: ubuntu-latest + + 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 + + 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 + + steps: + - name: Download build artifact + uses: actions/download-artifact@v4 + with: + name: dist + path: dist/ + + - name: Check bundle size + run: | + BUNDLE_SIZE=$(du -sk dist/ | cut -f1) + echo "Bundle size: ${BUNDLE_SIZE}KB" + # Warn if bundle exceeds 500KB (keeping it lean per project constraints) + if [ "$BUNDLE_SIZE" -gt 500 ]; then + echo "⚠️ Warning: Bundle size ${BUNDLE_SIZE}KB exceeds 500KB threshold" + echo "Consider lazy loading or removing unused dependencies" + else + echo "✅ Bundle size ${BUNDLE_SIZE}KB is within threshold" + fi From 4eacebc16d26fa75e9a1625c856d25ed57731160 Mon Sep 17 00:00:00 2001 From: Ritikydv1 Date: Sat, 7 Mar 2026 18:41:02 +0530 Subject: [PATCH 2/3] ci: add concurrency control,job timeouts and GitHub annotations --- .github/workflows/ci.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 579b81c..8d79fed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,11 +6,16 @@ on: pull_request: branches: [main] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: # Job 1: Build & Type Check build: name: Build & Type Check runs-on: ubuntu-latest + timeout-minutes: 10 steps: - name: Checkout code @@ -39,6 +44,7 @@ jobs: lint: name: Lint runs-on: ubuntu-latest + timeout-minutes: 10 steps: - name: Checkout code @@ -61,6 +67,7 @@ jobs: name: Bundle Size Check runs-on: ubuntu-latest needs: build + timeout-minutes: 10 steps: - name: Download build artifact @@ -70,13 +77,13 @@ jobs: path: dist/ - name: Check bundle size + env: + BUNDLE_SIZE_THRESHOLD: 500 run: | BUNDLE_SIZE=$(du -sk dist/ | cut -f1) echo "Bundle size: ${BUNDLE_SIZE}KB" - # Warn if bundle exceeds 500KB (keeping it lean per project constraints) - if [ "$BUNDLE_SIZE" -gt 500 ]; then - echo "⚠️ Warning: Bundle size ${BUNDLE_SIZE}KB exceeds 500KB threshold" - echo "Consider lazy loading or removing unused dependencies" + if [ "$BUNDLE_SIZE" -gt "$BUNDLE_SIZE_THRESHOLD" ]; then + echo "::warning::Bundle size ${BUNDLE_SIZE}KB exceeds ${BUNDLE_SIZE_THRESHOLD}KB threshold." else echo "✅ Bundle size ${BUNDLE_SIZE}KB is within threshold" fi From ebb925b2191b5e952d1c5f8358e12e047c64d198 Mon Sep 17 00:00:00 2001 From: Ritikydv1 Date: Sat, 7 Mar 2026 18:56:18 +0530 Subject: [PATCH 3/3] ci: fix bundle size measurement and add permissions block --- .github/workflows/ci.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d79fed..6eae6a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +permissions: + contents: read + jobs: # Job 1: Build & Type Check build: @@ -80,10 +83,12 @@ jobs: env: BUNDLE_SIZE_THRESHOLD: 500 run: | - BUNDLE_SIZE=$(du -sk dist/ | cut -f1) - echo "Bundle size: ${BUNDLE_SIZE}KB" - if [ "$BUNDLE_SIZE" -gt "$BUNDLE_SIZE_THRESHOLD" ]; then - echo "::warning::Bundle size ${BUNDLE_SIZE}KB exceeds ${BUNDLE_SIZE_THRESHOLD}KB threshold." + 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 is within threshold" + echo "✅ Bundle size ${BUNDLE_SIZE_KB}KB is within threshold" fi