From 0ee2bd0b682624878e49008f6a411c417d40ba81 Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Wed, 10 Sep 2025 16:21:24 +0800 Subject: [PATCH 01/13] fix compressed-diff workflow --- .github/workflows/compressed-diff.yml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/compressed-diff.yml b/.github/workflows/compressed-diff.yml index 8d57cec4c5..921c276864 100644 --- a/.github/workflows/compressed-diff.yml +++ b/.github/workflows/compressed-diff.yml @@ -9,20 +9,22 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/checkout@v2 # Checkout the Stackable Premium repo. + - uses: actions/checkout@v4 + - uses: actions/checkout@v4 # Checkout the Stackable Premium repo. with: repository: 'bfintal/Stackable-Premium' ref: 'v3' path: 'pro__premium_only' token: '${{ secrets.ACCESS_KEY }}' - - name: Install Composer Dependencies - run: | - composer install --prefer-dist --no-progress --ignore-platform-reqs - - name: Setup Node # Fix because we can't do npm ci --legacy-peer-deps - uses: actions/setup-node@v1 + - name: Setup Node + uses: actions/setup-node@v3 with: - node-version: 14.x + node-version: 18.x + cache: 'npm' + - name: Install Dependencies + run: | + npm install + cd pro__premium_only && npm install - uses: preactjs/compressed-size-action@v2 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" From b22aecd69cbac38c4b78d108efaa2e7dac359144 Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Wed, 10 Sep 2025 16:29:06 +0800 Subject: [PATCH 02/13] try adding legacy peer deps --- .github/workflows/compressed-diff.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compressed-diff.yml b/.github/workflows/compressed-diff.yml index 921c276864..0249d08c9f 100644 --- a/.github/workflows/compressed-diff.yml +++ b/.github/workflows/compressed-diff.yml @@ -23,8 +23,9 @@ jobs: cache: 'npm' - name: Install Dependencies run: | - npm install - cd pro__premium_only && npm install + npm ci --legacy-peer-deps + cd pro__premium_only + npm ci --legacy-peer-deps - uses: preactjs/compressed-size-action@v2 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" From 09ee9267e923ce847dbe502464db1ba97a76f58a Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Wed, 10 Sep 2025 16:36:05 +0800 Subject: [PATCH 03/13] try doing build:no-translate --- .github/workflows/compressed-diff.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/compressed-diff.yml b/.github/workflows/compressed-diff.yml index 0249d08c9f..fc6d4e7080 100644 --- a/.github/workflows/compressed-diff.yml +++ b/.github/workflows/compressed-diff.yml @@ -23,12 +23,14 @@ jobs: cache: 'npm' - name: Install Dependencies run: | - npm ci --legacy-peer-deps + npm ci cd pro__premium_only - npm ci --legacy-peer-deps + npm ci + - name: Build Project + run: | + npm run build:no-translate - uses: preactjs/compressed-size-action@v2 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" - clean-script: "clean" pattern: "./build/stackable/**" exclude: "{**/*.map,**/node_modules/**}" From 8a4bb868f7859340a7b67e8539b10593114c2342 Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Wed, 10 Sep 2025 16:39:41 +0800 Subject: [PATCH 04/13] try removing premium --- .github/workflows/compressed-diff.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/compressed-diff.yml b/.github/workflows/compressed-diff.yml index fc6d4e7080..e21c8eefbf 100644 --- a/.github/workflows/compressed-diff.yml +++ b/.github/workflows/compressed-diff.yml @@ -24,8 +24,6 @@ jobs: - name: Install Dependencies run: | npm ci - cd pro__premium_only - npm ci - name: Build Project run: | npm run build:no-translate From 578558d75bf595105ea992e795bc64277dcd9a69 Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Wed, 10 Sep 2025 16:45:16 +0800 Subject: [PATCH 05/13] try using pre-built files --- .github/workflows/compressed-diff.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/compressed-diff.yml b/.github/workflows/compressed-diff.yml index e21c8eefbf..152415acc4 100644 --- a/.github/workflows/compressed-diff.yml +++ b/.github/workflows/compressed-diff.yml @@ -30,5 +30,6 @@ jobs: - uses: preactjs/compressed-size-action@v2 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" + build-script: "echo 'Using pre-built files'" pattern: "./build/stackable/**" exclude: "{**/*.map,**/node_modules/**}" From cd83e6291a22c61e63e96a2d5af003e5aa06c51f Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Wed, 10 Sep 2025 16:49:28 +0800 Subject: [PATCH 06/13] try build true --- .github/workflows/compressed-diff.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compressed-diff.yml b/.github/workflows/compressed-diff.yml index 152415acc4..26c4c2534f 100644 --- a/.github/workflows/compressed-diff.yml +++ b/.github/workflows/compressed-diff.yml @@ -30,6 +30,6 @@ jobs: - uses: preactjs/compressed-size-action@v2 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" - build-script: "echo 'Using pre-built files'" + build-script: "true" pattern: "./build/stackable/**" exclude: "{**/*.map,**/node_modules/**}" From 1a6704d87b13adaa49db21a599953b13feb0e85e Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Wed, 10 Sep 2025 16:56:40 +0800 Subject: [PATCH 07/13] try different approach --- .github/workflows/compressed-diff.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/compressed-diff.yml b/.github/workflows/compressed-diff.yml index 26c4c2534f..fd48e4e16e 100644 --- a/.github/workflows/compressed-diff.yml +++ b/.github/workflows/compressed-diff.yml @@ -16,20 +16,27 @@ jobs: ref: 'v3' path: 'pro__premium_only' token: '${{ secrets.ACCESS_KEY }}' + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' - name: Setup Node uses: actions/setup-node@v3 with: node-version: 18.x cache: 'npm' - - name: Install Dependencies + - name: Install Build Tools run: | - npm ci - - name: Build Project + sudo apt-get update + sudo apt-get install -y build-essential + - name: Install Dependencies run: | - npm run build:no-translate + npm ci --legacy-peer-deps + cd pro__premium_only + npm ci --legacy-peer-deps - uses: preactjs/compressed-size-action@v2 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" - build-script: "true" + clean-script: "clean" pattern: "./build/stackable/**" exclude: "{**/*.map,**/node_modules/**}" From efb30526ae6e5fbb60e044167b95a21d62d7b16a Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Wed, 10 Sep 2025 17:13:32 +0800 Subject: [PATCH 08/13] try new size comparison --- .github/workflows/build-size-comparison.yml | 107 ++++++++++++++++++++ .github/workflows/compressed-diff.yml | 42 -------- 2 files changed, 107 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/build-size-comparison.yml delete mode 100644 .github/workflows/compressed-diff.yml diff --git a/.github/workflows/build-size-comparison.yml b/.github/workflows/build-size-comparison.yml new file mode 100644 index 0000000000..cc709a34d6 --- /dev/null +++ b/.github/workflows/build-size-comparison.yml @@ -0,0 +1,107 @@ +name: Build Size Comparison + +on: + pull_request: + branches: [ master, develop ] + +jobs: + build-and-compare: + runs-on: ubuntu-latest + + steps: + - name: Checkout current PR + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Checkout base branch + uses: actions/checkout@v4 + with: + ref: ${{ github.base_ref }} + path: base-branch + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 14.x + cache: 'npm' + + - name: Install Dependencies (Current PR) + run: | + npm ci --legacy-peer-deps + cd pro__premium_only + npm ci --legacy-peer-deps + + - name: Install Dependencies (Base Branch) + run: | + cd base-branch + npm ci --legacy-peer-deps + cd pro__premium_only + npm ci --legacy-peer-deps + + - name: Build Current PR + run: | + npm run build:no-translate + + - name: Build Base Branch + run: | + cd base-branch + npm run build:no-translate + + - name: Create Zip Files + run: | + # Create zip for current PR + cd build/stackable + zip -r ../../current-build.zip . -x "*.map" "node_modules/*" + + # Create zip for base branch + cd ../../base-branch/build/stackable + zip -r ../../base-build.zip . -x "*.map" "node_modules/*" + + - name: Compare Build Sizes + run: | + echo "## 📦 Build Size Comparison" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + + # Get file sizes + CURRENT_SIZE=$(du -h current-build.zip | cut -f1) + BASE_SIZE=$(du -h base-build.zip | cut -f1) + + # Get exact byte sizes for calculation + CURRENT_BYTES=$(stat -c%s current-build.zip) + BASE_BYTES=$(stat -c%s base-build.zip) + + # Calculate difference + DIFF_BYTES=$((CURRENT_BYTES - BASE_BYTES)) + DIFF_PERCENT=$((DIFF_BYTES * 100 / BASE_BYTES)) + + echo "| Build | Size |" >> $GITHUB_STEP_SUMMARY + echo "|-------|------|" >> $GITHUB_STEP_SUMMARY + echo "| **Current PR** | **$CURRENT_SIZE** |" >> $GITHUB_STEP_SUMMARY + echo "| Base Branch | $BASE_SIZE |" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + + if [ $DIFF_BYTES -gt 0 ]; then + echo "📈 **Size increased by** $(numfmt --to=iec $DIFF_BYTES) (+$DIFF_PERCENT%)" >> $GITHUB_STEP_SUMMARY + elif [ $DIFF_BYTES -lt 0 ]; then + echo "📉 **Size decreased by** $(numfmt --to=iec $((DIFF_BYTES * -1))) (-$((DIFF_PERCENT * -1))%)" >> $GITHUB_STEP_SUMMARY + else + echo "✅ **No size change**" >> $GITHUB_STEP_SUMMARY + fi + + echo "" >> $GITHUB_STEP_SUMMARY + echo "### 📁 Build Contents" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Current PR build contents:**" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + unzip -l current-build.zip | head -20 >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + + - name: Upload Build Artifacts + uses: actions/upload-artifact@v4 + with: + name: build-comparison + path: | + current-build.zip + base-build.zip + retention-days: 7 diff --git a/.github/workflows/compressed-diff.yml b/.github/workflows/compressed-diff.yml deleted file mode 100644 index fd48e4e16e..0000000000 --- a/.github/workflows/compressed-diff.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Compressed Size - -on: - pull_request: - branches: [ master, develop ] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - uses: actions/checkout@v4 # Checkout the Stackable Premium repo. - with: - repository: 'bfintal/Stackable-Premium' - ref: 'v3' - path: 'pro__premium_only' - token: '${{ secrets.ACCESS_KEY }}' - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.9' - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 18.x - cache: 'npm' - - name: Install Build Tools - run: | - sudo apt-get update - sudo apt-get install -y build-essential - - name: Install Dependencies - run: | - npm ci --legacy-peer-deps - cd pro__premium_only - npm ci --legacy-peer-deps - - uses: preactjs/compressed-size-action@v2 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" - clean-script: "clean" - pattern: "./build/stackable/**" - exclude: "{**/*.map,**/node_modules/**}" From a740f0ecbf72f2bbd7a31b98aa70d7f1e428db84 Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Wed, 10 Sep 2025 17:20:00 +0800 Subject: [PATCH 09/13] try checkout --- .github/workflows/build-size-comparison.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-size-comparison.yml b/.github/workflows/build-size-comparison.yml index cc709a34d6..f2db28c711 100644 --- a/.github/workflows/build-size-comparison.yml +++ b/.github/workflows/build-size-comparison.yml @@ -20,6 +20,22 @@ jobs: ref: ${{ github.base_ref }} path: base-branch + - name: Checkout Premium Repo (Current PR) + uses: actions/checkout@v4 + with: + repository: 'bfintal/Stackable-Premium' + ref: 'v3' + path: 'pro__premium_only' + token: '${{ secrets.ACCESS_KEY }}' + + - name: Checkout Premium Repo (Base Branch) + uses: actions/checkout@v4 + with: + repository: 'bfintal/Stackable-Premium' + ref: 'v3' + path: 'base-branch/pro__premium_only' + token: '${{ secrets.ACCESS_KEY }}' + - name: Setup Node uses: actions/setup-node@v3 with: @@ -104,4 +120,4 @@ jobs: path: | current-build.zip base-build.zip - retention-days: 7 + retention-days: 7 \ No newline at end of file From 71acb10c008cba4b03c510f046439030c34f637e Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Wed, 10 Sep 2025 17:29:01 +0800 Subject: [PATCH 10/13] try another path --- .github/workflows/build-size-comparison.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-size-comparison.yml b/.github/workflows/build-size-comparison.yml index f2db28c711..6579c1166b 100644 --- a/.github/workflows/build-size-comparison.yml +++ b/.github/workflows/build-size-comparison.yml @@ -72,13 +72,28 @@ jobs: # Create zip for base branch cd ../../base-branch/build/stackable - zip -r ../../base-build.zip . -x "*.map" "node_modules/*" + zip -r ../../../base-build.zip . -x "*.map" "node_modules/*" + + # Move zip files to root directory for easier access + cd ../../../ + ls -la *.zip - name: Compare Build Sizes run: | echo "## 📦 Build Size Comparison" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY + # Check if files exist + if [ ! -f "current-build.zip" ]; then + echo "❌ **Error**: current-build.zip not found" >> $GITHUB_STEP_SUMMARY + exit 1 + fi + + if [ ! -f "base-build.zip" ]; then + echo "❌ **Error**: base-build.zip not found" >> $GITHUB_STEP_SUMMARY + exit 1 + fi + # Get file sizes CURRENT_SIZE=$(du -h current-build.zip | cut -f1) BASE_SIZE=$(du -h base-build.zip | cut -f1) From 9b93e2d955804238c5f5f852dcff48be52a0cc44 Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Wed, 10 Sep 2025 17:43:53 +0800 Subject: [PATCH 11/13] added comparisons --- .github/workflows/build-size-comparison.yml | 311 +++++++++++++++++--- 1 file changed, 263 insertions(+), 48 deletions(-) diff --git a/.github/workflows/build-size-comparison.yml b/.github/workflows/build-size-comparison.yml index 6579c1166b..5483f9d1af 100644 --- a/.github/workflows/build-size-comparison.yml +++ b/.github/workflows/build-size-comparison.yml @@ -78,55 +78,270 @@ jobs: cd ../../../ ls -la *.zip - - name: Compare Build Sizes + - name: Extract and Compare Files run: | - echo "## 📦 Build Size Comparison" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - - # Check if files exist - if [ ! -f "current-build.zip" ]; then - echo "❌ **Error**: current-build.zip not found" >> $GITHUB_STEP_SUMMARY - exit 1 - fi - - if [ ! -f "base-build.zip" ]; then - echo "❌ **Error**: base-build.zip not found" >> $GITHUB_STEP_SUMMARY - exit 1 - fi - - # Get file sizes - CURRENT_SIZE=$(du -h current-build.zip | cut -f1) - BASE_SIZE=$(du -h base-build.zip | cut -f1) - - # Get exact byte sizes for calculation - CURRENT_BYTES=$(stat -c%s current-build.zip) - BASE_BYTES=$(stat -c%s base-build.zip) - - # Calculate difference - DIFF_BYTES=$((CURRENT_BYTES - BASE_BYTES)) - DIFF_PERCENT=$((DIFF_BYTES * 100 / BASE_BYTES)) - - echo "| Build | Size |" >> $GITHUB_STEP_SUMMARY - echo "|-------|------|" >> $GITHUB_STEP_SUMMARY - echo "| **Current PR** | **$CURRENT_SIZE** |" >> $GITHUB_STEP_SUMMARY - echo "| Base Branch | $BASE_SIZE |" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - - if [ $DIFF_BYTES -gt 0 ]; then - echo "📈 **Size increased by** $(numfmt --to=iec $DIFF_BYTES) (+$DIFF_PERCENT%)" >> $GITHUB_STEP_SUMMARY - elif [ $DIFF_BYTES -lt 0 ]; then - echo "📉 **Size decreased by** $(numfmt --to=iec $((DIFF_BYTES * -1))) (-$((DIFF_PERCENT * -1))%)" >> $GITHUB_STEP_SUMMARY - else - echo "✅ **No size change**" >> $GITHUB_STEP_SUMMARY - fi - - echo "" >> $GITHUB_STEP_SUMMARY - echo "### 📁 Build Contents" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "**Current PR build contents:**" >> $GITHUB_STEP_SUMMARY - echo '```' >> $GITHUB_STEP_SUMMARY - unzip -l current-build.zip | head -20 >> $GITHUB_STEP_SUMMARY - echo '```' >> $GITHUB_STEP_SUMMARY + # Extract both zip files + mkdir -p current-files base-files + unzip -q current-build.zip -d current-files/ + unzip -q base-build.zip -d base-files/ + + # Create comparison script + cat > compare_files.py << 'EOF' + import os + import json + from pathlib import Path + + def get_file_size(filepath): + if os.path.exists(filepath): + return os.path.getsize(filepath) + return 0 + + def format_bytes(bytes): + for unit in ['B', 'KB', 'MB', 'GB']: + if bytes < 1024.0: + return f"{bytes:.1f}{unit}" + bytes /= 1024.0 + return f"{bytes:.1f}TB" + + def compare_directories(current_dir, base_dir): + current_path = Path(current_dir) + base_path = Path(base_dir) + + all_files = set() + + # Get all files from both directories + for file_path in current_path.rglob('*'): + if file_path.is_file(): + rel_path = file_path.relative_to(current_path) + all_files.add(str(rel_path)) + + for file_path in base_path.rglob('*'): + if file_path.is_file(): + rel_path = file_path.relative_to(base_path) + all_files.add(str(rel_path)) + + changes = [] + total_current = 0 + total_base = 0 + + for file_path in sorted(all_files): + current_file = current_path / file_path + base_file = base_path / file_path + + current_size = get_file_size(current_file) + base_size = get_file_size(base_file) + + total_current += current_size + total_base += base_size + + if current_size != base_size: + diff = current_size - base_size + if base_size > 0: + percent = (diff / base_size) * 100 + else: + percent = 100 if current_size > 0 else 0 + + status = "🆕" if base_size == 0 else "❌" if current_size == 0 else "📝" + + changes.append({ + 'file': file_path, + 'current_size': current_size, + 'base_size': base_size, + 'diff': diff, + 'percent': percent, + 'status': status + }) + + return changes, total_current, total_base + + # Compare files + changes, total_current, total_base = compare_directories('current-files', 'base-files') + + # Create summary + total_diff = total_current - total_base + total_percent = (total_diff / total_base * 100) if total_base > 0 else 0 + + # Flag large changes (>10% or >100KB) + flagged_changes = [c for c in changes if abs(c['percent']) > 10 or abs(c['diff']) > 102400] + + # Generate report + report = { + 'total_current': total_current, + 'total_base': total_base, + 'total_diff': total_diff, + 'total_percent': total_percent, + 'changes': changes, + 'flagged_changes': flagged_changes + } + + with open('comparison_report.json', 'w') as f: + json.dump(report, f, indent=2) + + # Print summary to console + print(f"Total size change: {format_bytes(total_diff)} ({total_percent:+.1f}%)") + print(f"Files changed: {len(changes)}") + print(f"Flagged changes: {len(flagged_changes)}") + EOF + + python3 compare_files.py + + - name: Generate PR Comment + id: pr_comment + run: | + # Read the comparison report + python3 -c " + import json + with open('comparison_report.json', 'r') as f: + report = json.load(f) + + def format_bytes(bytes): + for unit in ['B', 'KB', 'MB', 'GB']: + if bytes < 1024.0: + return f'{bytes:.1f}{unit}' + bytes /= 1024.0 + return f'{bytes:.1f}TB' + + # Generate comment + comment = '## 📦 Build Size Comparison\n\n' + + # Overall summary + total_current = report['total_current'] + total_base = report['total_base'] + total_diff = report['total_diff'] + total_percent = report['total_percent'] + + comment += '| Build | Size |\n' + comment += '|-------|------|\n' + comment += f'| **Current PR** | **{format_bytes(total_current)}** |\n' + comment += f'| Base Branch | {format_bytes(total_base)} |\n\n' + + if total_diff > 0: + comment += f'📈 **Total size increased by** {format_bytes(total_diff)} (+{total_percent:.1f}%)\n\n' + elif total_diff < 0: + comment += f'📉 **Total size decreased by** {format_bytes(abs(total_diff))} ({total_percent:.1f}%)\n\n' + else: + comment += '✅ **No total size change**\n\n' + + # File changes summary + changes = report['changes'] + flagged = report['flagged_changes'] + + comment += f'**Files changed:** {len(changes)}\n' + comment += f'**Large changes flagged:** {len(flagged)}\n\n' + + if flagged: + comment += '## ⚠️ Large Changes (Requires Review)\n\n' + comment += '| File | Current | Base | Change | % | Status |\n' + comment += '|------|---------|------|--------|---|--------|\n' + + for change in flagged: + status_icon = change['status'] + file_name = change['file'] + current_size = format_bytes(change['current_size']) + base_size = format_bytes(change['base_size']) + diff_size = format_bytes(abs(change['diff'])) + percent = change['percent'] + + if change['diff'] > 0: + change_str = f'+{diff_size}' + elif change['diff'] < 0: + change_str = f'-{diff_size}' + else: + change_str = '0B' + + comment += f'| `{file_name}` | {current_size} | {base_size} | {change_str} | {percent:+.1f}% | {status_icon} |\n' + + comment += '\n' + + # All changes table (if not too many) + if len(changes) <= 50: + comment += '## 📋 All File Changes\n\n' + comment += '| File | Current | Base | Change | % | Status |\n' + comment += '|------|---------|------|--------|---|--------|\n' + + for change in changes: + status_icon = change['status'] + file_name = change['file'] + current_size = format_bytes(change['current_size']) + base_size = format_bytes(change['base_size']) + diff_size = format_bytes(abs(change['diff'])) + percent = change['percent'] + + if change['diff'] > 0: + change_str = f'+{diff_size}' + elif change['diff'] < 0: + change_str = f'-{diff_size}' + else: + change_str = '0B' + + comment += f'| `{file_name}` | {current_size} | {base_size} | {change_str} | {percent:+.1f}% | {status_icon} |\n' + else: + comment += f'## 📋 File Changes (showing first 50 of {len(changes)})\n\n' + comment += '| File | Current | Base | Change | % | Status |\n' + comment += '|------|---------|------|--------|---|--------|\n' + + for change in changes[:50]: + status_icon = change['status'] + file_name = change['file'] + current_size = format_bytes(change['current_size']) + base_size = format_bytes(change['base_size']) + diff_size = format_bytes(abs(change['diff'])) + percent = change['percent'] + + if change['diff'] > 0: + change_str = f'+{diff_size}' + elif change['diff'] < 0: + change_str = f'-{diff_size}' + else: + change_str = '0B' + + comment += f'| `{file_name}` | {current_size} | {base_size} | {change_str} | {percent:+.1f}% | {status_icon} |\n' + + # Save comment to file + with open('pr_comment.md', 'w') as f: + f.write(comment) + + print('PR comment generated') + " + + - name: Post/Update PR Comment + uses: actions/github-script@v7 + with: + script: | + const fs = require('fs'); + const comment = fs.readFileSync('pr_comment.md', 'utf8'); + + // Find existing comment + const { data: comments } = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }); + + const existingComment = comments.find(comment => + comment.user.type === 'Bot' && + comment.body.includes('📦 Build Size Comparison') + ); + + if (existingComment) { + // Update existing comment + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: existingComment.id, + body: comment + }); + console.log('Updated existing PR comment'); + } else { + // Create new comment + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: comment + }); + console.log('Created new PR comment'); + } - name: Upload Build Artifacts uses: actions/upload-artifact@v4 From 061a4e932dc4e013f23732eb94bb5eee5581b58b Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Wed, 10 Sep 2025 17:51:48 +0800 Subject: [PATCH 12/13] test changes --- plugin.php | 1 + src/disabled-blocks.js | 1 + 2 files changed, 2 insertions(+) diff --git a/plugin.php b/plugin.php index 1fad10a379..ff3dcff28e 100644 --- a/plugin.php +++ b/plugin.php @@ -349,3 +349,4 @@ function is_frontend() { require_once( plugin_dir_path( __FILE__ ) . 'src/deprecated/v2/design-library/init.php' ); require_once( plugin_dir_path( __FILE__ ) . 'src/deprecated/v2/optimization-settings.php' ); require_once( plugin_dir_path( __FILE__ ) . 'src/deprecated/v2/global-settings.php' ); +error_log('test'); \ No newline at end of file diff --git a/src/disabled-blocks.js b/src/disabled-blocks.js index ffdd7917ae..085940d6c6 100644 --- a/src/disabled-blocks.js +++ b/src/disabled-blocks.js @@ -103,3 +103,4 @@ const applySettingsToMeta = metadata => { } addFilter( 'stackable.block.metadata', 'stackable/disabled-blocks', applySettingsToMeta ) +console.log( 'test' ) From 61a69d0ae4a4d7942814dd4a994a3dc5a8b8e214 Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Wed, 10 Sep 2025 18:01:40 +0800 Subject: [PATCH 13/13] updated filename --- .github/workflows/build-size-comparison.yml | 27 ++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-size-comparison.yml b/.github/workflows/build-size-comparison.yml index 5483f9d1af..d75706fb88 100644 --- a/.github/workflows/build-size-comparison.yml +++ b/.github/workflows/build-size-comparison.yml @@ -236,7 +236,7 @@ jobs: for change in flagged: status_icon = change['status'] - file_name = change['file'] + file_name = change['file'].replace('`', '\\`') # Escape backticks current_size = format_bytes(change['current_size']) base_size = format_bytes(change['base_size']) diff_size = format_bytes(abs(change['diff'])) @@ -249,7 +249,12 @@ jobs: else: change_str = '0B' - comment += f'| `{file_name}` | {current_size} | {base_size} | {change_str} | {percent:+.1f}% | {status_icon} |\n' + # Truncate long file names and escape special characters + display_name = file_name + if len(display_name) > 50: + display_name = '...' + display_name[-47:] + + comment += f'| `{display_name}` | {current_size} | {base_size} | {change_str} | {percent:+.1f}% | {status_icon} |\n' comment += '\n' @@ -261,7 +266,7 @@ jobs: for change in changes: status_icon = change['status'] - file_name = change['file'] + file_name = change['file'].replace('`', '\\`') # Escape backticks current_size = format_bytes(change['current_size']) base_size = format_bytes(change['base_size']) diff_size = format_bytes(abs(change['diff'])) @@ -274,7 +279,12 @@ jobs: else: change_str = '0B' - comment += f'| `{file_name}` | {current_size} | {base_size} | {change_str} | {percent:+.1f}% | {status_icon} |\n' + # Truncate long file names and escape special characters + display_name = file_name + if len(display_name) > 50: + display_name = '...' + display_name[-47:] + + comment += f'| `{display_name}` | {current_size} | {base_size} | {change_str} | {percent:+.1f}% | {status_icon} |\n' else: comment += f'## 📋 File Changes (showing first 50 of {len(changes)})\n\n' comment += '| File | Current | Base | Change | % | Status |\n' @@ -282,7 +292,7 @@ jobs: for change in changes[:50]: status_icon = change['status'] - file_name = change['file'] + file_name = change['file'].replace('`', '\\`') # Escape backticks current_size = format_bytes(change['current_size']) base_size = format_bytes(change['base_size']) diff_size = format_bytes(abs(change['diff'])) @@ -295,7 +305,12 @@ jobs: else: change_str = '0B' - comment += f'| `{file_name}` | {current_size} | {base_size} | {change_str} | {percent:+.1f}% | {status_icon} |\n' + # Truncate long file names and escape special characters + display_name = file_name + if len(display_name) > 50: + display_name = '...' + display_name[-47:] + + comment += f'| `{display_name}` | {current_size} | {base_size} | {change_str} | {percent:+.1f}% | {status_icon} |\n' # Save comment to file with open('pr_comment.md', 'w') as f: