Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 138 additions & 0 deletions .github/workflows/build-size-comparison.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: Build Size Comparison

on:
pull_request:
branches: [ master, develop ]

Comment on lines +1 to +6
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add explicit permissions and concurrency to harden and speed up the workflow.

  • Minimal permissions are safer, and comment posting needs issues: write.
  • Concurrency cancels stale runs for the same PR.
 name: Build Size Comparison

 on:
   pull_request:
     branches: [ master, develop ]
 
+permissions:
+  contents: read
+  issues: write
+  pull-requests: write
+
+concurrency:
+  group: build-size-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
name: Build Size Comparison
on:
pull_request:
branches: [ master, develop ]
name: Build Size Comparison
on:
pull_request:
branches: [ master, develop ]
permissions:
contents: read
issues: write
pull-requests: write
concurrency:
group: build-size-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
🤖 Prompt for AI Agents
.github/workflows/build-size-comparison.yml lines 1-6: add explicit
workflow-level permissions and a concurrency key to the YAML to tighten security
and cancel stale runs; set permissions to the minimal required (e.g.,
permissions: contents: read, issues: write) so the job can post comments, and
add a concurrency block (e.g., group: build-size-comparison-${{
github.event.pull_request.number }} and cancel-in-progress: true) to ensure only
the latest run for a PR proceeds.

jobs:
build-and-compare:
runs-on: ubuntu-latest
Comment on lines +8 to +9
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Skip the entire job for forked PRs to avoid secret access failures.

pull_request from forks won’t receive ${{ secrets.ACCESS_KEY }}; the job will fail at premium checkouts. Gate the job to run only for non-fork PRs.

 jobs:
   build-and-compare:
+    if: ${{ github.event.pull_request.head.repo.fork == false }}
     runs-on: ubuntu-latest
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
build-and-compare:
runs-on: ubuntu-latest
build-and-compare:
if: ${{ github.event.pull_request.head.repo.fork == false }}
runs-on: ubuntu-latest
🤖 Prompt for AI Agents
.github/workflows/build-size-comparison.yml around lines 8-9: the job currently
runs for pull_request events and will fail for forked PRs due to missing
secrets; add a job-level conditional to skip forked PRs by checking the source
repo. Modify the job to include an if condition such as: run if the event is not
a pull_request OR the pull request head repo equals the base repo (e.g. if:
github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository) so the job
only runs for non-fork PRs (and still runs for other events).


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: 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:
node-version: 14.x
cache: 'npm'

Comment on lines +39 to +44
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Update setup-node action and Node.js version (Node 14 is EOL; action v3 flagged).

Use actions/setup-node@v4 and a supported LTS (18.x or 20.x). Also cache all lockfiles via cache-dependency-path.

-    - name: Setup Node
-      uses: actions/setup-node@v3
+    - name: Setup Node
+      uses: actions/setup-node@v4
       with:
-        node-version: 14.x
-        cache: 'npm'
+        node-version: 20.x
+        cache: 'npm'
+        cache-dependency-path: |
+          package-lock.json
+          pro__premium_only/package-lock.json
+          base-branch/package-lock.json
+          base-branch/pro__premium_only/package-lock.json
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 14.x
cache: 'npm'
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'
cache-dependency-path: |
package-lock.json
pro__premium_only/package-lock.json
base-branch/package-lock.json
base-branch/pro__premium_only/package-lock.json
🧰 Tools
🪛 actionlint (1.7.7)

40-40: the runner of "actions/setup-node@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🤖 Prompt for AI Agents
.github/workflows/build-size-comparison.yml around lines 39-44: the workflow
uses actions/setup-node@v3 with Node 14 (EOL) and the deprecated 'cache' option;
update the action to actions/setup-node@v4 and set node-version to a supported
LTS (e.g., 18.x or 20.x), and replace the 'cache' key with
'cache-dependency-path' listing your lockfiles (e.g., package-lock.json,
yarn.lock, pnpm-lock.yaml) so all lockfiles are cached correctly.

- 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/*"

# 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)

# 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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Guard against divide-by-zero and show precise percentages.

If base-build.zip is empty, the script will divide by zero. Also, render percentages to two decimals for clarity.

         # 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))
+        DIFF_BYTES=$((CURRENT_BYTES - BASE_BYTES))
+        if [ "$BASE_BYTES" -eq 0 ]; then
+          echo "❌ **Error**: base-build.zip is empty (0 bytes), cannot compute percentage delta." >> $GITHUB_STEP_SUMMARY
+          exit 1
+        fi
+        DIFF_PERCENT=$(awk -v d="$DIFF_BYTES" -v b="$BASE_BYTES" 'BEGIN { printf("%.2f", (d*100.0)/b) }')
@@
-        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
+        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
+          # flip sign for display
+          POS_PCT=$(awk -v p="$DIFF_PERCENT" 'BEGIN { printf("%.2f", (p<0)?-p:p) }')
+          echo "📉 **Size decreased by** $(numfmt --to=iec $((DIFF_BYTES * -1))) (-$POS_PCT%)" >> $GITHUB_STEP_SUMMARY
         else:
           echo "✅ **No size change**" >> $GITHUB_STEP_SUMMARY
         fi

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 85-85: trailing spaces

(trailing-spaces)


[error] 91-91: trailing spaces

(trailing-spaces)


[error] 96-96: trailing spaces

(trailing-spaces)


[error] 100-100: trailing spaces

(trailing-spaces)


[error] 104-104: trailing spaces

(trailing-spaces)


[error] 108-108: trailing spaces

(trailing-spaces)


[error] 114-114: trailing spaces

(trailing-spaces)

🤖 Prompt for AI Agents
.github/workflows/build-size-comparison.yml around lines 81-121: the script
currently divides by BASE_BYTES which can be zero and calculates integer
percentages; update it to guard against divide-by-zero by checking if BASE_BYTES
is zero before computing DIFF_PERCENT — if BASE_BYTES is 0 and CURRENT_BYTES is
also 0 then report "No size change", otherwise report percentage as "N/A" or "∞"
as appropriate — and compute the percentage with two decimal places using a
floating-point tool like awk or bc (e.g. DIFF_PERCENT=$(awk "BEGIN {printf
\"%.2f\", ($DIFF_BYTES*100)/$BASE_BYTES}")), ensure sign handling when
DIFF_BYTES is negative and use numfmt for human-readable byte diffs as already
used for display.


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
31 changes: 0 additions & 31 deletions .github/workflows/compressed-diff.yml

This file was deleted.

Loading