also looking at this
chore(deps): update dependency actions/cache to v5.0.3
#413
2 files
+60
-5
| @@ -0,0 +1,40 @@ | ||
| 1 | name: Bundle Size Check | |
| 2 | ||
| 3 | on: | |
| 4 | pull_request: | |
| 5 | paths: | |
| 6 | - 'packages/ts-tokens/src/**' | |
| 7 | - 'packages/react/src/**' | |
| 8 | - 'packages/vue/src/**' | |
| 9 | ||
| 10 | jobs: | |
| 11 | bundle-size: | |
| 12 | runs-on: ubuntu-latest | |
| 13 | steps: | |
| 14 | - uses: actions/checkout@v4 | |
| 15 | - uses: oven-sh/setup-bun@v2 | |
| 16 | - uses: actions/cache@v5.0.3 | |
| 17 | with: | |
| 18 | path: node_modules | |
| 19 | key: node-modules-${{ hashFiles('**/bun.lock') }} | |
| 20 | - run: bun install | |
| 21 | - run: bun run build | |
| 22 | working-directory: packages/ts-tokens | |
| 23 | - name: Check bundle size | |
| 24 | run: | | |
| 25 | node -e " | |
| 26 | const { analyzeBundleSize, checkBundleBudget } = require('./packages/ts-tokens/dist/utils/bundle-optimizer.js'); | |
| 27 | analyzeBundleSize('./packages/ts-tokens/dist').then(report => { | |
| 28 | console.log('Bundle Size Report:'); | |
| 29 | console.log('Total:', (report.totalSizeBytes / 1024).toFixed(1), 'KB'); | |
| 30 | console.log('Gzip:', (report.totalGzipBytes / 1024).toFixed(1), 'KB'); | |
| 31 | report.entries.sort((a,b) => b.sizeBytes - a.sizeBytes).slice(0,10).forEach(e => { | |
| 32 | console.log(' ' + e.name + ': ' + (e.sizeBytes / 1024).toFixed(1) + ' KB'); | |
| 33 | }); | |
| 34 | const result = checkBundleBudget(report, { maxTotalBytes: 5 * 1024 * 1024 }); | |
| 35 | if (!result.passed) { | |
| 36 | console.error('Budget violations:', result.violations); | |
| 37 | process.exit(1); | |
| 38 | } | |
| 39 | }); | |
| 40 | " | |
| @@ -24,7 +24,7 @@ jobs: | ||
| 24 | 24 | uses: oven-sh/setup-bun@v2 |
| 25 | 25 | |
| 26 | 26 | - name: Use cached node_modules |
| 27 | uses: actions/cache@v4 | |
| 27 | uses: actions/cache@v5.0.3 | |
| 28 | 28 | with: |
| 29 | 29 | path: node_modules |
| 30 | 30 | key: node-modules-${{ hashFiles('**/bun.lock') }} |
| @@ -47,7 +47,7 @@ jobs: | ||
| 47 | 47 | uses: oven-sh/setup-bun@v2 |
| 48 | 48 | |
| 49 | 49 | - name: Use cached node_modules |
| 50 | uses: actions/cache@v4 | |
| 50 | uses: actions/cache@v5.0.3 | |
| 51 | 51 | with: |
| 52 | 52 | path: node_modules |
| 53 | 53 | key: node-modules-${{ hashFiles('**/bun.lock') }} |
| @@ -70,7 +70,7 @@ jobs: | ||
| 70 | 70 | uses: oven-sh/setup-bun@v2 |
| 71 | 71 | |
| 72 | 72 | - name: Use cached node_modules |
| 73 | uses: actions/cache@v4 | |
| 73 | uses: actions/cache@v5.0.3 | |
| 74 | 74 | with: |
| 75 | 75 | path: node_modules |
| 76 | 76 | key: node-modules-${{ hashFiles('**/bun.lock') }} |
| @@ -81,7 +81,22 @@ jobs: | ||
| 81 | 81 | run: bun install |
| 82 | 82 | |
| 83 | 83 | - name: Unit Test |
| 84 | run: bun test | |
| 84 | run: bun test --coverage 2>&1 | tee coverage-output.txt | |
| 85 | ||
| 86 | - name: Check Coverage Threshold | |
| 87 | run: | | |
| 88 | if grep -q "All files" coverage-output.txt; then | |
| 89 | LINE_COV=$(grep "All files" coverage-output.txt | awk '{print $4}' | tr -d '%') | |
| 90 | echo "Line coverage: ${LINE_COV}%" | |
| 91 | THRESHOLD=50 | |
| 92 | if [ "$(echo "${LINE_COV} < ${THRESHOLD}" | bc -l)" -eq 1 ]; then | |
| 93 | echo "::error::Line coverage ${LINE_COV}% is below threshold ${THRESHOLD}%" | |
| 94 | exit 1 | |
| 95 | fi | |
| 96 | echo "Coverage ${LINE_COV}% meets threshold ${THRESHOLD}%" | |
| 97 | else | |
| 98 | echo "Coverage report not found — skipping threshold check" | |
| 99 | fi | |
| 85 | 100 | |
| 86 | 101 | publish-commit: |
| 87 | 102 | runs-on: ubuntu-latest |
| @@ -93,7 +108,7 @@ jobs: | ||
| 93 | 108 | uses: oven-sh/setup-bun@v2 |
| 94 | 109 | |
| 95 | 110 | - name: Use cached node_modules |
| 96 | uses: actions/cache@v4 | |
| 111 | uses: actions/cache@v5.0.3 | |
| 97 | 112 | with: |
| 98 | 113 | path: node_modules |
| 99 | 114 | key: node-modules-${{ hashFiles('**/bun.lock') }} |