Skip to content

fix: ensure Continue button text is visible in dark mode (AlertDialog… #10

fix: ensure Continue button text is visible in dark mode (AlertDialog…

fix: ensure Continue button text is visible in dark mode (AlertDialog… #10

name: Bundle Size Analysis
on:
pull_request:
branches: [main]
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
analyze:
name: Analyze Bundle Size
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 15
env:
EXPO_PUBLIC_CAL_API_KEY: ${{ secrets.CI_EXPO_PUBLIC_CAL_API_KEY || vars.CI_EXPO_PUBLIC_CAL_API_KEY || vars.EXPO_PUBLIC_CAL_API_KEY }}
steps:
- uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.3.0
cache: true
cache-dependency-path: bun.lock
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build browser extension
run: bun run ext:build
- name: Calculate extension bundle size
id: ext_size
run: |
if [ -d ".output" ]; then
EXT_SIZE=$(du -sb .output | cut -f1)
EXT_SIZE_KB=$((EXT_SIZE / 1024))
echo "size_bytes=$EXT_SIZE" >> "$GITHUB_OUTPUT"
echo "size_kb=$EXT_SIZE_KB" >> "$GITHUB_OUTPUT"
echo "Extension bundle size: ${EXT_SIZE_KB}KB"
else
echo "size_bytes=0" >> "$GITHUB_OUTPUT"
echo "size_kb=0" >> "$GITHUB_OUTPUT"
echo "No extension output directory found"
fi
- name: Upload bundle stats
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: bundle-stats
path: .output/
retention-days: 90
- name: Download base branch stats
if: github.event_name == 'pull_request'
uses: dawidd6/action-download-artifact@v6
continue-on-error: true
with:
workflow: bundle-analysis.yml
branch: main
name: bundle-stats
path: .base-output/
id: download_base
- name: Compare bundle sizes
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const { execSync } = require('child_process');
const SIZE_INCREASE_THRESHOLD_BYTES = 5120; // 5KB — only comment if increase exceeds this
let currentSize = parseInt('${{ steps.ext_size.outputs.size_bytes }}') || 0;
let baseSize = 0;
if ('${{ steps.download_base.outcome }}' === 'success' && fs.existsSync('.base-output')) {
try {
baseSize = parseInt(execSync('du -sb .base-output').toString().split('\t')[0]) || 0;
} catch (e) {
console.log('Could not calculate base size:', e.message);
}
}
const diff = currentSize - baseSize;
if (baseSize === 0) {
console.log('No baseline found yet — skipping comment.');
return;
}
if (diff <= SIZE_INCREASE_THRESHOLD_BYTES) {
console.log(`Bundle size change (${(diff / 1024).toFixed(2)} KB) is within threshold — skipping comment.`);
return;
}
const diffKB = (diff / 1024).toFixed(2);
const currentKB = (currentSize / 1024).toFixed(2);
const baseKB = (baseSize / 1024).toFixed(2);
const pctChange = ((diff / baseSize) * 100).toFixed(2);
const emoji = diff > 51200 ? '🔴' : '🟡';
let body = `## ${emoji} Bundle Size Increase Detected\n\n`;
body += `| | Size |\n|---|---|\n`;
body += `| **Extension (current)** | ${currentKB} KB |\n`;
body += `| **Extension (main)** | ${baseKB} KB |\n`;
body += `| **Diff** | +${diffKB} KB (+${pctChange}%) |\n`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});